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 → i'm in need of a cog . . .
i'm in need of a cog . . .
2001-04-25, 2:41 PM #1
I'm rather new to editing, and it seems that my worst area is involving cogs. Anyway, I was wondering if someone could make me a cog that makes a series of lights show up in various places in my level once a switched in pulled. Could someone please help me?
2001-04-26, 6:58 AM #2
Since your a newbie like me, I'll give you the whole code:
Code:
# Put description here...
#
#
//If this is MP, put in 'flags=0x240'.
symbols
message activated
message deactivated
surface switch linkid=-1 //i dunno if the linkid goes there...
thing light1 local
thing light2 local
flex lighton insert = and a number here
flex lightoff insert = and a number here
end
#-------------------------------------------
code
activated:
SetThingLight(light1,lighton);
SetThingLight(light2,lighton);
deactivated:
SetThingLight(light1,lightoff);
SetThingLight(light2,lightoff);
end

You have to define the two things and the surface and the light amount if you don't add =# after lighton and off. Tell me if ya need it changed a bit. This would make two lights come on with the same light amount that you entered.
Oh, and get cogwriter in case i have any syntax errors.




[This message has been edited by scott_karana (edited April 26, 2001).]
Hey, I'm here! But who cares?
2001-04-26, 7:41 AM #3
I believe theres a cog already in the archives of this site for something like that. Might check there, but Im sure the cog above will work out fine.
"Flash like daybreak to the fray"
Raccoonking: Deeznuts are tasty!http://www.geocities.com/joshroxby/
2001-04-26, 10:00 AM #4
Thanks alot! [http://forums.massassi.net/html/smile.gif]
2001-04-26, 3:41 PM #5
You need a "return;" statement after the activated section, otherwise the cog will process the deactivated statements immediately after the activated ones. The deactivated message is triggered when you finish activating (you release the space bar) so you need a different section in the activated message part instead. Remove the "local" after the light things otherwise you can't enter the thing numbers in JED.

If there's a chance that the player can "activate" the light things by touching them besides just the switch then you'll need to check for the linkid of the switch.

I modified Scott's code and also added the function of changing the switch cell mat on and off, and added sounds. I haven't tested this. I'm assuming that the SetThingLight function is what you want. Otherwise you might want to find out how to use those tricky dynamic lights (which I haven't learned yet). If there's a problem you can e-mail me.

Code:
# Jedi Knight Cog Script
# ThingLightSwitch.cog
# This script changes the light of 1 to 3 things by a switch.
#
#//If this is MP, put in 'flags=0x240'

symbols
message startup
message activated
surface switch linkid=1
thing light1
thing light2
thing light3  //add more lines for more light things
flex lighton=1.0 //insert number here
flex lightoff=0.0 // insert number here
sound OnSound=activate02.wav
sound OffSound=deactivate02.wav
end

#-------------------------------------------
code

startup:
   sleep(1.0) //let system warm up
   SetWallCel(switch,0);
   SetThingLight(light1,lightoff);
   SetThingLight(light2,lightoff);
   return;

activated:
if (GetSenderID() != 1) return; //not switch
if (GetWallCel(switch) == 0) // turn lights on
{
   SetWallCel(switch,1);
   PlaySoundPos(OnSound, GetSurfaceCenter(switch), 1.0, 1, 10, 0x80);
   SetThingLight(light1,lighton);
   if (light2) SetThingLight(light2,lighton);
   if (light3) SetThingLight(light3,lighton);  //add more lines for more lights
   return;
}
else if (GetWallCel(switch) == 1) // turn lights off
{
   SetWallCel(switch,0);
   PlaySoundPos(OffSound, GetSurfaceCenter(switch), 1.0, 1, 10, 0x80);
   SetThingLight(light1,lightoff);
   if (light2) SetThingLight(light2,lightoff);
   if (light3) SetThingLight(light3,lightoff);  //add more lines for more lights
   return;
}
return;

end


------------------
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton
Sylvicolus JK homepage
If I have ever made any valuable discoveries, it has been owing more to
patient observation than to any other reason. -Isaac Newton

↑ Up to the top!