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 → Sleep, curse you! Sleep!
Sleep, curse you! Sleep!
2004-06-27, 7:50 AM #1
More COG problems. In this case, Jedi Knight refuses to sleep when I tell it to.

You activate Ug, and he displays a few lines of text and adds a new mission objective.

You go to the train station, and talk to the teller. He tells you to buzz off and various levels (depending on how many times you bug him). However, Jedi Knight refuses to recognize any of my Sleep(); verbs. It simply runs through all of the appropriate displays of text and playing of sounds. Why?

Code:
# Jedi Knight Cog Script
#
# UgTicket.cog
#
# Description
# 
#
# This Cog is Not supported by LucasArts Entertainment Co

symbols

message	activated
message	startup
message	entered
message	cyccam

thing		Ug
thing		scalper
thing		scalpcam

sector	sectcr

thing		ticketseller

sound		soundGoal=accomplish1.wav				local
sound		newGoal=activate01.wav					local
sound		traintalk1
sound		traintalk2
sound		traintalk3
sound		traintalk4

int		TicketTalk=0						local
int		TicketBuy=0							local
int		Sleep=0							local
int		Bother=0							local
int		entcred=0							local
int		ScalpTalk=0							local

end

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

code

startup:
  player = GetLocalPlayerThing();
  return;

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

activated:
  if ((GetSenderRef()==Ug) && (TicketTalk==0)) {
	StopThing(player);
	SetActorFlags(player, 0xa00000);
	JKPrintUNIString(player, 10113);
	Sleep(3.0);
	JKPrintUNIString(player, 10114);
	Sleep(3.0);
	JKPrintUNIString(player, 10115);
	JKPrintUNIString(player, 1020);
	PlaySoundLocal(newGoal, 1.0, 0.0, 0x0);
	SetGoalFlags(player, 10, 1);
	SetGoalFlags(player, 11, 1);
	ClearActorFlags(player, 0xa00000);
	TicketTalk=1;
	}

  if ((GetSenderRef()==Ug) && (TicketTalk==1) && (TicketBuy==0) && (Sleep==0)) {
	Sleep=1;
	JKPrintUNIString(player, 10116);
	Sleep(3.0);
	Sleep=0;
	}

  if ((GetSenderRef()==Ug) && (TicketTalk==1) && (TicketBuy==1)) {
	JKPrintUNIString(player, 10127);
	jkPrintUNIString(player, 350);
	PlaySoundThing(soundGoal, player, 1.0, -1, -1, 0);
	SetGoalFlags(player, 11, 2);
	}

  if((GetSenderRef()==ticketseller) && (Bother==0)) {
	Bother=500;
	JKPrintUNIString(player, 10117);
	PlaySoundThing(traintalk1, ticketseller, 1, -1, -1, 0x0);
	Sleep(13.0);
	Bother=1;
	}

  if((GetSenderRef()==ticketseller) && (Bother==1)) {
	Bother=500;
	JKPrintUNIString(player, 10118);
	PlaySoundThing(traintalk2, ticketseller, 1, -1, -1, 0x0);
	Sleep(3.0);
	Bother=2;
	}

  if((GetSenderRef()==ticketseller) && (Bother==2)) {
	Bother=500;
	JKPrintUNIString(player, 10119);
	PlaySoundThing(traintalk3, ticketseller, 1, -1, -1, 0x0);
	Sleep(3.0);
	Bother=3;
	}

  if((GetSenderRef()==ticketseller) && (Bother==3)) {
	Bother=500;
	JKPrintUNIString(player, 10120);
	PlaySoundThing(traintalk4, ticketseller, 1, -1, -1, 0x0);
	}

  if((GetSenderRef()==scalper) && (ScalpTalk==0)) {
	ScalpTalk=500;
	setcamerafocus(0, scalpcam);
	JKPrintUNIString(player, 10123);
	Sleep(3.0);
	TicketBuy=1;
	jkPrintUNIString(player, 350);
	PlaySoundThing(soundGoal, player, 1.0, -1, -1, 0);
	ScalpTalk=1;
	}

  return;

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

cyccam:
    if((GetCurrentCamera() != 0)) {
	CycleCamera();
	}
return;

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

end


------------------
<ubuu> does hitler have a last name?
<jipe> .. yes, Ubuu, we're racist commy nazi jews, and we hate male pattern baldness
<Professor`K> Sorry, but half-way through your logic, my head exploded
the idiot is the person who follows the idiot and your not following me your insulting me your following the path of a idiot so that makes you the idiot - LC Tusken
2004-06-27, 9:05 AM #2
Don't use sleep(). I don't know how many times I've heard someone say "don't use sleep()" but I don't know WHY.

JediKirby

------------------
-Proud Leader of the Minnessassian Council
<]-[ellequin> Nothing is quite as satisfying as placing a .177 lead pellet in between the eyes of a cat.
<]-[ellequin> I think I will leave it's corpse there, to warn all the other cats to keep out of my hibiscus patch

Live on, Adam.
ᵗʰᵉᵇˢᵍ๒ᵍᵐᵃᶥᶫ∙ᶜᵒᵐ
ᴸᶥᵛᵉ ᴼᵑ ᴬᵈᵃᵐ
2004-06-27, 11:55 AM #3
Could be that you have a value called sleep... Anyway, if all else fails, use timer...
Edward's Cognative Hazards
2004-06-27, 1:10 PM #4
Ya, having a variable named the same as a function will screw up the cog. Always think of creative names like 'delay'

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2004-06-27, 2:55 PM #5
Quote:
<font face="Verdana, Arial" size="2">Originally posted by SG-fan:
Ya, having a variable named the same as a function will screw up the cog. Always think of creative names like 'delay'

</font>


What he said. You can't have any symbols that have the same name as a verb and/or message.

------------------
Major projects working on:
SATNRT
JK Pistol Mod
Aliens TC
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2004-06-27, 11:31 PM #6
Yep, that'll be the cause (using JK's reserved word list as a variable name) alright [http://forums.massassi.net/html/wink.gif] [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX
"jackpot is an evil evil man... so evil, in fact, that he's awesome." - Seb

"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-06-28, 1:10 AM #7
Quote:
<font face="Verdana, Arial" size="2">Originally posted by jEDIkIRBY:
Don't use sleep(). I don't know how many times I've heard someone say "don't use sleep()" but I don't know WHY.

JediKirby

</font>


Yea, i mean everyone told me when i was makeing my AJTD cutseen cogs that i shouldent use sleep.. but as far as i can tell sleep is a bugless command... so why not use it?

------------------
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
I am Darth PJB!
well, go on, run away!

i have a plastic lightsaber and a jedi cape.. am i a nerd?

If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
2004-06-28, 2:40 AM #8
I think most of the problems with sleep() occur when you use it in a loop or section of cog that can be re-entered before the sleep timeout completes.

In those instances it seems like the Sleep time accumulates and makes the cog completely non-responsive.

------------------
- Wisdom is 99% experience, 1% knowledge. -
- Wisdom is 99% experience, 1% knowledge. -
2004-06-28, 3:35 AM #9
Sleep() is ok to use IF and ONLY IF you make sure that the cog can NOT be reactivated while the sleep is still running.

Tis best to simply use timers, since they don't have that problem. However, as long as you prevent a double activation of the cog, there is no problem with sleep().

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

↑ Up to the top!