Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
SysoevDV

Command block does not work

Question

Hi.
Please tell me why when I use the command block (via the adapter) for some reason it is not allowed to set its value.
Example (from Wiki):

local component = require("component") 
local cb = component.command_block 
local ticks = math.floor(1000/60/60 * os.time() - 6000) 
print(os.date()) 
cb.setValue("time set " .. (ticks + 24000)) 
cb.run() 
print(os.date())

And I get an error:

/command:8: attempt to call field 'setValue' (a nil value)
stack traceback:
/command:8: in main chunk
(..tail calls..)

So how do I get a command block to execute commands through OC?
Thank you in advance for your answers!


 

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

It's possible that this functionality was removed, since you're looking at the old wiki and I can't find anything about it on the new one, which is at:

 

http://ocdoc.cil.li

 

If you need to execute commands via computers, you could take a look at (and likely use) the debug card's component:

 

http://ocdoc.cil.li/component:debug

Link to post
Share on other sites
  • 0

Command blocks has three methods:

cb.setCommand(command)
cb.getCommand()
cb.executeCommand()

So your code must look like this:

local component = require("component") 
local cb = component.command_block 
local ticks = math.floor(1000/60/60 * os.time() - 6000) 
print(os.date()) 
cb.setCommand("time set " .. (ticks + 24000)) 
cb.executeCommand() 
print(os.date())

If command block driver was disabled in the config, this program would crash with error "no such component".

 

P. S. This wiki is outdated, use ocdoc.cil.li.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.