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 → lightswitch.cog
lightswitch.cog
2004-09-19, 5:11 PM #1
i got a cog off this website called lightswitch.cog - it works but i need more sector options to be in it because there are alot of sectors i need the cog to affect. im not good at cogging but i did the best i could in trying to add more to it. it works fine when you are the host but when you are the one joining the game only a few sectors are affected by the cog. Heres what it looks like with all the editing i did:

Code:
# Jedi Knight Cog Script
#
# Adjusts Sector extralight on activation of a switch
#
# 11/20/98 Nightmare edited by WAR_Nuker
# ========================================================================================

symbols

message     startup
message     activated

sound       poweroff=activate04.wav
sound       poweron=activate01.wav

surface     switch

flex        onlight=.75
flex        offlight=0

int         power			local

sector      sector00
sector      sector01
sector      sector02
sector      sector03
sector      sector04
sector      sector05
sector      sector06
sector      sector07
sector      sector08
sector      sector09
sector      sector10
sector      sector11
sector      sector12
sector      sector13
sector      sector14
sector      sector15
sector      sector16
sector      sector17
sector      sector18
sector      sector19
sector      sector20
sector      sector21
sector      sector22
sector      sector23
sector      sector24
sector      sector25
sector      sector26
sector      sector27
sector      sector28
sector      sector29
sector      sector30
sector      sector31
sector      sector32
sector      sector33
sector      sector34
sector      sector35
sector      sector36
sector      sector37
sector      sector38
sector      sector39
sector      sector40
sector      sector41
sector      sector42
sector      sector43
sector      sector44
sector      sector45
sector      sector46
sector      sector47
sector      sector48
sector      sector49
sector      sector50
sector      sector51
sector      sector52
sector      sector53
sector      sector54
sector      sector55
sector      sector56
sector      sector57
sector      sector58
sector      sector59
sector      sector60
sector      sector61
sector      sector62
sector      sector63
sector      sector64
sector      sector65
sector      sector66
sector      sector67
sector      sector68
sector      sector69
sector      sector70
sector      sector71
sector      sector72
sector      sector73
sector      sector74
sector      sector75
sector      sector76
sector      sector77
sector      sector78
sector      sector79
sector      sector80
sector      sector81
sector      sector82
sector      sector83
sector      sector84
sector      sector85
sector      sector86
sector      sector87
sector      sector88
sector      sector89
sector      sector90
sector      sector91
sector      sector92
sector      sector93
sector      sector94
sector      sector95
sector      sector96
sector      sector97
sector      sector98
sector      sector99
sector      sector100
sector      sector101
sector      sector102
sector      sector103
sector      sector104
sector      sector105
sector      sector106
sector      sector107
sector      sector108
sector      sector109
sector      sector110
sector      sector111
sector      sector112
sector      sector113
sector      sector114


end

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

code

