0

Lua in ComputerCraft 1.5

This seems to work but the recursive loops is breaking after 4 or 5 times running.

Cannot seem to see why.

Am i doing something incredibly wrong here? Full Code


Snippet for the loop:

x = 1

function loop()
 if x > 0 then
  getTarg()
  derp1()
  sleep(2.9)
  monInit()
  loop()
 end
end

loop()
3
  • Well it will eventually overflow your stack, though not after 5 times. Commented Jun 17, 2015 at 1:24
  • x may clash with another global, try changing the condition to if true then .... Commented Jun 17, 2015 at 1:33
  • 1
    try change to return loop() Commented Jun 17, 2015 at 5:30

1 Answer 1

1

It looks as though you are not even using the X var... so why don't you try this... this is a more effective way to keep doing the same thing over and over

while true do
    getTarg()
    derp1()
    sleep(2.9)
    monInit()
end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.