From e8044c574d68dbf2017bc3b52178516f015af770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 7 Dec 2013 04:20:56 -0800 Subject: [PATCH] Created Component/CommandBlock (markdown) --- Component-CommandBlock.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Component-CommandBlock.md diff --git a/Component-CommandBlock.md b/Component-CommandBlock.md new file mode 100644 index 0000000..8e46fec --- /dev/null +++ b/Component-CommandBlock.md @@ -0,0 +1,22 @@ +This component represents a vanilla command block. + +Component name: `command_block`. +Callbacks: +- `getValue(): string` + The currently set command. +- `setValue(value: string): boolean` + Sets a new command for the command block. Returns `true` on success. +- `run(): number` + Tries to execute the command set in the command block. May use a custom (fake) username for executing commands as set in the config. Returns the numeric result from running the command, usually larger than one for success, zero for failure. + +Example use: +```lua +local cb = component.command_block -- get primary command block +-- os.time() returns "in-game seconds" with a 6000 tick offset, so that +-- midnight is actually midnight. +local ticks = math.floor(1000/60/60 * os.time() - 6000) +print(os.date()) +cb.setValue("time set " .. (ticks + 24000)) +cb.run() +print(os.date()) -- one day more than before +``` \ No newline at end of file