Jump to content

Recommended Posts

  • Replies 135
  • Created
  • Last Reply

Top Posters In This Topic

Posted (edited)

when is a script initialized? Just once per load?

I threw this in OnInit()

  Reveal hidden contents



This in Main()

  Reveal hidden contents



and this in GetUpdateTime()

  Reveal hidden contents



How to limit the player to one upgrade per day, and to check whether a blade was sated took some time to figure out how to accomplish efficiently, but here it is:

  Reveal hidden contents



the idea is in any 12 hour period the first 12 kills will upgrade a blade, and the next 12 with satiate the upgraded blade. In effect you need 24 kills per 12 hours to keep the tempered fang blades.

here is the other function:

  Reveal hidden contents

 

Edited by irswat
Posted (edited)

in the script I have a function setup to run at night time. If the player is waiting during the night does this portion of the script still run?

Edited by irswat
Posted

RE: OnInit()

Scripts are initialized when the object they are attached to is first loaded. I really only know what the wiki says on the matter. I've not delved into testing specific scenarios to see if OnInit() could run more than once.

 

RE: waiting at night

It depends upon how your function is called and written as to whether or not it will be skipped or processed after the player has finished waiting. This is something where in-game testing might yield more information than asking others. At least, I know that I can't give any specifics in the matter.

Posted (edited)

the mod should be pretty darn close to fully functional. I know I've said that before, but well, here I have pictures to prove it.

http://i63.tinypic.com/34pjfvo.jpg

DISCLAIMER: Countless mud crabs were slaughtered indiscriminately in the making of this mod.

Edited by irswat
Posted

I had once a script on a item that was crafted for testing purposes and if i remember right this was the oninit/onload behavior:

 

As soon as it's crafted the item begins to exist, but as a "item x on container Y reference" invalid object reference => OnInit

Drop the item => the reference becomes a proper object reference => OnInit again and OnLoad

 

My item became persistent the moment it was loaded so OnInit never run again but i guess if its not persistent it will eventually unload from memory and this behaviour would repeat. But not once per load.

If the item is persistent and placed on the world from the beginning (not in a container) then OnInit would only run once i think.

 

EDIT: I was curious and checked the wiki, the relevant part for when OnInit runs:

 

  Quote

For persistent refs: At game start the first time this script is loaded

For non-persistent refs: When the ref is loaded the first time [and] when the cell resets.

 

 

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...