startup:
   SetWallCel(switch,0);                     // set the switch to the on position

   power=1;

		SetSectorLight(sector00, onlight, 0);	// set all sector light
		SetSectorLight(sector01, onlight, 0);	// values to "on"
		SetSectorLight(sector02, onlight, 0);
		SetSectorLight(sector03, onlight, 0);
		SetSectorLight(sector04, onlight, 0);
		SetSectorLight(sector05, onlight, 0);
		SetSectorLight(sector06, onlight, 0);
		SetSectorLight(sector07, onlight, 0);
		SetSectorLight(sector08, onlight, 0);
		SetSectorLight(sector09, onlight, 0);
		SetSectorLight(sector10, onlight, 0);
		SetSectorLight(sector11, onlight, 0);
		SetSectorLight(sector12, onlight, 0);
		SetSectorLight(sector13, onlight, 0);
		SetSectorLight(sector14, onlight, 0);
		SetSectorLight(sector15, onlight, 0);
		SetSectorLight(sector16, onlight, 0);
		SetSectorLight(sector17, onlight, 0);
		SetSectorLight(sector18, onlight, 0);
		SetSectorLight(sector19, onlight, 0);
		SetSectorLight(sector20, onlight, 0);
		SetSectorLight(sector21, onlight, 0);
		SetSectorLight(sector22, onlight, 0);
		SetSectorLight(sector23, onlight, 0);
		SetSectorLight(sector24, onlight, 0);
		SetSectorLight(sector25, onlight, 0);
		SetSectorLight(sector26, onlight, 0);
		SetSectorLight(sector27, onlight, 0);
		SetSectorLight(sector28, onlight, 0);
		SetSectorLight(sector29, onlight, 0);
		SetSectorLight(sector30, onlight, 0);
		SetSectorLight(sector31, onlight, 0);
		SetSectorLight(sector32, onlight, 0);
		SetSectorLight(sector33, onlight, 0);
		SetSectorLight(sector34, onlight, 0);
		SetSectorLight(sector35, onlight, 0);
		SetSectorLight(sector36, onlight, 0);
		SetSectorLight(sector37, onlight, 0);
		SetSectorLight(sector38, onlight, 0);
		SetSectorLight(sector39, onlight, 0);
		SetSectorLight(sector40, onlight, 0);
		SetSectorLight(sector41, onlight, 0);
		SetSectorLight(sector42, onlight, 0);
		SetSectorLight(sector43, onlight, 0);
		SetSectorLight(sector44, onlight, 0);
		SetSectorLight(sector45, onlight, 0);
		SetSectorLight(sector46, onlight, 0);
		SetSectorLight(sector47, onlight, 0);
		SetSectorLight(sector48, onlight, 0);
		SetSectorLight(sector49, onlight, 0);
		SetSectorLight(sector50, onlight, 0);
		SetSectorLight(sector51, onlight, 0);
		SetSectorLight(sector52, onlight, 0);
		SetSectorLight(sector53, onlight, 0);
		SetSectorLight(sector54, onlight, 0);
		SetSectorLight(sector55, onlight, 0);
		SetSectorLight(sector56, onlight, 0);
		SetSectorLight(sector57, onlight, 0);
		SetSectorLight(sector58, onlight, 0);
		SetSectorLight(sector59, onlight, 0);
		SetSectorLight(sector60, onlight, 0);
		SetSectorLight(sector61, onlight, 0);
		SetSectorLight(sector62, onlight, 0);
		SetSectorLight(sector63, onlight, 0);
		SetSectorLight(sector64, onlight, 0);
		SetSectorLight(sector65, onlight, 0);
		SetSectorLight(sector66, onlight, 0);
		SetSectorLight(sector67, onlight, 0);
		SetSectorLight(sector68, onlight, 0);
		SetSectorLight(sector69, onlight, 0);
		SetSectorLight(sector70, onlight, 0);
		SetSectorLight(sector71, onlight, 0);
		SetSectorLight(sector72, onlight, 0);
		SetSectorLight(sector73, onlight, 0);
		SetSectorLight(sector74, onlight, 0);
		SetSectorLight(sector75, onlight, 0);
		SetSectorLight(sector76, onlight, 0);
		SetSectorLight(sector77, onlight, 0);
		SetSectorLight(sector78, onlight, 0);
		SetSectorLight(sector79, onlight, 0);
		SetSectorLight(sector80, onlight, 0);
		SetSectorLight(sector81, onlight, 0);
		SetSectorLight(sector82, onlight, 0);
		SetSectorLight(sector83, onlight, 0);
		SetSectorLight(sector84, onlight, 0);
		SetSectorLight(sector85, onlight, 0);
		SetSectorLight(sector86, onlight, 0);
		SetSectorLight(sector87, onlight, 0);
		SetSectorLight(sector88, onlight, 0);
		SetSectorLight(sector89, onlight, 0);
		SetSectorLight(sector90, onlight, 0);
		SetSectorLight(sector91, onlight, 0);
		SetSectorLight(sector92, onlight, 0);
		SetSectorLight(sector93, onlight, 0);
		SetSectorLight(sector94, onlight, 0);
		SetSectorLight(sector95, onlight, 0);
		SetSectorLight(sector96, onlight, 0);
		SetSectorLight(sector97, onlight, 0);
		SetSectorLight(sector98, onlight, 0);
		SetSectorLight(sector99, onlight, 0);
		SetSectorLight(sector100, onlight, 0);
		SetSectorLight(sector101, onlight, 0);
		SetSectorLight(sector102, onlight, 0);
		SetSectorLight(sector103, onlight, 0);
		SetSectorLight(sector104, onlight, 0);
		SetSectorLight(sector105, onlight, 0);
		SetSectorLight(sector106, onlight, 0);
		SetSectorLight(sector107, onlight, 0);
		SetSectorLight(sector108, onlight, 0);
		SetSectorLight(sector109, onlight, 0);
		SetSectorLight(sector110, onlight, 0);
		SetSectorLight(sector111, onlight, 0);
		SetSectorLight(sector112, onlight, 0);
		SetSectorLight(sector113, onlight, 0);
		SetSectorLight(sector114, onlight, 0);

   return;

