pepperman35 Posted January 12, 2021 Share Posted January 12, 2021 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 parentmarker (EnableMarker) and a switch with this scriptattached 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 autoEvent OnInit()If (EnableMarker.IsDisabled())GoToState("LightsOff")ElseGoToState("LightsOn")EndIfEndEventState LightsOffEvent OnBeginState()EnableMarker.Disable()EndEventEvent OnActivate(ObjectReference akActionRef)GoToState("LightsOn")EndEventEndStateState LightsOnEvent OnBeginState()EnableMarker.Enable()myKlaxonLight.Activate(Game.GetPlayer())EndEventEvent OnActivate(ObjectReference akActionRef)GoToState("LightsOff")EndEventEndState 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 scriptobjectC:\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 scriptobjectNo output generated for SpecIslandInstReborn:KlaxonToggleScript, compilation failed. What am I doing wrong? Link to comment Share on other sites More sharing options...
NoCashNoExp Posted January 12, 2021 Share Posted January 12, 2021 (edited) 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 January 12, 2021 by NoCashNoExp Link to comment Share on other sites More sharing options...
pepperman35 Posted January 13, 2021 Author Share Posted January 13, 2021 Thanks, much appreciated. I got the code from the creation Kit site Light Switch so I had assumed it would work, but you know what happens when you assume. lol I also looked at the CK OnBeginState site but couldn't figure it out. So I am greatful for the help. Link to comment Share on other sites More sharing options...
Recommended Posts