SphereCommunity
How to turn all light sources ON/OFF - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: How to turn all light sources ON/OFF (/Thread-How-to-turn-all-light-sources-ON-OFF)



How to turn all light sources ON/OFF - Extreme - 06-23-2013 02:38 PM

Hey guys, I need another idea...
I'm trying to turn all light sources on and off, but I think the only way to turn on/off is dclicking (DCLICK) it or using (USE)...

So I made this code, should works fine but sometimes it don't turn on all types I set to do.

PHP Code:
[DEFNAME LIGHTTYPES]
LIGHT.1 I_TORCH_WALL
LIGHT.2 I_TORCH_WALL2
LIGHT.3 I_CANDELABRA
LIGHT.4 I_CANDELABRA2

[FUNCTION TURNLIGHTS]
SERV.NEWNPC C_ZOMBIE
REF1 
<NEW>
REF1.FLAGS STATF_INVISIBLE
FOR I 1 4
 serv
.<DEF.LIGHT.<dLOCAL.I>><QVAL <ARGS>==1?:_LIT>
 
FORINSTANCES <DEF.LIGHT.<dLOCAL.I>><QVAL <ARGS>==1?:_LIT>
  IF !<
CONT>
   
REF1.<P>
   
MOREY 20
   REF1
.DCLICK <UID>
  ENDIF
 ENDFOR
ENDFOR
REF1.REMOVE
RETURN 

How to use: .turnlights 0 to turn all lights off, or 1 to turn on.

Any idea how to improve it?

Thanks


RE: How to turn all light sources ON/OFF - Mordaunt - 06-23-2013 09:26 PM

I did something like this about 5 years ago as a plugin for another script, I wouldn't think it's the most efficient way now either but...

Streetlight Manager


RE: How to turn all light sources ON/OFF - Extreme - 06-25-2013 12:41 AM

Thanks Mordaunt!
But it didn't work perfectly too...

I don't understand why my code isn't running okay.
All itemdefs should turn lights on/off when used the command, but is most cases, some don't lights on/off.

Still searching a solution !


RE: How to turn all light sources ON/OFF - RanXerox - 06-25-2013 01:34 AM

Maybe it is something to do with the underground region flag?


RE: How to turn all light sources ON/OFF - Extreme - 06-25-2013 01:51 AM

(06-25-2013 01:34 AM)RanXerox Wrote:  Maybe it is something to do with the underground region flag?

Absolutely not.
Those items are near to test in a house inside the city with flags nobuilding and guarded.

Some turn lights on, others aren't checked by forinstances.

I'm sure its problem with forinstances!

PHP Code:
FORINSTANCES I_TORCH_WALL
 SAY hi
ENDFOR 

Some torch walls (I_TORCH_WALL) don't say 'hi' and the ones that say 'hi' works.
Just don't understand, but the problem is in forinstances!


RE: How to turn all light sources ON/OFF - darksun84 - 06-25-2013 02:29 AM

i tried with 500 i_torch_wall and foristances worked fine Shock


RE: How to turn all light sources ON/OFF - Ben - 06-25-2013 02:46 AM

<QVAL <ARGS>==1?:_LIT> is probably the problem... because of the premature closing.
Need to find another way to deal with it.

[EDIT]
NVM... There's nothing wrong there


RE: How to turn all light sources ON/OFF - Extreme - 06-25-2013 02:48 AM

(06-25-2013 02:29 AM)darksun84 Wrote:  i tried with 500 i_torch_wall and foristances worked fine Shock

Not here :/
I'm using the lastest pre-release.


RE: How to turn all light sources ON/OFF - Extreme - 06-29-2013 05:12 AM

I fixed it, just made a WHILE for FORINSTANCES that isn't working properly.
Now TURNLIGHTS 1 turns ALL lightsources ON with no problem, same for turning off Big Grin


RE: How to turn all light sources ON/OFF - admin phoenix - 06-29-2013 08:28 PM

can I see your script, please?