activated:
	if(power == 0)
		{	
		SetWallCel(switch,0);	// do effects
		PlaySoundPos(poweron, SurfaceCenter(switch), 1.0, -1, -1, 0);

		SetSectorLight(sector00, onlight, 0);	// set all sector light
		SetSectorLight(sector01, onlight, 0);	// values to "on"
		SetSectorLight(sector02, onlight, 0);
		SetSectorLight(sector03, onlight, 0);
		SetSectorLight(sector04, onlight, 0);
		SetSectorLight(sector05, onlight, 0);
		SetSectorLight(sector06, onlight, 0);
		SetSectorLight(sector07, onlight, 0);
		SetSectorLight(sector08, onlight, 0);
		SetSectorLight(sector09, onlight, 0);
		SetSectorLight(sector10, onlight, 0);
		SetSectorLight(sector11, onlight, 0);
		SetSectorLight(sector12, onlight, 0);
		SetSectorLight(sector13, onlight, 0);
		SetSectorLight(sector14, onlight, 0);
		SetSectorLight(sector15, onlight, 0);
		SetSectorLight(sector16, onlight, 0);
		SetSectorLight(sector17, onlight, 0);
		SetSectorLight(sector18, onlight, 0);
		SetSectorLight(sector19, onlight, 0);
		SetSectorLight(sector20, onlight, 0);
		SetSectorLight(sector21, onlight, 0);
		SetSectorLight(sector22, onlight, 0);
		SetSectorLight(sector23, onlight, 0);
		SetSectorLight(sector24, onlight, 0);
		SetSectorLight(sector25, onlight, 0);
		SetSectorLight(sector26, onlight, 0);
		SetSectorLight(sector27, onlight, 0);
		SetSectorLight(sector28, onlight, 0);
		SetSectorLight(sector29, onlight, 0);
		SetSectorLight(sector30, onlight, 0);
		SetSectorLight(sector31, onlight, 0);
		SetSectorLight(sector32, onlight, 0);
		SetSectorLight(sector33, onlight, 0);
		SetSectorLight(sector34, onlight, 0);
		SetSectorLight(sector35, onlight, 0);
		SetSectorLight(sector36, onlight, 0);
		SetSectorLight(sector37, onlight, 0);
		SetSectorLight(sector38, onlight, 0);
		SetSectorLight(sector39, onlight, 0);
		SetSectorLight(sector40, onlight, 0);
		SetSectorLight(sector41, onlight, 0);
		SetSectorLight(sector42, onlight, 0);
		SetSectorLight(sector43, onlight, 0);
		SetSectorLight(sector44, onlight, 0);
		SetSectorLight(sector45, onlight, 0);
		SetSectorLight(sector46, onlight, 0);
		SetSectorLight(sector47, onlight, 0);
		SetSectorLight(sector48, onlight, 0);
		SetSectorLight(sector49, onlight, 0);
		SetSectorLight(sector50, onlight, 0);
		SetSectorLight(sector51, onlight, 0);
		SetSectorLight(sector52, onlight, 0);
		SetSectorLight(sector53, onlight, 0);
		SetSectorLight(sector54, onlight, 0);
		SetSectorLight(sector55, onlight, 0);
		SetSectorLight(sector56, onlight, 0);
		SetSectorLight(sector57, onlight, 0);
		SetSectorLight(sector58, onlight, 0);
		SetSectorLight(sector59, onlight, 0);
		SetSectorLight(sector60, onlight, 0);
		SetSectorLight(sector61, onlight, 0);
		SetSectorLight(sector62, onlight, 0);
		SetSectorLight(sector63, onlight, 0);
		SetSectorLight(sector64, onlight, 0);
		SetSectorLight(sector65, onlight, 0);
		SetSectorLight(sector66, onlight, 0);
		SetSectorLight(sector67, onlight, 0);
		SetSectorLight(sector68, onlight, 0);
		SetSectorLight(sector69, onlight, 0);
		SetSectorLight(sector70, onlight, 0);
		SetSectorLight(sector71, onlight, 0);
		SetSectorLight(sector72, onlight, 0);
		SetSectorLight(sector73, onlight, 0);
		SetSectorLight(sector74, onlight, 0);
		SetSectorLight(sector75, onlight, 0);
		SetSectorLight(sector76, onlight, 0);
		SetSectorLight(sector77, onlight, 0);
		SetSectorLight(sector78, onlight, 0);
		SetSectorLight(sector79, onlight, 0);
		SetSectorLight(sector80, onlight, 0);
		SetSectorLight(sector81, onlight, 0);
		SetSectorLight(sector82, onlight, 0);
		SetSectorLight(sector83, onlight, 0);
		SetSectorLight(sector84, onlight, 0);
		SetSectorLight(sector85, onlight, 0);
		SetSectorLight(sector86, onlight, 0);
		SetSectorLight(sector87, onlight, 0);
		SetSectorLight(sector88, onlight, 0);
		SetSectorLight(sector89, onlight, 0);
		SetSectorLight(sector90, onlight, 0);
		SetSectorLight(sector91, onlight, 0);
		SetSectorLight(sector92, onlight, 0);
		SetSectorLight(sector93, onlight, 0);
		SetSectorLight(sector94, onlight, 0);
		SetSectorLight(sector95, onlight, 0);
		SetSectorLight(sector96, onlight, 0);
		SetSectorLight(sector97, onlight, 0);
		SetSectorLight(sector98, onlight, 0);
		SetSectorLight(sector99, onlight, 0);
		SetSectorLight(sector100, onlight, 0);
		SetSectorLight(sector101, onlight, 0);
		SetSectorLight(sector102, onlight, 0);
		SetSectorLight(sector103, onlight, 0);
		SetSectorLight(sector104, onlight, 0);
		SetSectorLight(sector105, onlight, 0);
		SetSectorLight(sector106, onlight, 0);
		SetSectorLight(sector107, onlight, 0);
		SetSectorLight(sector108, onlight, 0);
		SetSectorLight(sector109, onlight, 0);
		SetSectorLight(sector110, onlight, 0);
		SetSectorLight(sector111, onlight, 0);
		SetSectorLight(sector112, onlight, 0);
		SetSectorLight(sector113, onlight, 0);
		SetSectorLight(sector114, onlight, 0);
		
		power = 1;
		return;
		}

	if(power == 1)
		{
		SetWallCel(switch,1);                     // do effects
		PlaySoundPos(poweroff, SurfaceCenter(switch), 1.0, -1, -1, 0);

		SetSectorLight(sector00, offlight, 0);	// set all sector lights to
		SetSectorLight(sector01, offlight, 0);	// the "off" value
		SetSectorLight(sector02, offlight, 0);
		SetSectorLight(sector03, offlight, 0);
		SetSectorLight(sector04, offlight, 0);
		SetSectorLight(sector05, offlight, 0);
		SetSectorLight(sector06, offlight, 0);
		SetSectorLight(sector07, offlight, 0);
		SetSectorLight(sector08, offlight, 0);
		SetSectorLight(sector09, offlight, 0);
		SetSectorLight(sector10, offlight, 0);
		SetSectorLight(sector11, offlight, 0);
		SetSectorLight(sector12, offlight, 0);
		SetSectorLight(sector13, offlight, 0);
		SetSectorLight(sector14, offlight, 0);
		SetSectorLight(sector15, offlight, 0);
		SetSectorLight(sector16, offlight, 0);
		SetSectorLight(sector17, offlight, 0);
		SetSectorLight(sector18, offlight, 0);
		SetSectorLight(sector19, offlight, 0);
		SetSectorLight(sector20, offlight, 0);
		SetSectorLight(sector21, offlight, 0);
		SetSectorLight(sector22, offlight, 0);
		SetSectorLight(sector23, offlight, 0);
		SetSectorLight(sector24, offlight, 0);
		SetSectorLight(sector25, offlight, 0);
		SetSectorLight(sector26, offlight, 0);
		SetSectorLight(sector27, offlight, 0);
		SetSectorLight(sector28, offlight, 0);
		SetSectorLight(sector29, offlight, 0);
		SetSectorLight(sector30, offlight, 0);
		SetSectorLight(sector31, offlight, 0);
		SetSectorLight(sector32, offlight, 0);
		SetSectorLight(sector33, offlight, 0);
		SetSectorLight(sector34, offlight, 0);
		SetSectorLight(sector35, offlight, 0);
		SetSectorLight(sector36, offlight, 0);
		SetSectorLight(sector37, offlight, 0);
		SetSectorLight(sector38, offlight, 0);
		SetSectorLight(sector39, offlight, 0);
		SetSectorLight(sector40, offlight, 0);
		SetSectorLight(sector41, offlight, 0);
		SetSectorLight(sector42, offlight, 0);
		SetSectorLight(sector43, offlight, 0);
		SetSectorLight(sector44, offlight, 0);
		SetSectorLight(sector45, offlight, 0);
		SetSectorLight(sector46, offlight, 0);
		SetSectorLight(sector47, offlight, 0);
		SetSectorLight(sector48, offlight, 0);
		SetSectorLight(sector49, offlight, 0);
		SetSectorLight(sector50, offlight, 0);
		SetSectorLight(sector51, offlight, 0);
		SetSectorLight(sector52, offlight, 0);
		SetSectorLight(sector53, offlight, 0);
		SetSectorLight(sector54, offlight, 0);
		SetSectorLight(sector55, offlight, 0);
		SetSectorLight(sector56, offlight, 0);
		SetSectorLight(sector57, offlight, 0);
		SetSectorLight(sector58, offlight, 0);
		SetSectorLight(sector59, offlight, 0);
		SetSectorLight(sector60, offlight, 0);
		SetSectorLight(sector61, offlight, 0);
		SetSectorLight(sector62, offlight, 0);
		SetSectorLight(sector63, offlight, 0);
		SetSectorLight(sector64, offlight, 0);
		SetSectorLight(sector65, offlight, 0);
		SetSectorLight(sector66, offlight, 0);
		SetSectorLight(sector67, offlight, 0);
		SetSectorLight(sector68, offlight, 0);
		SetSectorLight(sector69, offlight, 0);
		SetSectorLight(sector70, offlight, 0);
		SetSectorLight(sector71, offlight, 0);
		SetSectorLight(sector72, offlight, 0);
		SetSectorLight(sector73, offlight, 0);
		SetSectorLight(sector74, offlight, 0);
		SetSectorLight(sector75, offlight, 0);
		SetSectorLight(sector76, offlight, 0);
		SetSectorLight(sector77, offlight, 0);
		SetSectorLight(sector78, offlight, 0);
		SetSectorLight(sector79, offlight, 0);
		SetSectorLight(sector80, offlight, 0);
		SetSectorLight(sector81, offlight, 0);
		SetSectorLight(sector82, offlight, 0);
		SetSectorLight(sector83, offlight, 0);
		SetSectorLight(sector84, offlight, 0);
		SetSectorLight(sector85, offlight, 0);
		SetSectorLight(sector86, offlight, 0);
		SetSectorLight(sector87, offlight, 0);
		SetSectorLight(sector88, offlight, 0);
		SetSectorLight(sector89, offlight, 0);
		SetSectorLight(sector90, offlight, 0);
		SetSectorLight(sector91, offlight, 0);
		SetSectorLight(sector92, offlight, 0);
		SetSectorLight(sector93, offlight, 0);
		SetSectorLight(sector94, offlight, 0);
		SetSectorLight(sector95, offlight, 0);
		SetSectorLight(sector96, offlight, 0);
		SetSectorLight(sector97, offlight, 0);
		SetSectorLight(sector98, offlight, 0);
		SetSectorLight(sector99, offlight, 0);
		SetSectorLight(sector100, offlight, 0);
		SetSectorLight(sector101, offlight, 0);
		SetSectorLight(sector102, offlight, 0);
		SetSectorLight(sector103, offlight, 0);
		SetSectorLight(sector104, offlight, 0);
		SetSectorLight(sector105, offlight, 0);
		SetSectorLight(sector106, offlight, 0);
		SetSectorLight(sector107, offlight, 0);
		SetSectorLight(sector108, offlight, 0);
		SetSectorLight(sector109, offlight, 0);
		SetSectorLight(sector110, offlight, 0);
		SetSectorLight(sector111, offlight, 0);
		SetSectorLight(sector112, offlight, 0);
		SetSectorLight(sector113, offlight, 0);
		SetSectorLight(sector114, offlight, 0);
		
		power = 0;
		return;
		}

   return;

