Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to turn all light sources ON/OFF
Author Message
Extreme
Grandmaster Poster
***

Posts: 1,140
Likes Given: 217
Likes Received: 89 in 76 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #1
How to turn all light sources ON/OFF
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

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
06-23-2013 02:38 PM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: How to turn all light sources ON/OFF
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

[Image: 2nis46r.jpg]
06-23-2013 09:26 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,140
Likes Given: 217
Likes Received: 89 in 76 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #3
RE: How to turn all light sources ON/OFF
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 !

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
06-25-2013 12:41 AM
Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #4
RE: How to turn all light sources ON/OFF
Maybe it is something to do with the underground region flag?
06-25-2013 01:34 AM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,140
Likes Given: 217
Likes Received: 89 in 76 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #5
RE: How to turn all light sources ON/OFF
(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!

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
06-25-2013 01:51 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #6
RE: How to turn all light sources ON/OFF
i tried with 500 i_torch_wall and foristances worked fine Shock
06-25-2013 02:29 AM
Find all posts by this user Like Post Quote this message in a reply
Ben
Sphere Developer
*****

Posts: 612
Likes Given: 2
Likes Received: 123 in 70 posts
Joined: Mar 2010
Reputation: 18

SphereCommunity

Post: #7
RE: How to turn all light sources ON/OFF
<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

AxisII's current version: 2.0.4j
AxisII SourceCode on Github
AxisII up to date changelog
(This post was last modified: 06-25-2013 12:49 PM by Ben.)
06-25-2013 02:46 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,140
Likes Given: 217
Likes Received: 89 in 76 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #8
RE: How to turn all light sources ON/OFF
(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.

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
06-25-2013 02:48 AM
Find all posts by this user Like Post Quote this message in a reply
Extreme
Grandmaster Poster
***

Posts: 1,140
Likes Given: 217
Likes Received: 89 in 76 posts
Joined: May 2012
Reputation: 20

SphereCommunity

Post: #9
RE: How to turn all light sources ON/OFF
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

STEPS BEFORE CREATE A THREAD
- Check the revisions log;
- Use the search button and use the keywords of your problem;
- Check the WIKI;
- Create a thread.
06-29-2013 05:12 AM
Find all posts by this user Like Post Quote this message in a reply
admin phoenix
Master
**

Posts: 354
Likes Given: 1
Likes Received: 23 in 13 posts
Joined: Mar 2012
Reputation: 3



Post: #10
RE: How to turn all light sources ON/OFF
can I see your script, please?
06-29-2013 08:28 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)