12 posts
Posted 21 November 2013 - 12:12 PM
Hey guys! I am having an issue with my program. The computer is waiting for the responce message back from the turtle, so it never continues! How can I pass the wait time? Would a try catch work? Thanks! If you need the code tell me and I will upload around 5PM EST.
8543 posts
Posted 21 November 2013 - 02:12 PM
You should upload the code. You'll probably want to have a basic event handling loop that looks for rednet_message events as well.
1852 posts
Location
Sweden
Posted 21 November 2013 - 02:25 PM
Well.. You do know that the rednet.receive() has a timeout right?
EXAMPLE
local timeout = 5
id, msg = rednet.receive(timeout)
if id == nil then
print("You haven't received any messages D:")
else
print(id .. ":" .. msg)
end
But as mentioned by Lyqyd you'll probably want to use basic event handling
EXAMPLE
while true do
local evt, id, msg = os.pullEvent()
if evt == "rednet_message" then
print(id .. ":" .. msg)
end
end
Edited on 21 November 2013 - 01:26 PM
12 posts
Posted 21 November 2013 - 06:52 PM
Well.. You do know that the rednet.receive() has a timeout right?
EXAMPLE
local timeout = 5
id, msg = rednet.receive(timeout)
if id == nil then
print("You haven't received any messages D:")
else
print(id .. ":" .. msg)
end
But as mentioned by Lyqyd you'll probably want to use basic event handling
EXAMPLE
while true do
local evt, id, msg = os.pullEvent()
if evt == "rednet_message" then
print(id .. ":" .. msg)
end
end
Thank you very much, I did not know that rednet had a time out function. I have terrible internet where I live and just learned about rednet, it is tons of fun! I +1'd you, thank you for your time. ~Papa Beans
7508 posts
Location
Australia
Posted 21 November 2013 - 08:41 PM
Also just as a side point. There is not try/catch in Lua.
12 posts
Posted 22 November 2013 - 01:56 PM
Also just as a side point. There is not try/catch in Lua.
Thanks xP too much VB haha.