145 posts
Location
the vast cosmos of my mind; binary!
Posted 09 February 2013 - 06:53 PM
help i can't get this to work
function start()
if redstone.getinput("back") then
turtle.place("front")
start()
end
end
start()
71 posts
Location
Nerdfightaria Island
Posted 09 February 2013 - 07:17 PM
It looks like you are using the function in its own function. That's a big no no. Basically, when you run it, it is going to go down the code, then try to do the function start, go down the code again, try to do the function start again, into infinity. If you don't call the function in its own function
it will work fine. If you want it to repeat try doing a for loop or a while loop.
i = 5 -- however many time you want it to do it
for q = 1,i do
start()
end
or, if you want it to repeat forever try
while true do
start()
end
Next time, try to give more information, like the error code that the program spits back out at you.
2005 posts
Posted 09 February 2013 - 08:56 PM
What is "working"?
That is, what is this supposed to do?
Right now, it just throws an attempt to call nil error cause redstone.getinput is nil.
2088 posts
Location
South Africa
Posted 10 February 2013 - 12:14 AM
It looks like you are using the function in its own function. That's a big no no.
Only if the redstone input on the back is true
2005 posts
Posted 10 February 2013 - 05:47 AM
Meh, it's a no no for our purposes anyway. This code will never actually recurse because as it is now it won't run at all. Once conditions are arranged so that it can recurse, it will overflow the stack very quickly.