end

[Code tags, please...]


thats what it looks now that ive edited it. can someone help me so that this cog will work for everyone in a multiplayer game? thanks.
2004-09-19, 6:50 PM #2
Holy c4rp! That code could be one heckuvalot shorter!
I'll see what I can whip up for you. Might end up c/s.
May the mass times acceleration be with you.
2004-09-19, 7:55 PM #3
well first i tried usin the cog as it was when i downloaded it and just kept duplicating it a bunch of times over and over and kept assigning them to the same switch and i ended up with the problem with the person that joined the game didnt see all of the sectors turning off when the switch was activated. I figured making it one big cog with like 115 entries for sectors would fix that problem....but it did not. so i guess making it one big cog was kind of useless - since the same problem occured anyways. thanks again for your help man.
2004-09-19, 8:14 PM #4
Yep, turned into c/s (but really only because of the way it's set up ;)

Add the "server" side once, assign the variables. Add as many "clients" as you need to assign all those sectors. As long as the id variable in all the related cogs is the same, the server will toggle all sector lights in all the assigned sectors.

I tested this in Single player and it works fine (good thing too, because I made an error -- of course, I fixed it :) ). Hopefully it will work in MP (it should). You can even select whether to have the lights on or off at startup :)

Code:
# Jedi Knight Cog Script
#
# lightswitch_s.cog - Server side
#
# Adjusts Sector extralight on activation of a switch
#
# Set power to 1 to have lights on at startup; 0 to have them off.
#
# 11/20/98 Nightmare edited by WAR_Nuker and Darth Slaw
# ========================================================================================

