Posted 07 July 2012 - 01:54 PM
Hello everybody
I'm just experimenting with my code. And i really don't know why it's not working correct.
Even if i contains 1, the code executes this part of the code. The Problem is, that it never gets out of the loop.
Please can you explain why that code isn't working?
I'm just experimenting with my code. And i really don't know why it's not working correct.
while true do
local i
if i == nil then
i = 0
end
os.sleep(1)
rednet.broadcast(sFWName)
event, id, text = os.pullEvent("rednet_message")
if text == "message_received" then
print("Message received")
break
else
print("Message not received")
i = i + 1
end
if i == 2 then
i = nil
break
end
end
Even if i contains 1, the code executes this part of the code. The Problem is, that it never gets out of the loop.
if i == nil then
i = 0
end
Please can you explain why that code isn't working?