Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Timers
Timers
2001-10-29, 3:56 AM #1
Can more than one timer be set in a cog, and if you can, would you do it like:

Code:
message    timer
message    timer1
message    timer2


If thats not how you do it, pls show me [http://forums.massassi.net/html/biggrin.gif]

------------------
Generating Electro Vibes™ for the masses on Massassi
Go To: EL3CTROPROSE or DEEPMATRIX or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
<EL3CTRO> EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!
Generating Electro Vibes™ for the masses on Massassi
Go To: BiTsToRm Forums or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
&lt;EL3CTRO&gt; EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!
2001-10-29, 4:23 AM #2
Heck no, you would use SettimerEX.




------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-10-29, 6:33 AM #3
could someone demonstrate how to use them? like make a cog that will create 2 things at differnt intervals using 2 timers?
Generating Electro Vibes™ for the masses on Massassi
Go To: BiTsToRm Forums or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
&lt;EL3CTRO&gt; EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!
2001-10-29, 7:37 AM #4
look at kyle.cog and see what they did with it there... if that's too complicated, try looking at 00_twoonebee.cog. Both use SetTimerEx() and multiple timers.
2001-10-29, 10:03 AM #5
You only get one timer message, but you can run as many timers in that message as you want. Just use: SetTimerEx(delay, id, param, param1);

SetTimerEx() sets a timer with an ID number and two variables. They are retrieved in the timer message like this:

Code:
timer:
   if(GetSenderID() == 20)
   {
      var=GetParam(0);
      var2=GetParam(1);
   }
   else if(GetSenderID() == 30)
   {
      etc...


GetSenderID() returns the ID of the timer, and the two variables are retrieved with GetParam(number of param).

Hope that helps. [http://forums.massassi.net/html/wink.gif]




------------------
Thank you for sending me a copy of your book - I'll waste no time reading it.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2001-10-29, 1:42 PM #6
Ok, i made this, is it correct? because it doesnt work in-game [http://forums.massassi.net/html/frown.gif]

Code:
# [E3 - 29/10/2001]
# 

flags=0x240

symbols

template	rainsprite
thing		ghost0
thing		ghost1
thing		ghost2
thing		ghost3
thing		ghost4
thing		ghost5
thing		ghost6
thing		ghost7
thing		ghost8
thing		ghost9

message 	startup
message		timer


end

# ========================================================================================

code

startup:

SetTimerEx(Rand(), 1);
SetTimerEx(Rand(), 2);
SetTimerEx(Rand(), 3);
SetTimerEx(Rand(), 4);
SetTimerEx(Rand(), 5);
SetTimerEx(Rand(), 6);
SetTimerEx(Rand(), 7);
SetTimerEx(Rand(), 8);
SetTimerEx(Rand(), 9);
SetTimerEx(Rand(), 10);

Return;

# ........................................................................................

timer:

if(GetSenderID() == 1)
   {
	CreateThing(rainsprite, ghost0);
   }
   else
   if(GetSenderID() == 2)
   {
	CreateThing(rainsprite, ghost1);
   }
   else
   if(GetSenderID() == 3)
   {
	CreateThing(rainsprite, ghost2);
   }
   else
   if(GetSenderID() == 4)
   {
	CreateThing(rainsprite, ghost3);
   }
   else
   if(GetSenderID() == 5)
   {
	CreateThing(rainsprite, ghost4);
   }
   else
   if(GetSenderID() == 6)
   {
	CreateThing(rainsprite, ghost5);
   }
   else
   if(GetSenderID() == 7)
   {
	CreateThing(rainsprite, ghost6);
   }
   else
   if(GetSenderID() == 8)
   {
	CreateThing(rainsprite, ghost7);
   }
   else
   if(GetSenderID() == 9)
   {
	CreateThing(rainsprite, ghost8);
   }
   else
   if(GetSenderID() == 10)
   {
	CreateThing(rainsprite, ghost9);
   }

Return;

# ........................................................................................

end


------------------
Generating Electro Vibes™ for the masses on Massassi
Go To: EL3CTROPROSE or DEEPMATRIX or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
<EL3CTRO> EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!
Generating Electro Vibes™ for the masses on Massassi
Go To: BiTsToRm Forums or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
&lt;EL3CTRO&gt; EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!
2001-10-29, 1:54 PM #7
SetTimerEx() needs 4 parameters (even though you only use 2)... just use 0's for the last two parameters and it should work... you could also clean up the code by using an array instead of all the if...else statements, but that's just me (I like clean code heh).
2001-10-29, 2:06 PM #8
Who doesnt like clean code? A FOR loop would cut that cog's size by 80%.

------------------
Success is the inverse relationship between effort, gain, and loss.

[This message has been edited by GBK (edited October 29, 2001).]
And when the moment is right, I'm gonna fly a kite.
2001-10-30, 2:27 AM #9
Ok, it works now, thanks
Generating Electro Vibes™ for the masses on Massassi
Go To: BiTsToRm Forums or L3CY's Topsites
Boba Jules: You ever read the bible TK-421?
TK-421: No?
Boba Jules: Oh, ok...
*BLAM BLAM BLAM BLAM*
&lt;EL3CTRO&gt; EXCAUSE ME MISTAR CAERV BUT I LIEK MY PHORUMPHS!

↑ Up to the top!