symbols

message		startup
message		activated

int		id=0

surface		switch

sound		poweroff=activate04.wav
sound		poweron=activate01.wav

flex		onlight=0.75
flex		offlight=0.0

int		power=0

end

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

code

startup:
	Sleep(1);
	if(power == 1)
	{
		SendTrigger(-1, 2000 + id, 1, onlight, 0, 0); //lights on at startup - turn on lights
		SetWallCel(switch, 0);
	}
	else
	{
		SendTrigger(-1, 2000 + id, 0, offlight, 0, 0); //lights off at startup - turn off lights
		SetWallCel(switch, 1);
	}

return;

activated:
	if(power == 0)
	{
		power = 1;
		SetWallCel(switch, 0); // set the switch to the on position
		PlaySoundPos(poweron, SurfaceCenter(switch), 1.0, -1, -1, 0);
		SendTrigger(-1, 2000 + id, 1, onlight, 0, 0); //turn on lights
		return;
	}
	else
	{
		power = 0;
		SetWallCel(switch, 1); // set the switch to the off position
		PlaySoundPos(poweroff, SurfaceCenter(switch), 1.0, -1, -1, 0);
		SendTrigger(-1, 2000 + id, 0, offlight, 0, 0); //turn off lights
		return;
	}

return;

end


Code:
# Jedi Knight Cog Script
#
# lightswitch_c.cog - Client side
#
# Adjusts Sector extralight on activation of a switch
#
# Add as many instances of this cog that you need; all instances with the same id will
#  be affected by the server cog with the corresponding id.
# This doesn't have to be a c/s setup, but it allows large numbers of sectors to be
#  assigned to a single switch.
#
# 11/20/98 Nightmare edited by WAR_Nuker and Darth Slaw

