-
Notifications
You must be signed in to change notification settings - Fork 432
Component CommandBlock
Vexatos edited this page Jul 13, 2014
·
6 revisions
For those that don't like images: the wiki has moved to a new place, http://ocdoc.cil.li/.
This wiki will no longer be updated.
This component represents a vanilla command block.
Important: this component is only available if OpenComponents is also installed!
Component name: command_block
.
Callbacks:
-
getValue(): string
The currently set command. -
setValue(value: string): boolean
Sets a new command for the command block. Returnstrue
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:
local component = require("component")
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