Jump to content

OnLoad() and load distance


Zorkaz

Recommended Posts

Onload() happens when the cell is loaded. But when actually is a cell really loaded?

(I mean in terms of distance)

 

 

Has someone gained insight?

 

 

 

The reason: I want to make some animals respawnable via script, but I'm unsure if they would just pop up

Link to comment
Share on other sites

You may mix OnLoad with OnCellLoad here?

 

OnLoad signals when the ObjectReference's 3d is rendered and ready.

OnCellLoad signals when the cell's 3d and all the children's (object references) 3d in the cell is ready.

 

 

Check the documentation for both.

Link to comment
Share on other sites

The radius that triggers it is your uGridsToLoad which is by default 5 which works out to 10,240 game units radius from the player. Plus/Minus the object offset from the cell datum.

 

Test it yourself by attaching this to some object references for some empirical data so you don't need to rely on internet opinions;

Event OnLoad()
   Debug.Trace("MyScript.OnLoad " + Self + " 3D " + Self.Is3dLoaded() + " Distance " + Self.GetDistance(Game.GetPlayer()) as Int )
EndEvent

Event OnCellAttach()
   Debug.Trace("MyScript.OnCellAttach " + Self + " 3D " + Self.Is3dLoaded() + " Distance " + Self.GetDistance(Game.GetPlayer()) as Int )
EndEvent

Event OnCellLoad()
   Debug.Trace("MyScript.OnCellLoad " + Self + " 3D " + Self.Is3dLoaded() + " Distance " + Self.GetDistance(Game.GetPlayer()) as Int )
EndEvent

Link to comment
Share on other sites

Since we are sharing opinion, I have found OnLoad is the cheapest to use in terms of Papyrus system load, OnCellLoad(/OnCellAttach are equal.


That's from measuring script latency on 4096 const scripts loading at once.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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