Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Joey, flink, AndrewAMD), 1,226 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
One time key push #242025
12/20/08 21:52
12/20/08 21:52
Joined: Sep 2008
Posts: 69
U
upsidedownman Offline OP
Junior Member
upsidedownman  Offline OP
Junior Member
U

Joined: Sep 2008
Posts: 69
Hi, i was trying to get a variable changed when the space key is pressed and that variable makes a while loop start, and then at a certain point the variable is changed back to make the while loop stop.

here is an example of what i mean.
Code:
function test()
{
	while(a == 1)
	{
		g = 6;
		a = 0;
		wait(1);
	}
}

function run_101()
{
	while(1)
	{
		if(key_space)
		{
			a = 1;
		}
		wait(1);
	}
}

Except while i am holding the space key a continues to equal 1, i just want it to equal one when the space key is pressed and then go about the while loop and act like the space key was released right away even if i am holding it down. I tried putting a while(key_space){wait(1);} in there but that requires me to let the space key up for it to trigger. I tried using on_space also but it crashes.

I also need to be able to do this more than once so its in a while loop.

Can any1 help?

Re: One time key push [Re: upsidedownman] #242027
12/20/08 21:56
12/20/08 21:56
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
Code:
function test()
{
	while(a == 1)
	{
		g = 6;
		a = 0;
		wait(1);
	}
}

function run_101()
{
	while(1)
	{
		if(key_space && a == 0)
		{
			a = 1;
		}
		wait(1);
	}
}

maybe something like that? this time it will do only one loop and it will wont come in this function until you set a = 0; somewhere and press the space bar then.

hope this helps you smile



Ubi bene, ibi Patria.
Re: One time key push [Re: croman] #242028
12/20/08 21:59
12/20/08 21:59
Joined: Sep 2008
Posts: 69
U
upsidedownman Offline OP
Junior Member
upsidedownman  Offline OP
Junior Member
U

Joined: Sep 2008
Posts: 69
Didn't work because a is being set to 0 at the end of the loop. But thanks.

Re: One time key push [Re: upsidedownman] #242029
12/20/08 22:00
12/20/08 22:00
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
oh i didnt see that. how about you set it like this:

...
if(key_space && a == 2)
...



Ubi bene, ibi Patria.
Re: One time key push [Re: croman] #242030
12/20/08 22:19
12/20/08 22:19
Joined: Sep 2008
Posts: 69
U
upsidedownman Offline OP
Junior Member
upsidedownman  Offline OP
Junior Member
U

Joined: Sep 2008
Posts: 69
nope because a still has to be called back too 2 at some point and it ends up doing the same thing.

Re: One time key push [Re: upsidedownman] #242033
12/20/08 22:25
12/20/08 22:25
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
Code:
function test()
{
	while(a == 1)
	{
		g = 6;
		a = 0;
                
                if(!key_space)
                {                
                    continue_running = 1;
                }

		wait(1);
	}
}

function run_101()
{
	while(1)
	{
		if(key_space && continue_running)
		{
			a = 1;
                        continue_running = 0;
		}
		wait(1);
	}
}



this should work!



Ubi bene, ibi Patria.
Re: One time key push [Re: croman] #242036
12/20/08 22:46
12/20/08 22:46
Joined: Sep 2008
Posts: 69
U
upsidedownman Offline OP
Junior Member
upsidedownman  Offline OP
Junior Member
U

Joined: Sep 2008
Posts: 69
Tried that already didn't work. Thanks for trying to help thou.

Re: One time key push [Re: upsidedownman] #242038
12/20/08 22:51
12/20/08 22:51
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline
Serious User
croman  Offline
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
i think i get it now. as soon as you change a to 0 (a=0;) your while loop in first function stops working and you need to call that function (test();) again and a needs to be equal to 1 (a=1;)



Ubi bene, ibi Patria.
Re: One time key push [Re: upsidedownman] #242039
12/20/08 22:53
12/20/08 22:53
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
Code:
function run_101()
{
	var ab = 1;
	while(1)
	{
		if(key_space && ab)
		{
			a = 1;
			ab = 0;
		}
		if(!key_space){ab = 1;}
		wait(1);
	}
}



"empty"
Re: One time key push [Re: flits] #242040
12/20/08 23:05
12/20/08 23:05
Joined: Sep 2008
Posts: 69
U
upsidedownman Offline OP
Junior Member
upsidedownman  Offline OP
Junior Member
U

Joined: Sep 2008
Posts: 69
ehh nothing is working thanks for helping but im just going to give up. frown

Page 1 of 2 1 2

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