Jump to content




Help with simple program :(

turtle

  • You cannot reply to this topic
5 replies to this topic

#1 rabin0l

  • Members
  • 3 posts

Posted 24 December 2015 - 04:44 PM

I am not very good at this, but I wanted to try to make an automated Ender Lily farm for Tekkit Space. I used some project red stuff and the turtle. I wrote a program with an infinite while loop but the turtle just restarts for no reason.
Here's the code
local boolreds = redstone.getInput("left")
while true do
  if boolreds==true then
    turtle.dig()
    sleep(15)
    turtle.place()
    turtle.select(2)
    turtle.place()
  end
end
Thanks in advance.

#2 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 24 December 2015 - 05:46 PM

That program checks for the redstone input on the left once and stores the result in boolreds. It never changes boolreds again. If you run the program while the redstone input is off, boolreds will be set to false forever. Since boolreds is false, the if branch is skipped and the loop is repeated. Doing nothing in an infinite loop results in a yield timeout crash.

The program should check for the redstone input in every iteration of the infinite loop instead.

Solution (read it only if you must, see if you can get it working yourself)

Edited by LBPHacker, 24 December 2015 - 09:04 PM.


#3 rabin0l

  • Members
  • 3 posts

Posted 24 December 2015 - 11:35 PM

Yes, LBP, thanks, I figured it out like 20 minutes after I uploaded this :).
I do have a problem though. The lily seeds somehow end up in slot number 3 and I don't know why. I guess I'll have to check every slot and place block :/

#4 LBPHacker

  • Members
  • 766 posts
  • LocationBudapest, Hungary

Posted 25 December 2015 - 12:29 AM

Instead of the first one, you mean?

#5 rabin0l

  • Members
  • 3 posts

Posted 25 December 2015 - 01:15 AM

First or second, thats why I place and then switch to slot 2 and place again. I may have figured out what does it. I think it depends on which slot is selected when the seed is broken. Here: pastebin

#6 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 26 December 2015 - 01:50 AM

View Postrabin0l, on 25 December 2015 - 01:15 AM, said:

I think it depends on which slot is selected when the seed is broken

Exactly, items that are picked up by the turtle will go into the selected slot, if there isn't already a partial stack in the turtles inventory





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users