Jump to content

Another scripting question


pepperman35

Recommended Posts

Okay, I am trying to activate/deactivate a Klaxon light (KlaxonLight01) when a button/switch is pressed.

 

Here is the script

 

Scriptname SpecIslandInstReborn:KlaxonToggleScript extends ObjectReference
{Controls the Klaxon light in the workshop 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}
ObjectReference Property myKlaxonLight auto

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()
myKlaxonLight.Activate(Game.GetPlayer())
EndEvent

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

 

 

Here are the errors

 

C:\Users\Omega1\AppData\Local\Temp\PapyrusTemp\SpecIslandInstReborn\KlaxonToggleScript.psc(19,2): the parameter types of function onbeginstate in state lightsoff on script specislandinstreborn:klaxontogglescript do not match the original script scriptobject
C:\Users\Omega1\AppData\Local\Temp\PapyrusTemp\SpecIslandInstReborn\KlaxonToggleScript.psc(29,2): the parameter types of function onbeginstate in state lightson on script specislandinstreborn:klaxontogglescript do not match the original script scriptobject
No output generated for SpecIslandInstReborn:KlaxonToggleScript, compilation failed.

 

 

What am I doing wrong?

Link to comment
Share on other sites

Pretty sure OnBeginState event needs a string parameter which is the old state. Your code should look like this:

Scriptname SpecIslandInstReborn:KlaxonToggleScript extends ObjectReference
{Controls the Klaxon light in the workshop 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}
ObjectReference Property myKlaxonLight auto

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()
		myKlaxonLight.Activate(Game.GetPlayer())
	EndEvent

	Event OnActivate(ObjectReference akActionRef)
		GoToState("LightsOff")
	EndEvent
EndState
Edited by NoCashNoExp
Link to comment
Share on other sites

  • Recently Browsing   0 members

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