Jump to content

Newbie Scripting Request


ebondream

Recommended Posts

Posted

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
 
Posted

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?

Posted

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()
 

 

 

 

 

 

Posted

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?

Posted

Yes, you can do that.

 

Personally I don't like global variables.

You can do similar stuff without them.

Posted

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...

Posted

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.

Posted

They are way less heavy on computation power.

They provide more functionalities compared to global variables.

 

Posted

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...

Posted

You need to add further scripts if you want to track the activation.

Posted

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...

  • 2 weeks later...
Posted

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...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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