Skip to content

Component CommandBlock

Florian Nücke edited this page Dec 7, 2013 · 6 revisions

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:

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
Clone this wiki locally