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

[SOLVED] Text not appearing (Weird bug)

Started by Kadecamz, 12 September 2012 - 09:03 PM
Kadecamz #1
Posted 12 September 2012 - 11:03 PM

term.clear()
sleep(0)
term.setCursorPos(1,1)
event, p1 = os.pullEvent("key")
print("Press ESC to shutdown")
print("Press any other key to go back to normal")
if p1 == 1 then
write("Shutting Down")
sleep(1)
write(".")
sleep(1)
write(".")
sleep(1)
write(".")
sleep(1)
os.shutdown()
else
print("Returning to normal")
write("14%")
sleep(1)
term.setCursorPos(1,3)
write("34%")
sleep(1)
term.setCursorPos(1,3)
write("57%")
sleep(1)
term.setCursorPos(1,3)
write("78%")
sleep(1)
term.setCursorPos(1,3)
write("97%")
sleep(1)
term.setCursorPos(1,3)
print("Done!")
sleep(2)
term.clear()
sleep(0)
term.setCursorPos(1,1)
shell.run("startup")
end

I made an improved exit program, but there is a weird bug where when I run the program it doesn't show the text till I press one of the keys.
Cranium #2
Posted 12 September 2012 - 11:14 PM
That's simple. The os.pullEvent() command halts all function calls until it receives an event. You will want to have your two print commands BEFORE your os.pullEvent() function call.
MysticT #3
Posted 12 September 2012 - 11:16 PM
You told it to wait for a key:

event, p1 = os.pullEvent("key")
So it will wait for a key :)/>/>
Kadecamz #4
Posted 12 September 2012 - 11:16 PM
Oh, thank you!