Background for Skyrim SE

The Form Script

    The Form script is a part of Skyrim SE’s Papyrus scripting ecosystem. It is included with the base game, and is extended/modified by modded sources such as Skyrim Script Extender x64 (SKSE).

    For this script, the Papyrus index knows about:

    • 19 events
    • 62 functions


    Inheritance Tree

    Properties

    No properties found.

      Events

      • eventOnAnimationEvent(ObjectReferenceakSource, stringasEventName)

        Event called when the active magic effect/alias/form receives one of the animation events it was listening for.

      • eventOnAnimationEventUnregistered(ObjectReferenceakSource, stringasEventName)

        Received when one of the animation events we are listening for has been automatically unregistered by the game due to the target animation graph unloading. This event is not received when you manually unregister for the event.

      • eventOnGainLOS(ActorakViewer, ObjectReferenceakTarget)

        Event called when a viewer goes from not seeing the target, to seeing the target - if this active magic effect/alias/form is registered for it.

      • eventOnLostLOS(ActorakViewer, ObjectReferenceakTarget)

        Event called when a viewer goes from seeing the target, to not seeing the target - if this active magic effect/alias/form is registered for it.

      • eventOnSleepStart(floatafSleepStartTime, floatafDesiredSleepEndTime)

        Event called when the player goes to sleep - if this active magic effect/alias/form is registered for it.

      • eventOnSleepStop(boolabInterrupted)

        Event called when the player wakes up - if this active magic effect/alias/form is registered for it.

      • eventOnTrackedStatsEvent(stringarStatName, intaiStatValue)

        Event called when tracked stats are updated - if this active magic effect/alias/form is registered for it.

      • eventOnUpdate()

        Event called periodically if the active magic effect/alias/form is registered for update events. This event will not be sent if the game is in menu mode.

      • Event called periodically in game time if the active magic effect/alias/form is registered for update events. This event will not be sent if the game is in menu mode.

      • eventOnKeyDown(intkeyCode)

        Listens for the pressing of keys whose Input have been registered via Form.RegisterForKey(...). (This event requires SKSE)

      • eventOnKeyUp(intkeyCode, floatholdTime)

        Listens for the release of keys whose Input have been registered via Form.RegisterForKey(...). (This event requires SKSE)

      • eventOnControlDown(stringcontrol)

        Listens for the pressing of game controls that have been registered via Form.RegisterForControl(...).

      • eventOnControlUp(stringcontrol, floatholdTime)

        Listens for the release of game controls that have been registered via Form.RegisterForControl(...).

      • eventOnMenuOpen(stringmenuName)

        Listens for opening of UI previously registered via Form.RegisterForMenu(...). (This function requires SKSE)

      • eventOnMenuClose(stringmenuName)

        Listens for closing of UI previously registered via Form.RegisterForMenu(...). (This function requires SKSE)

      • eventOnPlayerCameraState(intoldState, intnewState)

        Listens for camera state changes, for this event to be received the form must have been registered previously via Form.RegisterForCameraState().

      • Listens for target (See notes) changes of the crosshair, for this event to be received the form must have been registered previously via Form.RegisterForCrosshairRef().

        Syntax

        Event OnCrosshairRefChange(ObjectReference ref)
        

        Parameters

        • ref: The ObjectReference that is targeted (Can be None).

        Examples

        Event OnInit()
            RegisterForCrosshairRef()
        EndEvent
         
        Event OnCrosshairRefChange(ObjectReference ref)
            If ref ;Used to determine if it's none or not.
                Debug.Trace("Crosshair had " + ref + " targeted.")
            EndIf
        EndEvent
        
      • eventOnActorAction(intactionType, ActorakActor, Formsource, intslot)

        Listens for actor actions. For this event to be received, the form must have been registered previously via Form.RegisterForActorAction(...).

        Syntax

        Event OnActorAction(int actionType, Actor akActor, Form source, int slot)
        

        Parameters

        • actionType - The actionType that triggered the event (See Form.RegisterForActorAction(...) for a list of available action types).

        • akActor - The actor that triggered the event.

        • source - The Weapon or Spell that was used within the action.

        • slot - The slot of the source item. Valid Slots:

          • 0 - Left Hand
          • 1 - Right Hand
          • 2 - Voice

        Examples

        Actor property PlayerRef auto
        
        Event OnInit()
            RegisterForActorAction(0);Register for melee swings.
        EndEvent
         
        Event OnActorAction(int actionType, Actor akActor, Form source, int slot)
            if akActor == PlayerRef
                    If !source ;Hand to Hand does not have a form of its own so it will be none.
                    If !slot ;Left Hand slot
                        Debug.Trace("The player has swung their left fist.")
                    Else
                        Debug.Trace("The player has swung their right fist.")
                    EndIf
                    EndIf
                Endif
        EndEvent
        
      • Event called when a NetImmerse node is updated.

      Functions

      • intfunctionGetFormID()Native

        Returns this form's form ID.

      • intfunctionGetGoldValue()Native

        Returns the value of this form in gold. If called on a form that doesn't have a value (like a quest), it will return -1.

      • boolfunctionHasKeyword(KeywordakKeyword)Native

        Checks to see if the specified keyword is attached to this form.

      • boolfunctionPlayerKnows()Native

        Is the "Known" flag set for this form? This is used for MagicEffect, WordOfPower, and Enchantment.

      • boolfunctionRegisterForAnimationEvent(ObjectReferenceakSender, stringasEventName)Native

        Registers this active magic effect/alias/form for the specified Form.OnAnimationEvent(...) on the specified reference. The event will only go to the specific effect, alias, or form that registered and will not be relayed to attached aliases or effects.

      • voidfunctionRegisterForLOS(ActorakViewer, ObjectReferenceakTarget)Native

        Registers this active magic effect/alias/form to receive LOS (line-of-sight) events between the viewer and the target. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForSingleLOSGain(ActorakViewer, ObjectReferenceakTarget)Native

        Registers this active magic effect/alias/form to receive a single Form.OnGainLOS(...). If the viewer is currently looking at the target, the event will be sent immediately. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForSingleLOSLost(ActorakViewer, ObjectReferenceakTarget)Native

        Registers this active magic effect/alias/form to receive a single Form.OnLostLOS(...). If the viewer is not currently looking at the target, the event will be sent immediately. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForSingleUpdate(floatafInterval)Native

        Registers this form/alias/magic effect for a single Form.OnUpdate(). Which also means you don't need to call Form.UnregisterForUpdate() unless you want to cancel the update early. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForSleep()Native

        Registers this active magic effect/alias/form to receive events when the player goes to sleep and when he wakes up. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForTrackedStatsEvent()Native

        Registers this active magic effect/alias/form to receive Form.OnTrackedStatsEvent(...) when tracked stats are updated. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForUpdate(floatafInterval)Native

        Registers this active magic effect/alias/form for periodic Form.OnUpdate(). The interval is only counted when the game is not in menu mode. For example, you register for update every 5 seconds. 2 seconds go by and the player opens the menu for 10 seconds. Once the player puts the menu away, 3 more seconds will go by before your next update comes in. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForUpdateGameTime(floatafInterval)Native

        Registers this active magic effect/alias/form for periodic Form.OnUpdateGameTime() in game time. Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionRegisterForSingleUpdateGameTime(floatafInterval)Native

        Registers this active magic effect/alias/form for a single Form.OnUpdateGameTime(). Of course, this means you don't need to call Form.UnregisterForUpdateGameTime(). Only the specific form, alias, or magic effect that registered will get the event - it will not be relayed to attached aliases or magic effects.

      • voidfunctionStartObjectProfiling()Native

        Starts profiling all scripts attached to this object until stopped. The profile files are stored in "<documents>/My Games/Skyrim/Logs/Script/Profiling". This will also cycle the older profiling logs (so log 0 becomes 1, 1 becomes 2, etc). If the object is already profiled nothing will change. Profiling requests are not saved and will be reset if you load a save game.

      • voidfunctionStopObjectProfiling()Native

        Stops profiling all scripts attached to this object until stopped. The profile files are stored in "<documents>/My Games/Skyrim/Logs/Script/Profiling". This will also cycle the older profiling logs (so log 0 becomes 1, 1 becomes 2, etc). If the object is not already profiled nothing will change.

      • voidfunctionUnregisterForAnimationEvent(ObjectReferenceakSender, stringasEventName)Native

        Unregisters this active magic effect/alias/form from the specified Form.OnAnimationEvent(...) on the specified reference.

      • voidfunctionUnregisterForLOS(ActorakViewer, ObjectReferenceakTarget)Native

        Unregisters this active magic effect/alias/form to stop receiving LOS events from between the viewer and the target.

      • voidfunctionUnregisterForSleep()Native

        Unregisters this active magic effect/alias/form from receiving sleep-related events.

      • voidfunctionUnregisterForTrackedStatsEvent()Native

        Unregisters this active magic effect/alias/form from receiving Form.OnTrackedStatsEvent(...).

      • voidfunctionUnregisterForUpdate()Native

        Unregisters this active magic effect/alias/form so it no longer receives Form.OnUpdate() triggered by a call to Form.RegisterForUpdate(...) or Form.RegisterForSingleUpdate(...).

      • voidfunctionUnregisterForUpdateGameTime()Native

        Unregisters this active magic effect/alias/form so it no longer receives periodic game time Form.OnUpdateGameTime().

      • intfunctionGetType()Native

        Returns this form's form type. (This function requires SKSE)

      • stringfunctionGetName()Native

        Returns the name of the passed form. (This function requires SKSE)

      • voidfunctionSetName(stringname)Native

        Sets the name of the form. (This function requires SKSE)

      • floatfunctionGetWeight()Native

        Returns the weight of this form. (This function requires SKSE)

      • voidfunctionSetWeight(floatweight)Native

        Sets the weight of this form. (This function requires SKSE)

      • voidfunctionSetGoldValue(intvalue)Native

        Sets the value of this form in gold. (This function requires SKSE)

      • intfunctionGetNumKeywords()Native

        Returns the number of keywords assigned to this form. (This function requires SKSE)

      • KeywordfunctionGetNthKeyword(intindex)Native

        Returns the Nth keyword assigned to this form. (This function requires SKSE)

      • Keyword[]functionGetKeywords()Native

        returns all keywords of the form

      • boolfunctionHasKeywordString(strings)

        Checks to see if the specified keyword is attached to this form. (This function requires SKSE)

      • voidfunctionSetPlayerKnows(boolknows)Native

        Sets whether the player knows this form
        Should only be used for Magic Effects,
        Words of Power, and Enchantments

      • voidfunctionRegisterForKey(intkeyCode)Native

        Registers the given Input for Form.OnKeyDown(...) and Form.OnKeyUp(...) events. (This function requires SKSE)

      • voidfunctionUnregisterForKey(intkeyCode)Native

        Unregisters the given Input for Form.OnKeyDown(...) and Form.OnKeyUp(...) events after prior registration via Form.RegisterForKey(...). (This function requires SKSE)

      • voidfunctionUnregisterForAllKeys()Native

        Unregisters all Input for Form.OnKeyDown(...) and Form.OnKeyUp(...) events after prior registration via Form.RegisterForKey(...). (This function requires SKSE)

      • voidfunctionRegisterForControl(stringcontrol)Native

        Registers the given Control for Form.OnControlDown(...) and Form.OnControlUp(...) events.

      • voidfunctionUnregisterForControl(stringcontrol)Native

        Unregisters the given control for Form.OnControlDown(...) and Form.OnControlUp(...) events after prior registration via Form.RegisterForControl(...).

      • voidfunctionUnregisterForAllControls()Native

        Unregisters all controls for Form.OnControlDown(...) and Form.OnControlUp(...) events after prior registration via Form.RegisterForControl(...).

      • voidfunctionRegisterForMenu(stringmenuName)Native

        Registers the calling form to listen for the UI via Form.OnMenuOpen(...) and Form.OnMenuClose(...). (This function requires SKSE)

      • voidfunctionUnregisterForMenu(stringmenuName)Native

        Unregisters the UI, previously registered with Form.RegisterForMenu(...). (This function requires SKSE)

      • voidfunctionUnregisterForAllMenus()Native

        Unregisters all UI previously registered with Form.RegisterForMenu(...). (This function requires SKSE)

      • voidfunctionRegisterForModEvent(stringeventName, stringcallbackName)Native

        Registers a custom event callback for given event name. Registrations have to be refreshed after each game load.

      • voidfunctionUnregisterForModEvent(stringeventName)Native
      • voidfunctionUnregisterForAllModEvents()Native
      • voidfunctionSendModEvent(stringeventName, stringstrArg="", floatnumArg=0.0)Native

        Sends custom event with given generic parameters.

      • voidfunctionRegisterForCameraState()Native

        Registers the calling form to listen for Camera state changes via Form.OnPlayerCameraState(...).

      • voidfunctionUnregisterForCameraState()Native

        Unregisters the calling form for Camera state changes via Form.OnPlayerCameraState(...).

      • voidfunctionRegisterForCrosshairRef()Native

        Registers the calling form to listen for target changes via Form.OnCrosshairRefChange(...).

      • voidfunctionUnregisterForCrosshairRef()Native

        Unregisters the calling form from listening to target changes via Form.OnCrosshairRefChange(...).

      • voidfunctionRegisterForActorAction(intactionType)Native

        Registers the calling form to listen for the specified actor action via Form.OnActorAction(...).

        Syntax

        Function RegisterForActorAction(int actionType) Native
        

        Parameters

        • actionType - The following integers are valid:

          • 0 - Weapon Swing (Melee weapons that are swung including Hand to Hand.)
          • 1 - Spell Cast (Spells and staves).
          • 2 - Spell Fire (Spells and staves).
          • 3 - Voice Cast.
          • 4 - Voice Fire.
          • 5 - Bow Draw.
          • 6 - Bow Release.
          • 7 - Draw Begin.
          • 8 - Draw End.
          • 9 - Sheathe Begin.
          • 10 - Sheathe End.

        Examples

        RegisterforActorAction(0) ; Registers the form for Weapon Swings
        
      • voidfunctionUnregisterForActorAction(intactionType)Native

        Unregisters the calling form from listening for the specified actor action via Form.OnActorAction(...).

        Syntax

        Function UnregisterForActorAction(int actionType) Native
        

        Examples

        UnregisterforActorAction(4);Unregisters the form for Voice Fire.
        
      • voidfunctionRegisterForNiNodeUpdate()Native

        Registers for the NiNodeUpdate event.

      • voidfunctionUnregisterForNiNodeUpdate()Native

        Unregisters for the NiNodeUpdate event.

      • FormfunctionTempClone()Native

        Creates a temporary clone of this form. (This function requires SKSE)

      • boolfunctionHasWorldModel()Native

        Returns whether this Form has a World Model (fast)

      • stringfunctionGetWorldModelPath()Native

        Returns the world model path of this Form, if it has a world model

      • voidfunctionSetWorldModelPath(stringpath)Native

        Sets the world model of the form. (This function requires SKSE)

      • intfunctionGetWorldModelNumTextureSets()Native

        Returns the number of texture sets the world model has, if its textures can be swapped

      • Returns the Nth texture set of the world model, if the textures can be swapped

      • voidfunctionSetWorldModelNthTextureSet(TextureSetnSet, intn)Native

        Sets the world models Nth texture set, if the textures can be set

      • boolfunctionIsPlayable()Native

        Returns whether this Form is playable, only applied to Forms with the playable flag

      Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.