Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/19/24 18:45
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, Ayumi, kzhao, 7th_zorro), 735 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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