5 posts
Posted 30 April 2012 - 08:11 PM
Basically, i need my program to wait for redstone input. But it crashes, with the error: "Too long without yielding".
This is how i wait:
while redstone.getOutput("back") == false do
i = 1
end
How can i stop my program from crashing?
474 posts
Posted 30 April 2012 - 08:16 PM
while not redstone.getInput("back") do
os.queueEvent("randomEvent")
os.pullEvent()
i = 1
end
Fixed code. ^^
5 posts
Posted 30 April 2012 - 08:18 PM
Thanks!
Also, how do i read a file, and get the string in a variable named "password")
5 posts
Posted 30 April 2012 - 08:24 PM
Sorry, the code just hangs the pc. Any other way of waiting for input of redstone?
1604 posts
Posted 30 April 2012 - 08:34 PM
Queueing too many events is probably the problem. This is what the "redstone" event is for:
while true do
os.pullEvent("redstone")
if rs.getInput("back") then
break
end
end
It will wait for any change in redstone input and then check if the input is in the side you want and break the loop if it is.
474 posts
Posted 30 April 2012 - 08:34 PM
Sorry, the code just hangs the pc. Any other way of waiting for input of redstone?
Try this:
while true do
sleep(0)
local event = os.pullEvent()
if event == "redstone" then
break
end
end
718 posts
Location
Hawaii
Posted 01 May 2012 - 06:39 PM
Thanks!
Also, how do i read a file, and get the string in a variable named "password")
file = fs.open("filenname", "r") -- r = read only
correctPass = file:read()
file:close()
Then you can do
write("Password: ")
if read("*") == correctPass then
--your code
end
(Oops, didn't see your other post)
Edited on 01 May 2012 - 04:39 PM
9 posts
Posted 03 September 2012 - 12:03 PM
What if you want your turtle/computer to do a certain thing until it receives a redstone pulse?
9 posts
Posted 15 May 2013 - 07:21 AM
I have the problem withe 3 codes working together
http://pastebin.com/B4ZpxpmVhttp://pastebin.com/yQSvCCQKhttp://pastebin.com/jypAecUhand on the turtle it says
Too long without yieldingbut on computer nothing