adzscott Posted June 16, 2016 Share Posted June 16, 2016 So I've been messing around a little with perk fragments, and have made a mod which triggers a perk fragment script when an object is activated in game. Is there anyway I can prevent the script from being triggered again before it has finished running? I'm trying to prevent a situation where the player can simply mash the "activate" button and run the script a dozen times before it has even finished the first run. States cannot be used (this would be the obvious goto) as fragments are const scripts and therefore cannot support states. I've looked into setting up a perk-conditon which prevents the perk from being used if the fragment is running, but cannot find a relevant conditional. Any advice on how to approach this? Link to comment Share on other sites More sharing options...
MasterMagnus Posted June 16, 2016 Share Posted June 16, 2016 You could use Quest Stages to 'track your progress'. Create quest0 stage: nothing done yetYour code only executes when quest is stage 0 (conditional)First line of code sets quest to stage 1010 stage: workingLast line of code sets quest to stage 2020 stage: done, do nothing Link to comment Share on other sites More sharing options...
Ashnal Posted June 17, 2016 Share Posted June 17, 2016 (edited) So a fragment can't have states right? Why not instead just have an almost empty quest that only has the activation script in it? You have the perk fragment use that quest as a property, and have the quest script have a function with the code you want to execute. In the fragment you just call QuestProperty.Function() Within the quest script you have your states, one which has the function with the stuff you want to do, and the other state a busy state that does nothing. Edited June 17, 2016 by Ashnal Link to comment Share on other sites More sharing options...
adzscott Posted June 17, 2016 Author Share Posted June 17, 2016 (edited) So a fragment can't have states right? Why not instead just have an almost empty quest that only has the activation script in it? You have the perk fragment use that quest as a property, and have the quest script have a function with the code you want to execute. In the fragment you just call QuestProperty.Function() Within the quest script you have your states, one which has the function with the stuff you want to do, and the other state a busy state that does nothing.That's... not a bad idea. It would certainly remove a lot of the limitations of perk fragments (They don't hang on to variables too well). Let me give it a go and see what happens. EDIT: So I gave it a go. Can't find a way to get the quest script to target the activated object. Also, QuestProperty.Function() doesn't appear to be working. Edited June 17, 2016 by adzscott Link to comment Share on other sites More sharing options...
Ashnal Posted June 20, 2016 Share Posted June 20, 2016 (edited) How would you normally get the fragment to target the activated object? If the fragment has a reference to the object, you can simply pass it to the quest script via a function parameter. I looked itup on the CK wiki Scriptname ActivationQuest extends Quest function PerformAction(ObectReference akTarget) GotoState("Busy") ;Stuff you want to do goes here ;akTarget shouldbe the reference to the activated object GotoState("") EndFunction State Busy function PerformAction() ;Do nothing EndFunction EndState that's the script attached to the quest then you have as the perk fragment: ActivationQuest.PerformAction(akTarget) BUT you have to link the property. To do that hit "Properties" underneath the fragment window. Then at the bottom of that window, "Add Property." Type in the type as "Quest" and name it "ActivationQuest." Then once the property is created, select it in the property list and click "Edit Value." For the "Pick Object" dropdown, find and select "ActivationQuest." Note that you have to have created the quest and named it ActivationQuest before doing the perk fragment. I referenced these two articles just now to come up with this :)http://www.creationkit.com/fallout4/index.php?title=States_(Papyrus)http://www.creationkit.com/fallout4/index.php?title=Perk_Fragments Edited June 20, 2016 by Ashnal Link to comment Share on other sites More sharing options...
colebylamoreau Posted June 28, 2016 Share Posted June 28, 2016 (edited) I have been trying to accomplish a similar task. I tried many different combinations including your exact setup. Some of the functions in the quest script would function, some would not. Also I was still able to spam the activation. Another weird issue, when I added the properties from the quest script to the perk fragment the previously non functioning functions would get performed... Papyrus is killing me, fragments even more so. Edit:I managed to accomplish my goal by creating a global variable, using it to set an int in the fragment, then using if/else. So far its working well. ;BEGIN CODEint Running = MyGlobal.GetValueInt() If Running == 0 MyGlobal.SetValue(1) ;do stuff ;do more stuff ;continue doing stuff MyGlobal.SetValue(0) Else Endif;END CODEEndFunction;END FRAGMENT Then I added a condition to my custom activator that also checked for the global and removed the custom activator while the script is running (global is 1) Edited June 29, 2016 by colebylamoreau Link to comment Share on other sites More sharing options...
Recommended Posts