Table of Contents

Message system (VCI update)

The message system has following features.


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

main.lua
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.


Receive messages(vci.message.On)

The receiving function receives three arguments.

main.lua
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

main.lua
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
main.lua
{
   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

main.lua
function onMessage(sender, name, message)   
end

The structure of the sender is as follows.

main.lua
{
   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)

main.lua
function onUse(self)
    -- Message name: MSG_NAME
    -- Content of the message: 1
    vci.message.Emit('MSG_NAME', 1)
end