Cmd: Difference between revisions
Jump to navigation
Jump to search
add info about com: and comu: links |
mNo edit summary |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 30: | Line 30: | ||
// send a message with the text "hi" with the username and Uvias ID | // send a message with the text "hi" with the username and Uvias ID | ||
w.broadcastCommand("hi", true); | w.broadcastCommand("hi", true); | ||
// are the same as above | |||
network.cmd("hi", false); | |||
network.cmd("hi", true); | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 46: | Line 51: | ||
==References== | ==References== | ||
<references /> | <references /> | ||
[[Category:Documentation]] | |||
[[Category:Scripts]] | |||
[[Category:Tutorials]] | |||
Latest revision as of 00:33, 19 August 2025
cmd is a feature of OWOT that allows scripts to exchange string messages.
Using cmd in scripts
Receiving cmd messages:
// Start receiving cmd messages
w.broadcastReceive();
// cmd message event
w.on("cmd", e =>
{
/*
Process the message here.
Properties:
kind = always "cmd"
data = the actual text of the cmd message
sender = the sender's channel id
source = always "cmd"
username (optional) = the sender's username
id (optional) = the sender's Uvias ID
*/
console.table(e);
});
Sending cmd messages:
// send a message with the text "hi" without the username and Uvias ID
w.broadcastCommand("hi", false);
// send a message with the text "hi" with the username and Uvias ID
w.broadcastCommand("hi", true);
// are the same as above
network.cmd("hi", false);
network.cmd("hi", true);
com: and comu: links
cmd messages can also be sent with special links. This allows for interactive scripts.
For example:
- The link
com:hiwill send a "hi" cmd message without the username and Uvias ID. - The link
comu:hiwill send a "hi" cmd message with the username and Uvias ID.
Limitations
cmd has some limitations:
- You can send only 192 cmd messages per second[1]
- The text of a cmd message can't be longer than 2048[2]
- cmd can only transmit strings, data of other types has to be serialized into a string[2]