Table of Contents

VCI update on Virtual Cast 1.5.4a


vci.message.Emit

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

vci.message.On

The receiving function receives 3 arguments.

main.lua
function onMessage(sender, name, message)
    -- The sender is in a table structure The information of the VCI that executed the vci.message.Emit function
    -- {
    --   type: "vci"
    --   name: "name of the vci"
    -- }
    -- In the future, the sender will have new messages implemented
    for k, v in pairs(sender) do
        print(k .. ":" .. v)
    end
 
    print(name)
    print(message)
end
 
vci.message.On('MSG_NAME', onMessage)

About this feature

The difference between the shared variable and the message