flags=0x240

symbols

message		startup
message		trigger

int		id=0
int		i			local
int		used			local

flex		onlight			local
flex		offlight		local

sector		sector00
sector		sector01
sector		sector02
sector		sector03
sector		sector04
sector		sector05
sector		sector06
sector		sector07
sector		sector08
sector		sector09
sector		sector10
sector		sector11
sector		sector12
sector		sector13
sector		sector14
sector		sector15
sector		sector16
sector		sector17
sector		sector18
sector		sector19
sector		sector20
sector		sector21
sector		sector22
sector		sector23
sector		sector24
sector		sector25
sector		sector26
sector		sector27
sector		sector28
sector		sector29
sector		sector30
sector		sector31
sector		sector32
sector		sector33
sector		sector34
sector		sector35
sector		sector36
sector		sector37
sector		sector38
sector		sector39

end

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

code
startup:
	for(i = 0; i < 20 && sector00 != -1; i = i + 1);
	used = i;

return;
trigger:
	if(GetSourceRef() == id + 2000)
	{
		if(GetParam(0) == 1)
		{
			onlight = GetParam(1);
			call lights_on;
		}
		else
		{
			offlight = GetParam(1);
			call lights_off;
		}
	}

return;

lights_on:
	for(i = 0; i < used; i = i + 1)
		SetSectorLight(sector00, onlight, 0);  // set all sector light values to "on"

