Guest Posted February 2, 2016 Posted February 2, 2016 Store it as a property. Scriptname myFirstScript extends WHATEVER Location Property mySavedLocation Auto Event OnWhateverYouWant() mySavedLocation = comeOnGetTheLocation() EndEvent And use it from another script Scriptname mySecondScript extends WHATEVER myFirstScript Property mfs Auto Function DoWhateverYouWant() Location andTheLocationIs = mfs.mySavedLocation EndFunction
ebondream Posted February 3, 2016 Author Posted February 3, 2016 If I have a custom function that I expect to run at many different points of the mod, and I would rather just write it up once and have all those events point to it (So that I can at need change the function without digging through a dozen scripts) What's the best way od going that? Via a quest maybe, or magic effect? EDIT: Starting to understand how to make custom global functions, but if I understand it correctly it's difficult to have those affect say, a specific global varaibles, because I can't give that script properties?
Guest Posted February 3, 2016 Posted February 3, 2016 global functions are just easy to be defined and used inside all the scripts of your mod. Usually I place them inside a script that extends a quest. If you need to have a context for the execution (a value of another variable, a property, etc.) then you should not define it as global, but define it as normal function. And use it not directly from the script definition, but from a property that will point to the script. ; Global scriptname myGlobal extends quest bool Function alwaysTrue() global return true End Function bool aValue bool Function sometimesTrue() aValue = !aValue return aValue EndFunction ; Use of global myGlobal.alwaysTrue() ; Use of reference myGlobal Property mg Auto mg.sometimesTrue()
ebondream Posted February 3, 2016 Author Posted February 3, 2016 So could I have a quest with a script that goes: scriptname myGlobal extends quest GlobalVariable property Alpha auto function ChangeAlpha(int iNumber) Alpha.SetValue(iNumber) endfunction And then set the global variable property on that, And then in some other script I'd write myGlobal Property mg auto mg.ChangeAlpha(5) And that'd set the Global Variable "Alpha" to 5?
Guest Posted February 3, 2016 Posted February 3, 2016 Yes, you can do that. Personally I don't like global variables. You can do similar stuff without them.
ebondream Posted February 3, 2016 Author Posted February 3, 2016 Keeping track of certain numbers is kinda important in what I'm working for, don't really see how I'd get around Global Variables... Somewhat different question: I occasionally placed Activators in a certain cell that I could load a savegame from, just to test out a script. I then later deleted the activator again, but is there some way to more generally 'revert' the cell, so it no longer shows up with the asterisk in the list? I don't imagine it makes a difference, but just in case it'd interfere with some other mod...
Guest Posted February 3, 2016 Posted February 3, 2016 For all you use a global variable you can use an Int or Float property in a script. If you need the value to condition a dialogue or a package or whatever, just define it as "Conditional". To remove the asterisk, open your mod in TES5Edit, find the cell that you edited and now you want back to vanilla, and delete it.
ebondream Posted February 4, 2016 Author Posted February 4, 2016 Is that easier on the engine or something? I'm not sure I see the benefit of using properties instead of global vars...
Guest Posted February 4, 2016 Posted February 4, 2016 They are way less heavy on computation power. They provide more functionalities compared to global variables.
ebondream Posted February 5, 2016 Author Posted February 5, 2016 Feel like I'm missing something really obvious now... what's the best way of calling a function whenver the PC uses a shrine?
ebondream Posted February 5, 2016 Author Posted February 5, 2016 No, I meant I want it to happen whenever the player uses any of the vanilla shrines to get a blessing. I don't really want to change every single shrine in the game--the best I can come up with right now is set up a quest with a few reference aliases, and have the quest repeatedly restart to fill the aliases with the closest shrines...
Guest Posted February 5, 2016 Posted February 5, 2016 You need to add further scripts if you want to track the activation.
ebondream Posted February 5, 2016 Author Posted February 5, 2016 But add them to what? Or isn't there a way to check whenever the PC has been hit by a specific spell, i.e. the shrine spell? OnHit doesn't seem to work for non-harmful spells...
ebondream Posted February 15, 2016 Author Posted February 15, 2016 Me again. I don't suppose there's an easy way to have something happen everytime the player moves into a different cell? OnCellAttach and its various variants don't seem to work for me...
Veladarius Posted February 15, 2016 Posted February 15, 2016 You can try OnCellLoad but it has some quirks as well: http://www.creationkit.com/OnCellLoad_-_ObjectReference You can try OnLocationChange if you don't need to check when you change every cell just locations.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.