Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (AbrahamR), 717 guests, and 4 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
how do I tell the program to use a function only every second #415509
01/19/13 18:47
01/19/13 18:47
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
Hi,

I want to save the postition of the player every second of the game into a txt file. This works when I use the function save(); in my main while(1) loop.

But it saves the postition every 20th or so of a second - much to much data for me.

How can I say "use save(); only every 1/2 sec"?

Thx in advance!

Re: how do I tell the program to use a function only every second [Re: elevationmind] #415513
01/19/13 19:09
01/19/13 19:09
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
By using wait with negative values.
Code:
wait(-10); // waits 10 seconds


http://www.conitec.net/beta/acrt-wait.htm


Always learn from history, to be sure you make the same mistakes again...
Re: how do I tell the program to use a function only every second [Re: Uhrwerk] #415515
01/19/13 19:13
01/19/13 19:13
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
I know and tried that, but it doesn't help me because I don't want the program to wait ten seconds - I want something to happen every x seconds. How do I do that?

Re: how do I tell the program to use a function only every second [Re: elevationmind] #415526
01/19/13 20:55
01/19/13 20:55
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
while(1)
{
error("dafuq, why does this even work?");
wait(-1);
}


Visit my site: www.masterq32.de
Re: how do I tell the program to use a function only every second [Re: MasterQ32] #415532
01/19/13 21:41
01/19/13 21:41
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Maybe you want to run a save-loop run in a seperate function:

Code:
void SaveLoop(var wait_time)
{
	while(1)
	{
		save();
		wait(-wait_time);
	}
}



f.e. call SaveLoop(2); once and save(); gets called every 2 seconds without affecting the rest of your code.


POTATO-MAN saves the day! - Random
Re: how do I tell the program to use a function only every second [Re: elevationmind] #415541
01/20/13 00:57
01/20/13 00:57
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: elevationmind
I know and tried that, but it doesn't help me because I don't want the program to wait ten seconds - I want something to happen every x seconds. How do I do that?

Do the tutorials. Seriously. http://tutorial.3dgamestudio.net/


Always learn from history, to be sure you make the same mistakes again...
Re: how do I tell the program to use a function only every second [Re: Kartoffel] #415548
01/20/13 11:20
01/20/13 11:20
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
Originally Posted By: Kartoffel
Maybe you want to run a save-loop run in a seperate function:

Code:
void SaveLoop(var wait_time)
{
	while(1)
	{
		save();
		wait(-wait_time);
	}
}



f.e. call SaveLoop(2); once and save(); gets called every 2 seconds without affecting the rest of your code.


Thank you very much! I tryed something simmilar, but my mistake was to call the function in my while(1) - so it was called every few miliseconds. But now I moved it to main and it does exactly what it should! Thanks again!

Re: how do I tell the program to use a function only every second [Re: Uhrwerk] #415549
01/20/13 11:24
01/20/13 11:24
Joined: Nov 2012
Posts: 18
Germany
E
elevationmind Offline OP
Newbie
elevationmind  Offline OP
Newbie
E

Joined: Nov 2012
Posts: 18
Germany
Originally Posted By: Uhrwerk
Originally Posted By: elevationmind
I know and tried that, but it doesn't help me because I don't want the program to wait ten seconds - I want something to happen every x seconds. How do I do that?

Do the tutorials. Seriously. http://tutorial.3dgamestudio.net/


So I did, but failed to find there anything that would help me. Could you direct me to the part of the information I might have missed that would have helped?

Re: how do I tell the program to use a function only every second [Re: elevationmind] #415572
01/20/13 15:02
01/20/13 15:02
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
I think Workshop 10 - Entities is the best one for this. Workshop 2 and 3 are also related to the issue.


Always learn from history, to be sure you make the same mistakes again...

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