15 posts
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.
7083 posts
Location
Tasmania (AU)
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.
15 posts
Posted 22 April 2016 - 07:37 AM
Thanks for the quick reply, works perfectly