This translation is older than the original page and might be outdated. See what has changed.
Translations of this page:

Sidebar

en:vci:updatelog:messagesystem

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

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.

  • 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
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)

  • Sends a message
  • The message will be sent to all VCIs of all users including the sender itself.
main.lua
function onUse(self)
    -- Message name: MSG_NAME
    -- Content of the message: 1
    vci.message.Emit('MSG_NAME', 1)
end
en/vci/updatelog/messagesystem.txt · Last modified: 2019/06/21 16:49 by h-eguchi

Page Tools