Lightswitch with a Boxtrigger?

Post » Tue Nov 20, 2012 10:27 am

Hello,

I′m currently working on my mod which should contain a feature as follows :

You are walking along a corridor and the light is supposed to go out and on as you pass further ( for a scary atmopshere :wink: )
My idea was to add a trigger box which activates the script already given :


ScriptName ManualLightSwitch extends ObjectReference
{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()
EnableMarker.Disable()
EndEvent

Event OnActivate(ObjectReference akActionRef)
GoToState("LightsOn")
EndEvent

EndState

State LightsOn

Event OnBeginState()
EnableMarker.Enable()
EndEvent

Event OnActivate(ObjectReference akActionRef)
GoToState("LightsOff")
EndEvent

EndState




Now I don′t know how to connect the trigger box correctly with the script.
I was trying to use the trigerboxes given in the warehouse_ambushes cell though it didn`t work at all
( even with a normal trap ).

I've only read the few tutorials on the creationkit site so I'm clearly a complete newbie concerning scripting. Therefore I would be very thankfull if some experienced scripter may help me with setting up this script :smile:

Don't know whether it's to complicated to add to the script to play a custom sound when triggering the box?

Thank you guys in advance!
User avatar
gary lee
 
Posts: 3436
Joined: Tue Jul 03, 2007 7:49 pm

Post » Tue Nov 20, 2012 5:27 am

That script needs editing if you want it to work with a triggerbox. Also, it is a bit extra to what I presume you need because it handles re-activating the lights. Here's what you do:

1. Add a xMarker to your cell
2. Ctrl+click all your lights to select them at once
3. Press the "-" key to bring up the http://www.creationkit.com/Batch_Assignment, then set the xmarker as their enable parent
4. Make a new trigger box and add the following script to it:
Scriptname TriggerLightsScript  extends ObjectReferenceObjectReference Property enableMarker  AutoBool doOnce = 0Event OnTrigger(ObjectReference akActionRef)   If (doOnce == 0)      enableMarker.Disable()      doOnce = 1   Else      ;   EndIfEndEvent
5. Then in the properties button where you added the script set the enableMarker as your xMarker made in step 1

- Hypno
User avatar
Richard
 
Posts: 3371
Joined: Sat Oct 13, 2007 2:50 pm

Post » Tue Nov 20, 2012 4:12 am

Thank you very much hypno!

Unfortunately I get this error message when saving the script :


Starting 1 compile threads for 1 files...
Compiling "TriggerLightsScript"...
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TriggerLightsScript.psc(4,5): cannot initialize a bool to 0
No output generated for TriggerLightsScript, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on TriggerLightsScript


Moreover to avoid further questions :

1. Do I use "xMarkerActivator" under the "activators section" or the "xMarker" ( Static )?
2. As Triggerbox do I use the "TriggerBox 256x126"? or the normal " TriggerBox ", which does not have a model as it seems
3. Do I have to add a default triggerbox script additonally to the "Triggelightsscript"?


I hope I don`t bother you with probably stupid questions... :/
User avatar
SiLa
 
Posts: 3447
Joined: Tue Jun 13, 2006 7:52 am

Post » Tue Nov 20, 2012 4:41 am

I don't see why DoOnce has to be a Bool. You could substitute it for "int".
User avatar
courtnay
 
Posts: 3412
Joined: Sun Nov 05, 2006 8:49 pm

Post » Tue Nov 20, 2012 1:01 am

Thank you very much hypno!

Unfortunately I get this error message when saving the script :

Spoiler

Starting 1 compile threads for 1 files...
Compiling "TriggerLightsScript"...
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\TriggerLightsScript.psc(4,5): cannot initialize a bool to 0
No output generated for TriggerLightsScript, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on TriggerLightsScript

As mentioned above, in line 4 swap the word "bool" for "int" then it should work.


Moreover to avoid further questions :

1. Do I use "xMarkerActivator" under the "activators section" or the "xMarker" ( Static )?
I've always used the static xmarker

2. As Triggerbox do I use the "TriggerBox 256x126"? or the normal " TriggerBox ", which does not have a model as it seems

Right-click in the list and make a brand new base

3. Do I have to add a default triggerbox script additonally to the "Triggelightsscript"?

Nope, the mentioned script is all you should need to add

I hope I don`t bother you with probably stupid questions... :/

No probs mate. Never be worried about asking questions around here, that's the point of the place :)

- Hypno
User avatar
ashleigh bryden
 
Posts: 3446
Joined: Thu Jun 29, 2006 5:43 am

Post » Tue Nov 20, 2012 2:14 am

Works perfectly :)

Thank you so much guys you helped me a lot!
User avatar
Siobhan Thompson
 
Posts: 3443
Joined: Sun Nov 12, 2006 10:40 am

Post » Tue Nov 20, 2012 5:51 am

Glad it worked mate, good luck with the rest of the mod

- Hypno
User avatar
Imy Davies
 
Posts: 3479
Joined: Fri Jul 14, 2006 6:42 pm


Return to V - Skyrim