67 lines
1.4 KiB
Markdown
67 lines
1.4 KiB
Markdown
# IScriptEvent.setValue
|
|
|
|
[← IScriptEvent](index.md) · [← Master](../../wiki.md)
|
|
|
|
Parça 3/3 · [önceki](setValue-2.md)
|
|
|
|
c.setValue("message", "Hello!");
|
|
|
|
// Schedule script "b" execution a second later
|
|
c.scheduleScript("b", "main", 20);
|
|
}
|
|
|
|
// Script "b"
|
|
function main(c)
|
|
{
|
|
c.send("A second ago, script \"a\" told me deliver this message: " + c.getValue("message"));
|
|
}
|
|
|
|
|
|
scheduleScript
|
|
|
|
void scheduleScript(int delay,
|
|
jdk.nashorn.api.scripting.ScriptObjectMirror function)
|
|
|
|
Schedule a JavaScript function (instead of script). Once the timer has expired, given function will be
|
|
called with this context as the only argument.
|
|
|
|
function main(c)
|
|
{
|
|
c.scheduleScript(60, function (context)
|
|
{
|
|
context.send("This was called three seconds later!");
|
|
});
|
|
}
|
|
|
|
|
|
scheduleScript
|
|
|
|
void scheduleScript(int delay,
|
|
java.util.function.Consumer<IScriptEvent> consumer)
|
|
|
|
Schedule a function (instead of script). Once the timer has expired, given function will be called with this
|
|
context as the only argument.
|
|
|
|
executeCommand
|
|
|
|
int executeCommand(java.lang.String command)
|
|
|
|
Execute a command.
|
|
|
|
c.executeCommand("/kick Creeper501");
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
How many successful commands were run. 0 - command errored, 1 - command was successful, 2 or
|
|
above - multiple commands were executed using target selectors.
|
|
|
|
send
|
|
|
|
void send(java.lang.String message)
|
|
|
|
Send a message to all players in the chat.
|
|
|
|
c.send("Hi :)");
|