Talk:Why does my on-keypress script freeze/produce errors when I hold down a key?

From OHRRPGCE-Wiki
Jump to: navigation, search

The Mad Cacti: The on-keypress script is not run if waitforkey is active, but it runs anyway on waitforscancode. Does this need fixing? See SUB onkeyscript, yetmore.bas

Bob the Hamster: hmm. yes. It should probably be consistent.

Alternative Solution[edit]

I ran into this problem a while back; I solved it by creating a blank On Keypress script and just calling Set On Keypress Script (@my blank keypress script) as the first line in a 'Then' block, and then re-setting it to whatever the keypress script had been before the script was called. :)

 if (key is pressed (any key))
 then (
   set on keypress script (@myblankkeypressscript)
 
   # Do commands
 
   wait (2)
   set on keypress script (@mykeypressscript)
 )

It's worked for me quite well! :)

The Mad Cacti: You don't have to supply a blank keypress script, writing "set on keypress script" will set no script.