Here's a link - http://www.cipscis.com/skyrim/tutorials/states.aspx
As always, feedback is appreciated.
Cipscis
.
As Amgepo already noted, only thing I didn't see was mention of GotoState("").
.
.ScriptName Statesixample extends ObjectReferenceFunction SharedStuff() ;Do stuffEndFunctionAuto State Inactive Event OnActivate(ObjectReference akActionRef) GoToState("Active") EndEvent Function InactiveOnlyStuff () ;Do stuff EndFunctionEndStateState Active Event OnActivate(ObjectReference akActionRef) GoToState("Inactive") EndEvent Function ActiveOnlyStuff () ;Do stuff EndFunctionEndStateA difference of coding style
.
Thanks!Event OnActivate(ObjectReference akActivator) bLightsOn = !bLightsOn If bLightsOn If rLight rLight.Enable() Else rLight = PlaceAtMe(LightBase) EndIf Else rLight.Disable() EndIfEndEvent
Auto State LightsOff Event OnActivate(ObjectReference akActivator) If rLight rLight.Enable() Else rLight = PlaceAtMe(LightBase) EndIf GoToState("LightsOn") EndEventEndStateState LightsOn Event OnActivate(ObjectReference akActivator) rLight.Disable() GoToState("LightsOff") EndEventEndStateFunction TestSpeed(Int aiIterations = 0, Float afBeginTime = 0.0, Float afEndTime = 0.0) afBeginTime = Utility.GetCurrentRealTime() Debug.Trace("Start: " + afBeginTime) While (aiIterations < 1000) aiIterations += 1 Activate(Game.GetPlayer()) EndWhile afEndTime = Utility.GetCurrentRealTime() Debug.Trace("Finish: " + afEndTime) Debug.Trace("Time Elapsed: " + (afEndTime - afBeginTime))EndFunction[06/04/2012 - 05:04:38AM] Start: 37.200001[06/04/2012 - 05:05:04AM] Finish: 63.493000[06/04/2012 - 05:05:04AM] Time Elapsed: 26.292999
[06/04/2012 - 05:06:44AM] Start: 40.375999[06/04/2012 - 05:07:10AM] Finish: 66.750000[06/04/2012 - 05:07:10AM] Time Elapsed: 26.374001
?
Thanks!Event OnActivate(ObjectReference akActivator) bLightsOn = !bLightsOn If bLightsOn rLight.Enable() Else rLight.Disable() EndIfEndEvent
Auto State LightsOff Event OnActivate(ObjectReference akActivator) rLight.Enable() GoToState("LightsOn") EndEventEndStateState LightsOn Event OnActivate(ObjectReference akActivator) rLight.Disable() GoToState("LightsOff") EndEventEndStateEvent OnActivate(ObjectReference akActivator) If rLight.IsDisabled() rLight.Enable() Else rLight.Disable() EndIfEndEvent
. (Hence the name "empty" state) While putting your script into a state you don't use has the same effect, you run the risk of introducing unexpected behavior if you later define the state in that script, one it extends, or one that extends it.
. Not a criticism that could be levelled at that speed test.