|
"release" key (do something)
#152208
09/05/07 07:38
09/05/07 07:38
|
Joined: Aug 2005
Posts: 390 Florida
oldschoolj
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2005
Posts: 390
Florida
|
Does anyone know how to express that you want something to happen if you release a key? I would really save alot of problems, but I cant find a wa yto do this.
example:
if (key_s is released) { do this.....; }
you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe.
__________________________________
yours truly
|
|
|
Re: "release" key (do something)
[Re: oldschoolj]
#152209
09/05/07 07:43
09/05/07 07:43
|
Joined: Aug 2005
Posts: 1,558 HK
vlau
Serious User
|
Serious User
Joined: Aug 2005
Posts: 1,558
HK
|
key_lastpressed? Maybe: Code:
while(1) { if (key_s) { // do something if 'S' is pressed } else { if (key_lastpressed == 31) // if 'S' is released { // do something if 'S' is released } } wait(1); }
Last edited by vlau; 09/05/07 08:02.
|
|
|
Re: "release" key (do something)
[Re: vlau]
#152210
09/05/07 07:54
09/05/07 07:54
|
Joined: Aug 2005
Posts: 390 Florida
oldschoolj
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2005
Posts: 390
Florida
|
ya I saw that, but it won't work in this scenario. Basicly, my character will run while I have the w or s keys pressed, but I want an animation and a few functions to run when I release the w or s keys. The problem is, that if I just state:
if (key_w == 0) || (key_s == 0) { do this; then this; }
what will happen is that it will do it whenever they are not pressed. So I need a way to say, "if I just released this button, do this".
key_lastpressed is nice, but I don't see how that could work for me in this situation.
you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe.
__________________________________
yours truly
|
|
|
Re: "release" key (do something)
[Re: vlau]
#152212
09/05/07 09:07
09/05/07 09:07
|
Joined: Jun 2001
Posts: 1,004 Dossenbach
nfs42
Serious User
|
Serious User
Joined: Jun 2001
Posts: 1,004
Dossenbach
|
Code:
//var key_s_released; function wait for_released_s(){ // key_s_released = 0; while(key_s){ wait(1); } // key_s_released = 1; //do your stuff her or use key_s_released in your action } on_s = wait for_released_s;
Andreas GSTools - Home of GSTScript 0.9.8: lua scripting for A6/7/8 GSTNet 0.7.9.20: network plugin for A6/7/8 GSTsqlite 1.3.7: sql database plugin for A6/7/8 3DGS Codebase: 57 snippets || 3DGS Downloads: 248 files
|
|
|
Re: "release" key (do something)
[Re: nfs42]
#152213
09/05/07 09:13
09/05/07 09:13
|
Joined: Aug 2005
Posts: 390 Florida
oldschoolj
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2005
Posts: 390
Florida
|
nice thanks a bunch!
you can find me with my face in the keyboard, unshaven, listening to some nameless techno tragedy, and hashing through code over a cold cup a stale joe.
__________________________________
yours truly
|
|
|
Re: "release" key (do something)
[Re: oldschoolj]
#152214
09/05/07 10:09
09/05/07 10:09
|
Joined: Jul 2005
Posts: 34 Hong Kong
ultranet
Newbie
|
Newbie
Joined: Jul 2005
Posts: 34
Hong Kong
|
Code:
var s_release=OFF;
action someAction{ while(1) { if(key_s) s_release=ON; if(s_release && !key_s) { //do something here... s_release=OFF; } wait(1); } }
|
|
|
|