====== Message system (VCI update) ====== The message system has following features.\\ * Send messages from one VCI to another VCI * Receive messages * Receive comments from the system ---- ===== Implemented messages ===== ^ 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 | ---- ===== Show comments on a debug log ===== 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.\\ * Username \\ **message** will have following value assigned.\\ * Comment body\\ ---- ===== Receive messages(vci.message.On) ===== The receiving function receives three arguments.\\ * sender: Information about the sender * name: Name of the message * message: Content of the message 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) ---- ==== Receive comment message ===== 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.\\ ---- ==== Receive vci message ===== 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. ---- ===== Send VCI message (vci.message.Emit) ===== * Sends a message * The message will be sent to all VCIs of all users including the sender itself. function onUse(self) -- Message name: MSG_NAME -- Content of the message: 1 vci.message.Emit('MSG_NAME', 1) end