TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Feb 27, 2009 2:49 am Post subject: |
|
|
Ah!
First, a tip. This is unreadable:
| Code: | | set input key (5,17,18) |
Write this instead:
| Code: | | set input key (@BUTTON start,17,18) |
Now, your setinputkey script is way longer than it needs to be. You'll notice that in the example I posted I used 1 line per key, you've duplicated a lot of code and used 17! Here's one reason why code duplication is a bad thing: you've made a mistake, and instead of fixing a single line of code you now have to a hundred. However, you can use find-and-replace.
In setinputkey:
| Code: | | set variable (GVar,17) |
GVar is the ID of the global variable holding the scancode, write this instead:
| Code: | | write global variable (GVar, 17) |
or better:
| Code: | | write global variable (GVar, key:W) |
And in getinputkey:
should be
| Code: | | if (read global variable(GVar) == 18) |
What I recommend you do is delete setinputkey and replace it with this small script:
| Code: | script, Set Input Key, GVar=0, string1=0, string2=1, begin
variable (i)
for (i, 0, 147) do (
if (key is pressed (i)) then (
set on keypress script (@nokeypress)
if ((i >= 2 && i <= 54) #key:1 to key:RIGHTSPACE
|| i == 56 || i == 57 #key:ALT || i == key:SPACE
|| (i >= 71 && i <= 83) #key:HOME to key:DELETE
|| (i >= 128 && i <= 147)) #joy:BUTTON 1 to joy:Y DOWN
then (
# pressed a valid key
write global variable (GVar, i)
)
# if not a valid key: do nothing
get input key (GVar,string1,string2)
set tag (tag:CUSTOMIZING,off)
wait (2)
set on keypress script (@optionstwokeypressscript)
exit script
)
)
end |
I hope I got the key ranges right. _________________ "It is so great it is insanely great." |
|