Version: stable
FUNCTION | |
---|---|
msg.url() | creates a new URL |
msg.url() | creates a new URL from a string |
msg.url() | creates a new URL from separate arguments |
msg.post() | posts a message to a receiving URL |
msg.url()
msg.url(nil)
or msg.url("#")
, which creates an url to the current
script component.
PARAMETERS
RETURNS
url |
a new URL |
EXAMPLES
Create a new URL which will address the current script:local my_url = msg.url() print(my_url) --> url: [current_collection:/my_instance#my_component]
msg.url(urlstring)
[socket:][path][#fragment]
, which is similar to a HTTP URL.
When addressing instances:
socket
is the name of a valid world (a collection)path
is the id of the instance, which can either be relative the instance of the calling script or globalfragment
would be the id of the desired component"."
the current game object"#"
the current componentPARAMETERS
urlstring |
string to create the url from |
RETURNS
url |
a new URL |
EXAMPLES
local my_url = msg.url("#my_component") print(my_url) --> url: [current_collection:/my_instance#my_component] local my_url = msg.url("my_collection:/my_sub_collection/my_instance#my_component") print(my_url) --> url: [my_collection:/my_sub_collection/my_instance#my_component] local my_url = msg.url("my_socket:") print(my_url) --> url: [my_collection:]
msg.url([socket],[path],[fragment])
PARAMETERS
[socket] |
socket of the URL |
[path] |
path of the URL |
[fragment] |
fragment of the URL |
RETURNS
url |
a new URL |
EXAMPLES
local my_socket = "main" -- specify by valid name local my_path = hash("/my_collection/my_gameobject") -- specify as string or hash local my_fragment = "component" -- specify as string or hash local my_url = msg.url(my_socket, my_path, my_fragment) print(my_url) --> url: [main:/my_collection/my_gameobject#component] print(my_url.socket) --> 786443 (internal numeric value) print(my_url.path) --> hash: [/my_collection/my_gameobject] print(my_url.fragment) --> hash: [component]
msg.post(receiver,message_id,[message])
"."
the current game object"#"
the current componentPARAMETERS
receiver |
The receiver must be a string in URL-format, a URL object or a hashed string. |
message_id |
The id must be a string or a hashed string. |
[message] |
a lua table with message parameters to send. |
EXAMPLES
Send "enable" to the sprite "my_sprite" in "my_gameobject":msg.post("my_gameobject#my_sprite", "enable")
local params = {my_parameter = "my_value"} msg.post(my_url, "my_message", params)