Jump to content

A Question About The "OnLoad" Commands


AlexxEG

Recommended Posts

Let's say a object have a script that goes

Begin OnLoad
PlaceAtMe Explosion
End

(I don't realy have that as the script, it's just a example)

If I then use "PlaceAtMe ObjectsFormID", will the script trigger when it's spawned?

Link to comment
Share on other sites

No it won't as the OnLoad block runs once when a cell is loaded, not an object. You could just use this instead:

 

scn MySpawnedExplosionScript

Short DoOnce

Begin GameMode
 If DoOnce == 0
   PlaceAtMe Explosion
   Set DoOnce to 1
   disable            ;Makes the spawned item vanish
   markfordelete      ;will remove the item from the game permanently after a few frames
 EndIf
End

Link to comment
Share on other sites

No it won't as the OnLoad block runs once when a cell is loaded, not an object. You could just use this instead:

 

scn MySpawnedExplosionScript

Short DoOnce

Begin GameMode
 If DoOnce == 0
   PlaceAtMe Explosion
   Set DoOnce to 1
   disable            ;Makes the spawned item vanish
   markfordelete      ;will remove the item from the game permanently after a few frames
 EndIf
End

Ahhh.... Okey thanks^^

Link to comment
Share on other sites

No it won't as the OnLoad block runs once when a cell is loaded, not an object. You could just use this instead:

 

scn MySpawnedExplosionScript

Short DoOnce

Begin GameMode
 If DoOnce == 0
   PlaceAtMe Explosion
   Set DoOnce to 1
   disable            ;Makes the spawned item vanish
   markfordelete      ;will remove the item from the game permanently after a few frames
 EndIf
End

Ahhh.... Okey thanks^^

 

Though, for reference, explosion type objects automatically mark themselves for deletion after their duration expires, so in this particular instance you wouldn't need markfordelete. Most other object types you do, though.

Link to comment
Share on other sites

OnLoad blocks will run when the scripted reference is loaded into memory. This can happen when the player enters the cell containing it, or when it is moved to the player's location from a distance cell, or when a previously disabled object is enabled (for objects with 3D data).

 

In some cases, OnLoad blocks won't run because an object may already be loaded in memory. For example, if I start Fallout 3 and load a save in which a reference with the following script attached to it, the global "TimeScale" variable will be set to 5:

ScriptName InitTimeScaleScript

Begin OnLoad
set TimeScale to 5
End

However, if I then load that same save from in-game, the value of "TimeScale" will be read from the save, but because the object is already loaded its OnLoad block won't run again, so "TimeScale" won't be updated.

 

For this reason, I usually recommend avoiding this blocktype - the fact that it can be ignored so easily makes it pretty useless in most cases.

 

Cipscis

Link to comment
Share on other sites

  • Recently Browsing   0 members

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