SphereCommunity
Turn lights ON/OFF - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Turn lights ON/OFF (/Thread-Turn-lights-ON-OFF)



Turn lights ON/OFF - Extreme - 04-20-2013 05:52 AM

I willing to make something to lights on the torchs on whole map when the sectors turns dark and off when turns lights...

Need some ideas, thats my idea... when the npc near the torchs lights on or off, it will run these functions to lights on/off near torchs.

Here is it:

PHP Code:
[FUNCTION F_LIGHTSON]
FORITEMS 8
 
IF STRMATCH(*T_LIGHT_OUT*,<TYPE>)
  IF <
SECTOR.ISDARK>
   
MOREY 20
   DCLICK
  
ENDIF
 ENDIF
ENDFOR
RETURN 
1

[FUNCTION F_LIGHTSOFF]
FORITEMS 8
 
IF STRMATCH(*T_LIGHT_LIT*,<TYPE>)
  IF !<
SECTOR.ISDARK>
   
MOREY 20
   DCLICK
  
ENDIF
 ENDIF
ENDFOR
RETURN 

PHP Code:
[EVENTS e_Human_Environ]

ON=@EnvironChange
    
if <flags>&statf_war 
        
return 0
    
endif
    if !<
sector.isdark> || (<flags>&statf_nightsight)
        if <
findlayer(layer_hand2)>
            if <
findlayer(layer_hand2).type> == t_light_lit
                F_LIGHTSOFF
                findlayer
(layer_hand2).bounce
            
endif
        endif
        return 
0
    
endif
    
// already have a lit light ?
    
if <findlayer(layer_hand2)>
        if <
findlayer(layer_hand2).type> == t_light_lit
            
return 0
        
endif
    endif
    
// try to use a torch or light source if i have one. (and it's dark)
    
if <findtype.t_light_out>
        
F_LIGHTSON
        findtype
.t_light_out.equip
        findtype
.t_light_out.use
    endif
    return