Created Component/CommandBlock (markdown)

Florian Nücke 2013-12-07 04:20:56 -08:00
parent 9d10a8612a
commit e8044c574d

22
Component-CommandBlock.md Normal file

@ -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
```