function onUse(self) -- Message name: MSG_NAME -- Content of the message: 1 vci.message.Emit('MSG_NAME', 1) end
The receiving function receives 3 arguments.
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)
The difference between the shared variable and the message