This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
dragonhippie's profile picture

Attempt to call nil error.

Started by dragonhippie, 24 July 2013 - 12:35 PM
dragonhippie #1
Posted 24 July 2013 - 02:35 PM
Need to know how to let the code keep going as a redstone has been activated from the "left" of the turtle.

what i have so far (not "all" of it, just a sample):

if rs.Input("left") then
  turtle.forward()
  sleep(2)
  turtle.back()
end
but i cant get it to run, it just displays "call nill"


Full code:

if rs.getInput("left") then
  turtle.forward()
  sleep(1)
  turtle.forward()
  sleep(1)
  turtle.forward()
  sleep(1)
  turtle.select(1)
  turtle.placeDown()
  turtle.turnRight()
  turtle.place()
  turtle.turnLeft()
  turtle.turnLeft()
  turtle.place()
  turtle.up()
  turtle.placeDown()
  turtle.select(2)
  turtle.place()
  turtle.turnRight()
  turtle.turnRight()
  turtle.place()
  turtle.turnLeft()
  turtle.back()
  turtle.place()
  turtle.down()
  turtle.back()
  turtle.back()
  sleep(120) 
end
Lyqyd #2
Posted 24 July 2013 - 02:57 PM
Split into new topic.

It's `rs.getInput`. In the future, post the whole code and the full text of the error message.
dragonhippie #3
Posted 24 July 2013 - 10:24 PM
Split into new topic.

It's `rs.getInput`. In the future, post the whole code and the full text of the error message.
thanks for that. But im having another issue :P/>

im trying to keep the program running till it retrieves a red stone signal, and than it would move. But i run the program and nothing happens.

Ill edit first post with the "full code".
Lyqyd #4
Posted 24 July 2013 - 10:40 PM
Put these lines at the beginning of the code:


while true do
os.pullEvent("redstone")

and this at the end:


end

That will make your code continue to loop forever, but wait for a change in redstone state before running the code to check if the input is high.
dragonhippie #5
Posted 24 July 2013 - 10:51 PM
Put these lines at the beginning of the code:


while true do
os.pullEvent("redstone")

and this at the end:


end

That will make your code continue to loop forever, but wait for a change in redstone state before running the code to check if the input is high.

Thank you very much :)/>
now my auto wither killer is complete! :D/>