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

Confirmation check?

Started by flaunting, 21 April 2016 - 08:51 AM
flaunting #1
Posted 21 April 2016 - 10:51 AM
I am writing a program in which I want a check before the program is run,

I want the program to print "press Enter to continue"

and then wait for the enter key to be pressed but can't find how to do this.
Bomb Bloke #2
Posted 21 April 2016 - 11:43 AM
Pretty much any time you want your script to pause, you do so by making it yield, and waiting for it to be resumed by a certain event; for example, if you call sleep(), then the function starts a timer for you and yields until the corresponding timer event is generated.

In this case you want a key event:

print("Press enter to continue...")

repeat
  local event, key = os.pullEvent("key")
until key == keys.enter

See this page on os.pullEvent() for more info.
flaunting #3
Posted 22 April 2016 - 07:37 AM
Thanks for the quick reply, works perfectly