return;

lights_off:
	for(i = 0; i < used; i = i + 1)
		SetSectorLight(sector00, offlight, 0); // set all sector light values to "off"

return;
# ........................................................................................

end


This might even be Massassi Cog section worthy ;)
May the mass times acceleration be with you.
2004-09-20, 3:01 PM #5
Once again, Mr. Slaw, I am in your debt.
2004-09-20, 4:24 PM #6
I could be utterly losing my marbles here (more than likely, being around this place too much ;)) but wouldn't your client-side "startup" message run into difficulties with the "for" loop being terminated with a ";"? I'm also a little confused about where the choice of "i<20" comes from (the sector test comparison I have no quibble with), but it just struck me that the number of sectors setup in the symbols being 40 - surely it should be "i<40" so that the iteration loops through all sector00's array objects before determining how many sectors are used, otherwise you're only getting half the sectors (with the current loop implementation)?

Then again, it's late and I'll probably regret typing this message because I'll wake up tomorrow and grasp it instantly, but all the same - put an old man's mind at rest ;) :D

-Jackpot

PS: Where's the "old codger" smiley when you need one ;)
"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-09-20, 5:24 PM #7
yea only 20 of the sectors work....shouldnt be too hard for me to fix tho....right?......?
2004-09-20, 5:45 PM #8
I do believe you're right, jackpot.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2004-09-20, 6:18 PM #9
yup fixed it and tested on my network and works great. one minor glitch im willing to tolerate because its so.....minor. Say you are host and you set the cog so that the lights initially are on for example. you turn off the lights and THEN someone joins the game. that person still sees the lights are on. the light switch has to be activated twice so that they both see lights are on or off at the same time. i wonder if there would be a problem with this with three people. ie player 2 sees lights are off and when player 3 joins he sees lights are on (because the lights are set to be on initially). the question is will they see the lights the same after playing around with the switch? a thought but i highly doubt it.


also i notice that when you startup, the lights are breifly off and then are turned on after like half a second - also minor
2004-09-20, 8:07 PM #10
Yeah, sorry, that should be a 40 in the loop.
Forgot to update the for loop when I added 20 more sectors to the symbols section :o

As for the ';' after the for loops -- it shouldn't cause any problems (if for some very odd reason it does, replace it with "i = i;")

I have a tendency to put a sleep(1) in the startup if I'm not sure about jk locking up. That's why the sleep is there. If it doesn't cause any problems, by all means remove it.

Also, see if commenting out the flags=0x240 above the symbols fixes the joining bug (where late joiners don't get the updated info). I hadn't considered that issue when converting it to use triggers.

oh, and when the switch is activated at least once, everyone should be synced concerning the lights, cause the server cog sends the sector light value to set the sectors to thru the trigger -- thus, every client gets the trigger and sets the lights to the value sent by the trigger (which is the same for everyone since they all get the same trigger). But commenting out the 0x240 line should fix this glitch anyway.
Wow, talk about wordiness ;) ^^^
May the mass times acceleration be with you.
2004-09-21, 12:19 AM #11
To fix the join bug you could add a join message in the server cog that sends the trigger to the joiner...maybe something like this:
Code:
join:
	if(GetSenderRef() == GetLocalPlayerThing())
	{
		if(power)
			SendTrigger(-1, 2000 + id, 1, onlight, 0, 0); //turn on lights
		else
			SendTrigger(-1, 2000 + id, 0, offlight, 0, 0); //turn off lights
	}
	Return;

Of course, you also have to add the join message to the symbols section.
Try to remove the first if encapsulation if it doesn't work.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2004-09-21, 1:04 PM #12
Quote:
Originally posted by LKOH_SniperWolf:
I do believe you're right, jackpot.


Pfft - on occasions, the odd miracle does appear... just not as frequently as I'd wish for ;) - maybe I should try not sleeping when examining code ;) :D

-Jackpot
"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!