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 → When time=10, and... still not...
When time=10, and... still not...
2004-03-28, 6:03 AM #1
Hi!
Code:
symbols

...

int    time=0    local

...
end
code
...
fire:
...
     time=0;
...
pulse:
	time=time+1;
	printint(time);
	if(time==10)
	{
		jkPlayPOVKey(player,povboredAnim0[rand()*2],1,0x38);
		time=rand()*8;
	}
return;

Now, I'm making here a thing where when idle/hasn't shot for more than 10 seconds, the Pov hands start to do stuff... Now, after the 10 seconds, the hands move. After a few more seconds, I expect hands to move. 8, 9, 10, 11, 12... Nothing! It seems like if the IF(time==10) was made to run only once! WHY? HELP! But, after firing and waiting another 10 seconds, they move! What's the problem?

/Edward
Edward's Cognative Hazards
2004-03-28, 6:48 AM #2
Simply put, the problem lies in your choice of implementation - don't use "pulse" messages for this type of situation [http://forums.massassi.net/html/smile.gif]

Use of the "timer" message with the SetTimer() / SetTimerEx() verbs (and parameters) would probably be a better bet - that way you can still keep your "time" variable (and increment/decrement as applicable) and retrieve the timer "ID" with the "GetSenderID()" verb (only for "SetTimerEx()").

Hope this information puts you back on track [http://forums.massassi.net/html/biggrin.gif]. After all, "time is of the essence"...
*runs away from the mountains of incoming rotten fruit and veg...* (or is that too healthy for your standard Massassian [http://forums.massassi.net/html/wink.gif])

Hope this helps [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

Also, as a side note, the code snippet you've provided isn't much use (from a debugging perspective) because you haven't told us where your "SetPulse()" verb is, nor the number you've provided as a parameter... [http://forums.massassi.net/html/redface.gif] [http://forums.massassi.net/html/wink.gif]

------------------
"lucky_jackpot is the smily god..." - gothicX

"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2004-03-28, 7:17 AM #3
SetPulse(1); in selected:
SetPulse(0); in deselected:
And, I wonder, can I kill the timer? Last I used a timer where there was another timer, I used a series of test like:
fire:
playkey();
gren=1;
settimer(GetkeyLen()/2);
...
timer:
if(gren==1)
{
DoThis();
}
else
{
StopKey(holsterTrack);
}

I don't know what I have against complex verbs... Well, complex, they are all easy, but I'm... I don't know... I'll try the Ex in Timer.

/Edward
Edward's Cognative Hazards
2004-03-28, 12:09 PM #4
KillTimerEx() verb is used to kill a timer (if you need to).

Scenarios:
--> "SetTimer()" = solely one timer message in your cog script. There's no need for the "extended" functionality that SetTimerEx() has, if there's only ever one "timer" message that is going to be needed by the cog.

--> "SetTimerEx()" = for use with multiple timers. The second parameter for this verb is an individual ID for a timer, so you can have multiple timers running something like this (cue pseudo-code):

Code:
symbols
int check=5
int pauseDelay=10
flex timerID_1=100.5
flex timerID_2=200.2
end
#
#
code:

startup:
    if (check > 5) {
        SetTimerEx (pauseDelay, timerID_1, -1, -1);
        SetTimerEx (pauseDelay, timerID_1+5, -1, -1);
    }
    else
    if (check < 5) {
        SetTimerEx (pauseDelay + 3, timerID_2, -1, -1);
    }
    Return;
#
timer:
    if (GetSenderID() == timerID_1) {
        PrintFlex (timerID_1);
    }
    else
    if (GetSenderID() == timerID_1+5) {
        Print ("second timer");
        PrintFlex (timerID_1+5);
    }
    else
    if (GetSenderID() == timerID_2) {
        PrintFlex (timerID_2);
    }
    Return;
end


The point of this being to show how you can have several timers running (some at the same time) but also the way in which you can distinguish between the different threads (of execution) [http://forums.massassi.net/html/smile.gif]

Hope this helps [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

If only Java threads and Observer/Observable interfaces were as simple as COG's way of dealing with program flow and threads [http://forums.massassi.net/html/rolleyes.gif]...

------------------
"lucky_jackpot is the smily god..." - gothicX

"Life is mostly froth and bubble,
But two things stand in stone,
Kindness in another's trouble,
Courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||

↑ Up to the top!