Jump to content

New lightswitch Script question


Recommended Posts

Ok i got my lights to work fine BUT....

 

Do i have to define the parent every time? In other words compile a new script for each room/lightswitch ?

 

Im using this that works great...(where Wlightswitch is the name of the xmarker that lights link to as parent)

 

Event OnActivate(ObjectReference akActionRef)
If(Wlightswitch.IsEnabled())
Wlightswitch.disable()
Else
Wlightswitch.enable()
EndIf
EndEvent

 

Is there a way to use the same script over and over and have it automatically link to the referenced object we select ?

Something like instead of a marker name use "ObjectReference" (dont shout i know cr@p about scripting :P ) and make it universal ?

Link to comment
Share on other sites

I don't quite get what you mean but maybe using an INT is a solution instead.

Or do you mean multiple ObjectReferences, both are included

Int Property Into Auto
ObjectReference Property TheLIght Auto
ObjectReference Property TheLIght2 Auto
Event OnActivate (ObjectReference AkActionRef)
If Into == 0
TheLight.enable()
TheLight2.enable()
Utility.wait(0.1)
Into = 1
Else
TheLight.disable()
TheLight2.disable()
Utility.wait(0.1)
Into=0
Endif
EndEvent
Link to comment
Share on other sites

 

I don't quite get what you mean but maybe using an INT is a solution instead.

Or do you mean multiple ObjectReferences, both are included

Int Property Into Auto
ObjectReference Property TheLIght Auto
ObjectReference Property TheLIght2 Auto
Event OnActivate (ObjectReference AkActionRef)
If Into == 0
TheLight.enable()
TheLight2.enable()
Utility.wait(0.1)
Into = 1
Else
TheLight.disable()
TheLight2.disable()
Utility.wait(0.1)
Into=0
Endif
EndEvent

Lemme Clarify...

 

I mean...

 

Is it possible to NOT to have to change these values every time i want to use a different marker (another set of lights/switch etc..)

(Bold highlighted is the name of the marker...)

 

Event OnActivate(ObjectReference akActionRef)

If(Wlightswitch.IsEnabled())

Wlightswitch.disable()

Else

Wlightswitch.enable()

EndIf

EndEvent

 

Imagine im doing a whole area with several buildings and each has its own lights/switches.

Do i have to make fresh script with the marker name for each building?

 

So far i have 3 different switches(duplicated/renamed) and 3 different scripts for each building... Is that how its supposed to be done or is there a way to use ONE universal script at each new building ?

Link to comment
Share on other sites

Solution found... ( big thanks to rdunlop )

Works with enable marker...(no need to rename marker either)

Only need to obviously change the Script name (or paste without the first line)

.......................................

{Controls a set of lights with a master enable parent
marker (EnableMarker) and a switch with this script
attached to turn on and off when the switch is activated}
ObjectReference Property EnableMarker auto
{The marker set as the enable parent of all the lights}
Event OnInit()
If (EnableMarker.IsDisabled())
GoToState("LightsOff")
Else
GoToState("LightsOn")
EndIf
EndEvent
State LightsOff
Event OnBeginState(string asOldState)
EnableMarker.Disable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
GoToState("LightsOn")
EndEvent
EndState
State LightsOn
Event OnBeginState(string asOldState)
EnableMarker.Enable()
EndEvent
Event OnActivate(ObjectReference akActionRef)
GoToState("LightsOff")
EndEvent
EndState
Edited by greekrage
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...