BoneTongue Posted November 4, 2017 Share Posted November 4, 2017 Im fairly new to scripting, i've only done a bunch of basic stuff My question is, how do you make it so a script will only fire ONCE? I dont want to do a self.disable on my pullchain What im trying to do is just make a debug message pop up when the pullchain is activated My script is (it is functional, it just repeats itself after every "Activate") Scriptname BTG_PullChainTest extends ObjectReference Actor Property PlayerRef Auto Event OnActivate(ObjectReference akActionRef) Debug.Trace("PlayerRef" + akActionRef)if akActionRef == PlayerRefUtility.Wait(2.5)Debug.Notification("I can feel the ground rumbling")endifEndEvent Thank you,BTG Link to comment Share on other sites More sharing options...
acidzebra Posted November 4, 2017 Share Posted November 4, 2017 Typically you'd set your script to run only if a variable has a value X, then change that variable inside the script so the condition is no longer true. You can also use states, I think it's probably the better method but requires a little more effort to understand and implement. This thread should have some relevant info:https://forums.nexusmods.com/index.php?/topic/831819-force-a-script-to-run-only-once/ Link to comment Share on other sites More sharing options...
PeterMartyr Posted November 4, 2017 Share Posted November 4, 2017 Take a look at some of Bethesda default scripts ScriptName defaultActivateLinkDoOnceSCRIPT extends objectReference {Default script intended for triggers. When hit, they'll activate their linked reference} import game import debug objectReference property OnlyActor auto {Set this property if you want to only allow activation from a specific actor, such as the player} bool property doOnce auto {by default, this trigger fires once only.} function ActivateNow(objectReference trigRef) ; Debug.Trace("Activating: " + self + " " + myLink) objectReference myLink = getLinkedRef() self.activate(self, true) if MyLink != NONE myLink.activate(self as objectReference) endif if doOnce == true gotoState("allDone") endif endFunction auto STATE waiting EVENT onTriggerEnter(objectReference actronaut) ; Debug.Trace("Trigger Enter: " + actronaut) if !onlyActor activateNow(actronaut) endif if onlyActor == actronaut activateNow(actronaut) endif endEVENT endSTATE STATE allDone ;do nothing endSTATE it a nice place to start if you don't want a custom scripts, or just to see how beth does certain things Link to comment Share on other sites More sharing options...
Di0nysys Posted November 4, 2017 Share Posted November 4, 2017 Int DoOnce Event OnActivate(ObjectReference akActionRef) if (akActionRef == PlayerRef) if (DoOnce == 0) DoOnce = 1 Utility.Wait(2.5) Debug.Notification("I can feel the ground rumbling") endif endif EndEvent Try this. It's just using an int. People might prefer to use a boolean, but it functions in the same way. Link to comment Share on other sites More sharing options...
BoneTongue Posted November 4, 2017 Author Share Posted November 4, 2017 Int DoOnce Event OnActivate(ObjectReference akActionRef) if (akActionRef == PlayerRef) if (DoOnce == 0) DoOnce = 1 Utility.Wait(2.5) Debug.Notification("I can feel the ground rumbling") endif endif EndEvent Try this. It's just using an int. People might prefer to use a boolean, but it functions in the same way. Thank you so much, it worked flawlessly and was very "light" compared to another one a friend showed me and didnt involve quests..... I'm leaving this topic up for others to learn from Link to comment Share on other sites More sharing options...
Recommended Posts