Do you remember the line from The Simpsons when Homer is stressed... "Where's the ANY key?"
Here is my lame question... Is there a method / routine to simulate the ANY key without causing the CPU to chuck a fit? Similar to Basic's 'waitkey'
(11-18-2025, 07:41 PM)johnno56 Wrote: [ -> ]Do you remember the line from The Simpsons when Homer is stressed... "Where's the ANY key?"
Here is my lame question... Is there a method / routine to simulate the ANY key without causing the CPU to chuck a fit? Similar to Basic's 'waitkey'
Was there a "wait key" in n6? I don't remember.
Maybe:
Code:
while not inkey() fwait 60
Hm, but inkey can be a bit tricky. From the docs: "'inkey()' returns the ASCII code of any character that was processed from keyboard during the last wait call. The input is queued, and the function returns 0 when the queue is empty."
So ... perhaps:
Code:
function WaitKey()
' clear queue.
while inkey()
' wait for any key to be pressed.
while not inkey() fwait 60
endfunc
It will only work in a graphical window. For command line programs I just go with 'system "pause"'.
Just had a look through N6 docs... Nope... Nothing about wait key.
The game I am trying to convert/modify/adapt (more like butcher... lol) uses 'waitkey'... I will test both of your suggestions... I am not sure how, but I will try to work out how to monitor the impact on the CPU... could be fun! Thanks for the suggestions. Much appreciated.
Marcus,
Ran a small test to monitor the value of inkey() which always produced '0', unless a key is pressed, which then displayed the ASCII value of the key.
Then threw together the following. Quick and simple. Oh. Also monitored the CPU impact... an extra 0.04%
Code:
set window "Waitkey Test", 640, 480, false
set redraw off
do
set caret 320, 200
set color 255, 255, 0
center "Press ANY key to continue..."
if inkey() <> 0 break
redraw
fwait 60
until keydown(KEY_ESCAPE, true)
Will not be difficult to create a function... Now... My next concern is to decide which of my keys I am going to label as "any"... lol