This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
master39's profile picture

[SOLVED][LUA] os.pullEvent() freeze

Started by master39, 13 June 2012 - 02:26 PM
master39 #1
Posted 13 June 2012 - 04:26 PM
rednet.open("top")
while true do
term.clear()
term.setCursorPos(1,1)
print("REMOTE CONTROL CLIENT")
print("")
print("")
print("-MAIN CENTRALE")
print(" MAIN STORAGE")
print(" PORTA REATTORE")
print(" LUCI")
term.setCursorPos(1,4)
local event,param1 = os.pullEvent()
if event=="char" then
   print(")")
   if param1=="w" then
	l,r=term.getCursorPos()
	if l>4 then
	 write(" ")
	 term.setCursorPos(1,l-1)
	 write("-")
	end
   elseif param1=="s" then
	l,r=term.getCursorPos()
	if l<7 then
	 write(" ")
	 term.setCursorPos(1,l+1)
	 write("-")
	end
   elseif param1=="e" then
	l,r=term.getCursorPos()
	if l==4 then printMen(colors.white)
	elseif l==5 then printMen(colors.orange)
	elseif l==6 then printMen(colors.lightBlue)
	elseif l==7 then printMen(color.lime)
   end
end
end
end

the program freeze on the os.pullEvent and even if I press a key it won't continue can anyone help?

thanks
ardera #2
Posted 13 June 2012 - 04:48 PM
it don't freezes, you wrote an error! if the whole program is in a while loop, and it changes the selection, the program prints not changed values, but the start state is printed! so it selected an other option, then the while loop starts again, and it selected again the first option…
master39 #3
Posted 13 June 2012 - 04:52 PM
it don't freezes, you wrote an error! if the whole program is in a while loop, and it changes the selection, the program prints not changed values, but the start state is printed! so it selected an other option, then the while loop starts again, and it selected again the first option…
you're right, thank you for helping