IWantMyMod Posted March 16, 2019 Share Posted March 16, 2019 I have tried a number of way to create static properties in Papyrus scripts similar to global functions but nothing seem to work. It would be great to have a static value that I could use from any global function or any other script. Is there some way to do that the I am just missing? Link to comment Share on other sites More sharing options...
Rizalgar Posted March 16, 2019 Share Posted March 16, 2019 (edited) Hmm, if I understand you correctly. You want a static value, stored outside a global variable? That, I'm not sure about. However, a static global is possible. Set the globals value and set it to Constant. Then you could use a script that stores all your static variables, attached to On Game Start quest, with any other script you want calling the globals. I'll show some examples, sorry if this is not what you're meaning, if it isn't then I'm not sure. The static holder script attached to quest Scriptname Framework Extends Quest GlobalVariable Property StaticOne Auto GlobalVariable Property StaticTwo Auto ;;so on and so forth A script, also attached to the same quest, to make call functions from the framework Scriptname Handler Extends Quest Framework Property Fetch Auto ;;assign the quest to this property GlobalVariable Function StatOne() Global Return Fetch.StaticOne EndFunction GlobalVariable Function StatTwo() Global Return Fetch.StaticTwo EndFunction ;;so on and so forth An example script to do something with the static, for some reason Scriptname Why Extends ActiveMagicEffect Handler Property Obtain Auto ;;attach property to quest Event OnEffectStart(Actor target, Actor caster) Game.GetPlayer().SetActorValue(Obtain.StatOne()) EndEvent It may not be what you're looking for, and it may not be the most elegant solution if it is, but it does work. Edit -- A thought occurs. Using the same principle above. You can create a static variable that doesn't require a globalvariable housing. I do it all the time, I guess I just misunderstood what you were saying. Something like this Function GetStatic() Global ;; Replace the proper values from the above script Int 5 ;;the static value you want String "heres a string" ;;a string static value you can call on using the function Float 0.83 ;the same as the Int NoWalkingHere() ; Yes you can even call other functions inside a function from outside a function in another script given its more complex EndFunction Edited March 16, 2019 by Rizalgar Link to comment Share on other sites More sharing options...
IWantMyMod Posted March 16, 2019 Author Share Posted March 16, 2019 Thanks but I'm trying to avoid attaching the script to an object just to get some static values. What I have been doing is using Global functions that simply return the static value. The effect is similar but much less elegant. int Function myGlobalInt() Global return 35 EndFunction Link to comment Share on other sites More sharing options...
Evangela Posted March 19, 2019 Share Posted March 19, 2019 (edited) That still needs to be placed in a script, but the script itself can be hidden and attached to no object. To access it, the script has to be imported into another script, etc. Just use an actual global? Can be accessed by any script via property, and to make it truly static(assuming you never want the value to change), set it to AutoReadOnly. Alternatively can bypass the whole property deal and access the global via GetFormFromFile, and assign the return value to a variable. Edited March 19, 2019 by Rasikko Link to comment Share on other sites More sharing options...
Recommended Posts