Jump to content

Toggle Global Script - giving me headache. Help please.


antstubell

Recommended Posts

I'm going a little mad here because I'm sure I've done this before. Honestly all I ask is for somebody to take a quick look and fix it. It's a on activate toggle global value script with a notification to aid with my other scripting. Thank you and I know it sounds lazy but really a quick fix and lesson will be learnt.

 

Actor Property PlayerRef Auto
Float Property Delay Auto
GlobalVariable Property MyGlobal Auto

Auto State Waiting

Event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerREF

GotoState("Busy")

If MyGlobal.GetValue() == 0
MyGlobal.SetValue(1)
debug.notification("Global = "+ MyGlobal)
Utility.wait(delay); time for anim

ElseIf MyGlobal.GetValue() == 1
MyGlobal.SetValue(0)
debug.notification("Global = "+ MyGlobal)
Utility.wait(delay); time for anim

GoToState("Done")

EndIf
EndIf
EndEvent
EndState

 

Link to comment
Share on other sites

Currently, when the object is activated the first time it moves to the busy state. If the global variable value is 0 it does stuff and ends the block leaving the script in the busy state. If the global variable value is 1 instead it does some stuff and moves the script to the done state. In this setup the activation will never process again. I suggest that the GoToState("Done") be changed to GoToState("Waiting") and dropped down below the first EndIf. That way the script will go to the busy state and process something if the global variable value is 0 or 1 else it will just switch back to the waiting state. But if you have stuff in the Done state (that you did not include in the snippet) that moves the script back to the waiting state, then you need to check there to see what could be blocking the state switch.

Link to comment
Share on other sites

Kind of stupid of me. I wrote the script for a switch that I thought player would need to use once. Then I thought why would a switch on a generator only be allowed to turn off? I could make some s**t up but that would require at least some reasonable explanation somewhere. Anyways, you're correct about the state. The issue I have now is that the notification that displays, whether the global is 0 or 1 is this Global = [GlobalValue

Link to comment
Share on other sites

  • Recently Browsing   0 members

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