SpawnerTask Script

From the CreationKit Wiki
Jump to navigation Jump to search


Minimum required SKSE Version: 1.7.3

A scripted SKSE interface that allows you to spawn objects (e.g. PlaceAtMe) in bulk, such that none of the spawns have to wait on each other.

Definition[edit | edit source]

ScriptName SpawnerTask Hidden

SKSE Global Functions[edit | edit source]

Int Create()
  • Creates a new SpawnerTask and returns the handle. If the handle is zero or a negative number, then SKSE failed to create a SpawnerTask.
AddSpawn(Int handle, Form formToPlace, ObjectReference target, Float[] positionOffset, Float[] rotation, Int count = 1, Bool bForcePersist = false, Bool bInitiallyDisabled = false)
  • Queues an object to spawn at the target when the SpawnerTask is run.
    • The positionOffset array is a world-relative offset from the target.
    • The rotation is a world-relative rotation to be applied to the new object.
ObjectReference[] Run(Int handle)
  • Executes the SpawnerTask, spawning all queued objects and returning an array.
Cancel(Int handle)
  • Aborts the SpawnerTask.

Example[edit | edit source]

Static Property XMarker Auto
{Auto-fill.}

Function SomeFunction()
   Float fPosition = new Float[3]
   Float fRotation = new Float[3]

   fPosition[2] = 128

   Int iHandle = SpawnerTask.Create()
   If (iHandle > 0)
      Int iIterator = 0
      While iIterator < 5
         SpawnerTask.AddSpawn(iHandle, XMarker, fPosition, fRotation)
         fRotation[2] += 24
         iIterator += 5
      EndWhile
      ;
      ObjectReference[] kResults = SpawnerTask.Run()
    EndIf
EndFunction

Notes[edit | edit source]

  • A SpawnerTask may only be used from the same call stack that created it. If you create a SpawnerTask while responding to one event, you cannot manipulate that SpawnerTask from a different event.
  • If a call stack expires without running or canceling its SpawnerTask, SKSE will automatically destroy the SpawnerTask the next time the player saves and loads the game, to prevent it from hanging around in memory forever.