Gamestudio Links
Zorro Links
Newest Posts
Training with the R bridge does not work
by frutza. 11/19/25 22:32
ZorroGPT
by TipmyPip. 11/19/25 10:10
MRC.c and WFO
by 11honza11. 11/18/25 15:22
webGL
by Ice2642. 11/17/25 21:27
Camera always moves upwards?
by NeoDumont. 11/17/25 09:56
Future of ZorroHFT
by TipmyPip. 11/16/25 13:52
COT Download with Quandl does not work
by Petra. 11/15/25 09:35
Zorro 2.70
by jcl. 11/15/25 08:43
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, Quad), 7,176 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
SkinnyApe, tritom, sheliepaley, Blueguy, blobplayintennis
19179 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
"release" key (do something) #152208
09/05/07 07:38
09/05/07 07:38
Joined: Aug 2005
Posts: 390
Florida
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

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
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

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
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

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: oldschoolj] #152211
09/05/07 08:05
09/05/07 08:05
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
I've edited my previous post, let me know if the
code is work for you.

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
N
nfs42 Offline
Serious User
nfs42  Offline
Serious User
N

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
O
oldschoolj Offline OP
Senior Member
oldschoolj  Offline OP
Senior Member
O

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
U
ultranet Offline
Newbie
ultranet  Offline
Newbie
U

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);
}
}




Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1