Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, TedMar), 1,031 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to make a timer #416917
02/05/13 21:34
02/05/13 21:34
Joined: Jan 2013
Posts: 41
Redoine Offline OP
Newbie
Redoine  Offline OP
Newbie

Joined: Jan 2013
Posts: 41
Hello good guys

1) i need a code of a timer
i mean a code that execut a function or action evry second , 2s or anytime u want

2) and also i need to know how to enable and disable a function

3) and i'm looking for a pack of lite c code snippets (no AUMs please)

and if someone could make a lite c code library that will be great (like VB.net code library)

Thank you very much

Last edited by Redoine; 02/05/13 21:40.
Re: How to make a timer [Re: Redoine] #416920
02/05/13 21:41
02/05/13 21:41
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
1. + 2.
Code:
var enabled = 1;
void my_special_timer_function()
{
    while (1)
    {
        while (!enabled)
            wait(1);
        while (enabled)
        {
            // Do whatever you want to do every second...
            wait(-1)
        }
    }
}



Always learn from history, to be sure you make the same mistakes again...
Re: How to make a timer [Re: Uhrwerk] #416922
02/05/13 22:03
02/05/13 22:03
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: How to make a timer [Re: Uhrwerk] #416923
02/05/13 22:03
02/05/13 22:03
Joined: Jan 2013
Posts: 24
M
milaz Offline
Newbie
milaz  Offline
Newbie
M

Joined: Jan 2013
Posts: 24
Originally Posted By: Uhrwerk
1. + 2.
Code:
var enabled = 1;
void my_special_timer_function()
{
    while (1)
    {
        while (!enabled)
            wait(1);
        while (enabled)
        {
            // Do whatever you want to do every second...
            wait(-1)
        }
    }
}



you forgot "wait(1);" for the first while...

Re: How to make a timer [Re: Uhrwerk] #416924
02/05/13 22:12
02/05/13 22:12
Joined: Jan 2013
Posts: 41
Redoine Offline OP
Newbie
Redoine  Offline OP
Newbie

Joined: Jan 2013
Posts: 41
Thank you

Re: How to make a timer [Re: Redoine] #416925
02/05/13 22:15
02/05/13 22:15
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
@milaz: I don't get it, sorry. Where is that wait(1) required?


Always learn from history, to be sure you make the same mistakes again...
Re: How to make a timer [Re: Uhrwerk] #416926
02/05/13 22:20
02/05/13 22:20
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
@milaz: while, for and if don't require the { } braces when there is only one instruction that should be included in the according case.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

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