Posted 12 October 2013 - 11:55 AM
I'm trying to set up a turtle that will place a specific mystcraft book into a portal book receptacle based on a specific button being pressed. (it also does some fancy stuff with activating drawbridges to expose the portal, and controls a router with redstone because turtles can't suck out of book receptacles in this version.)
I know very little about programming, but the method I came up with was to loop an if/else if with an else if for each frequency of the bundled cable.
Unfortunately when I run it it goes for a few seconds then quits and returns "startup:11: Too long without yielding"
I would greatly appreciate any help or advice in rewriting this to something that will actually work.
http://pastebin.com/JkGsCBSM
I know very little about programming, but the method I came up with was to loop an if/else if with an else if for each frequency of the bundled cable.
Unfortunately when I run it it goes for a few seconds then quits and returns "startup:11: Too long without yielding"
I would greatly appreciate any help or advice in rewriting this to something that will actually work.
http://pastebin.com/JkGsCBSM
Spoiler
while true do
if rs.getBundledInput("back") ==1 --getting the input from a button connected with rednet cable
then rs.setBundledOutput("right", 9) --Activating drawbridges to expose the portal, and disabling the router
turtle.select(1) --Selecting the appropriate book for this button
turtle.drop() --Placing the book
os.sleep(10) --Delay for people to enter the portal
rs.setBundledOutput("right", 1) --Enabling the router to suck the book out (drawbridges still activated)
os.sleep(.1) --delay to make sure book is pulled out
turtle.suckDown() --pulling the book out of the router back into the turtle
rs.setBundledOutput("right", 0) --resetting the drawbridges
else if rs.getBundledInput("back") ==2
then rs.setBundledOutput("right", 9)
turtle.select(2)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==4
then rs.setBundledOutput("right", 9)
turtle.select(3)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==8
then rs.setBundledOutput("right", 9)
turtle.select(4)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==16
then rs.setBundledOutput("right", 9)
turtle.select(5)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==32
then rs.setBundledOutput("right", 9)
turtle.select(6)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==64
then rs.setBundledOutput("right", 9)
turtle.select(7)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==128
then rs.setBundledOutput("right", 9)
turtle.select(8)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
if rs.getBundledInput("back") ==256
then rs.setBundledOutput("right", 9)
turtle.select(9)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==512
then rs.setBundledOutput("right", 9)
turtle.select(10)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==1024
then rs.setBundledOutput("right", 9)
turtle.select(11)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==2048
then rs.setBundledOutput("right", 9)
turtle.select(12)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==4096
then rs.setBundledOutput("right", 9)
turtle.select(13)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==8192
then rs.setBundledOutput("right", 9)
turtle.select(14)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==16384
then rs.setBundledOutput("right", 9)
turtle.select(15)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
else if rs.getBundledInput("back") ==32768
then rs.setBundledOutput("right", 9)
turtle.select(16)
turtle.drop()
os.sleep(10)
rs.setBundledOutput("right", 1)
os.sleep(.1)
turtle.suckDown()
rs.setBundledOutput("right", 0)
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end