The message system has following features.
Version | Name | Content |
---|---|---|
1.5.4a | Any string | Messages emitted (vci.message.Emit) from a VCI script |
1.5.6a | comment | Comment messages sent from the system |
function onMessage(sender, name, message) -- User name print(sender["name"]) -- Body of the comment print(message) end vci.message.On('comment', onMessage)
sender[“name”] will have following value assigned.
message will have following value assigned.
The receiving function receives three arguments.
function onMessage(sender, name, message) for k, v in pairs(sender) do print(k .. ":" .. v) end print(name) print(message) end -- To receive a message from a VCI item vci.message.On('MSG_NAME', onMessage) -- To receive comments vci.message.On('comment', onMessage)
function onMessage(sender, name, message) end
Argument | Content |
---|---|
sender[“name”] | Name of the sender |
sender[“type”] | Type of the sender |
name | |
message | Body of the message |
{ type: "comment" name: "Name of the user who sent the message" }
The structure of the sender is shown above.
sender[“name”] is name of the sender and sender[“type”] is type of the sender.
function onMessage(sender, name, message) end
The structure of the sender is as follows.
{ type: "vci" name: "name of the vci" }
name is the first argument of vci.message.Emit.
message is the second argument of vci.message.Emit.
function onUse(self) -- Message name: MSG_NAME -- Content of the message: 1 vci.message.Emit('MSG_NAME', 1) end