Jump to content

Binding switch to lights and generator audio?


Recommended Posts

your electric switch needs to be type acti (activator).

 

your going to need at least 1 script, and to give refnames to the light and generator and sound.

you'll also need to disable the light and sound intially.

 

using refs: Switch , Generator, Light (i suggest others, these are horrible names)

 

it would be something like this:

scn SwitchGeneratorScript

short isAct

Begin OnActivate
if isAct == 0
lights.enable
GeneratorSound.enable
set isAct to 1 
else
if isAct == 1
lights.disable
Generatorsound.disable
set isAct to 0
endif
;Activate 
endif
end

 

Attach this script to your activator switch, make sure to name all your references first or the script wont compile.

the variable (short) IsAct is 0 when off, and 1 when lights and generator sound are on.

this allows repeated activation to switch between the two modes.

Lights.enable enables the reference called 'Lights' this enables the initially disabled (not visable to start) lights.

generatorsound does the same thing for the sound...

 

the optional (commented out ;activate) at the bottom might help if it doesn't animate the switch proplery.

so would adding

 

Switch.setOpenState 2  ;Open
Switch.SetOpenState 0 ;Closed

 

under generator.disable/enable respectively

 

goodluck

Link to comment
Share on other sites

Thank you was afraid it would involve scripting lol guess thats another thing to learn about =(

i found that a bit scary too at first, but by trying out things, looking at existing scripts and keeping the geck-wiki's section about script commands open, you get a hang of it quite quick and it actually even is kind of fun. what scripting you see in my vegas-baby-mod (my first one) is what i could do after no more than a week, so don't panic :-)

Link to comment
Share on other sites

  • 3 weeks later...

heres an improved easier script, put this on the switch and make it a linked reference to a XMARKER, then set the generator sound and the light as enable children (select the xmarker as an enable parent of each object). to start the lights on set each object (children) to "Set enable state to opposite of parent'

and disable the xmarker to begin with.

scn MyLightSwitchScript

short on
ref MyLink

begin GameMode ; this is always running when loaded, so if on == 1 or 0 it changes accordingly.
Set mylink to GetLinkedRef
if on == 1 
mylink.enable ; this enables the xmarker, and through the enable relationship, its children
endif
if on == 0
mylink.disable
endif
end

begin onactivate ; this block runs when the player  activates the object (flicks the switch in this case)
if Isactionref Player == 1 ; ONLY if the player flicks the switch
if on == 0 ; if its already OFF, default
 set on to 1
elseif on == 1 ; if on is already set to 1
 set on to 0
endif
activate ; play the switch animation
endif
end

 

this script doesnt need persistant references on the light object or generator sound. though it never hurts.

i learn more everyday :)

Edited by xab666
Link to comment
Share on other sites

  • Recently Browsing   0 members

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