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 → Why does it print at the wrong time?
Why does it print at the wrong time?
2003-09-14, 9:55 AM #1
Hi!
This COG, when lever activated, releases endless grenades, until lever is pressed again.
Code:
# Grenades at Jump challange!
#
# By Edward

symbols

message		activated
message		pulse

surface		lever

sound		announce

thing		place0
thing		place1
thing		place2
thing		place3
thing		place4
thing		place5
thing		place6
thing		place7
thing		place8
thing		place9
thing		place10
thing		place11
thing		place12
thing		place13
thing		place14
thing		place15

template	grenades

int		i=0	local
int		z=0	local
int		go=0	local

end
#
code
activated:
	If(GetSenderRef()!=lever) return;
	if(go==0) {
		PlaySoundGlobal(announce,1,0,0xC0);
		Print("A challange is being thrown at the oily bronze corse.");
		SetPulse(0.16);
		SetWallCel(lever,1);
		go=1;
		sleep(5);
		print("Can you jump through 16 grenades/0.01 seconds?");
	} else {
		print("Grenades have stopped...");
		SetPulse(0);
		SetWallCel(lever,0);
		go=0; }
return;
pulse:
	for(i=0; i<16; i=i+1) {
		CreateThing(grenades,place0);
		sleep(0.01); }
return;
end

The problem is that when I "deactivate" the lever, it says "Grenades have stopped..." and then a little while after it says "Can you jump through 16 grenades/0.01 seconds?", and it doesn't say "Can you..." after I activate the lever. Help!

/Edward
Edward's Cognative Hazards
2003-09-14, 11:48 AM #2
try this and see if it fixes it.
Code:
//-When you set the pulse do this...
i = 0;
SetPulse(0.01);
#----------
//-Make the pulse message like this...
pulse:
     CreateThing(grenades, place0);
     i = i + 1;
     if(i > 15) i = 0;
return;


------------------
Famous last words - "It seemed like a good idea at the time."
Famous last words - "It seemed like a good idea at the time."
2003-09-14, 12:22 PM #3
Yeah, do what DeathSythe suggested for the pulse, and use an IDed timer instead of the five-second sleep. That way, you won't have any thread problems, and you'll be able to use KillTimerEx() to stop the message from printing if the surface is activated again before the five seconds are up.

------------------
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2003-09-15, 3:56 AM #4
Thank you! All is OK!

/Edward
Edward's Cognative Hazards

↑ Up to the top!