-
Notifications
You must be signed in to change notification settings - Fork 2
New Papyrus Functions
All new functions at this point in time are declared in the PAPER_SKSEFunctions
global script. This means that, in order to access them in your scripts, you may write the following import
statement:
import PAPER_SKSEFunctions
The following functions are related to resources (e.g. files for meshes, textures, animations, and so on), and checking whether or not they exist.
bool Function ResourceExists(String asResourcePath) global native
- This function can be used to determine whether or not a resource with a given path (
asResourcePath
) exists. - Should work for loose files as well as files in BSA archives.
- Provided path should be relative to
<Skyrim installation directory>/Data/
. - May be useful for determining whether or not the user has meshes/textures from certain mods (e.g., armor/clothing/weapon mods) installed, even if their plugins (esp/esl/esm files) are not active (or they do not come with any).
- Included as of version 1.0.0.
Example 1: in the following example, the condition should always be satisfied, since the file that we check for is included in one of the BSA archives of the base game. Any user should have this installed.
if (ResourceExists("meshes/Magic/ParalyzeTargetFX.nif"))
; This should always run!
endIf
Example 2: in the following, where we add an extra slash in front of the path, the condition will generally not be satisfied. However, it appears that such paths (with the extra slash prepended) do in fact work for loose files, but not for files in BSA archives. So, if a user happens to have unpacked the BSA archive (or installed a mod with a loose file that overrides this one), the condition would be satisfied.
if (ResourceExists("/meshes/Magic/ParalyzeTargetFX.nif"))
; This may or may not run depending on whether the file exists as a loose file.
endIf
String[] Function GetInstalledResources(String[] asStrings) global native
- This function returns a new array of strings, containing all the strings from the input array that correspond to installed resources (see the
ResourceExists
function above). - The returned array has a minimum length of
0
(if no input strings are installed resources), and a maximum length equal to the length of the input arrayasStrings
(if all input strings are installed resources). - Included as of version 2.1.0.
The following functions are related to ActorBase
objects.
ColorForm[] Function GetWarpaintColors(ActorBase akActorBase) global native
- This function attempts to figure out what color(s) the given
akActorBase
uses for any warpaints, and returns an array of ColorForms for them. - Will often return a 0-length array, i.e. for actors on which no warpaints are detected.
- If an actor has any warpaints at all, it will usually just be one. But having multiple different warpaints with different colors is technically possible, which is why an array is returned.
- Usually, the color(s) returned will be slightly different from how the warpaint looks in-game: this is because the color that we end up seeing in-game may also get affected by the lightness/darkness of the warpaint texture and/or the face texture.
- Does not check for RaceMenu overlays.
- Included as of version 2.1.0.
The following functions are helper functions for filter arguments of new inventory events. These are solely meant to be used inside OnBatchItemsAdded
and OnBatchItemsRemoved
events.
int[] Function GetInventoryEventFilterIndices(Form[] akEventItems, Form akFilter) global native
- Given a list of base objects (the first parameter), and a filter (the second parameter), returns an array of indices of base objects that match the filter.
- Meant to be used, in combination with the four functions below, inside
OnBatchItemsAdded
orOnBatchItemsRemoved
events. - The filter may either be the Form for an item, or a FormList, exactly as in
AddInventoryEventFilter
. - Included as of version 2.2.0.
int[] Function UpdateInventoryEventFilterIndices(Form[] akEventItems, Form akFilter, int[] aiIndices) global native
- Given a list of base objects (the first parameter), a filter (the second parameter), and an array of indices, returns an updated array of indices of base objects that match the filter.
- Meant to be used, in combination with the above function and the three functions below, inside
OnBatchItemsAdded
orOnBatchItemsRemoved
events. - The filter may either be the Form for an item, or a FormList, exactly as in
AddInventoryEventFilter
. - The
aiIndices
parameter should normally be an array of indices that was returned by a previousGetInventoryEventFilterIndices()
orUpdateInventoryEventFilterIndices()
call. This allows us to apply multiple filters in sequence, analogous to a combination of filters from multiple subsequentAddInventoryEventFilter
calls. - Included as of version 2.2.0.
Form[] Function ApplyInventoryEventFilterToForms(int[] aiIndicesToKeep, Form[] akFormArray) global native
- Given a list of indices to keep (the first parameter) and a list of base objects that was originally passed into an event (the second argument), returns a new array that only keeps the Forms at indices in the list of indices to keep.
- When
aiIndicesToKeep
is obtained using a call toGetInventoryEventFilterIndices()
, optionally followed by a sequence of calls toUpdateInventoryEventFilterIndices()
, andakFormArray
is an array of Forms received in an event for batched item additions/removals, the returned array of Forms will only contain those that match the filters used to generate the array of indices. - Included as of version 2.2.0.
int[] Function ApplyInventoryEventFilterToInts(int[] aiIndicesToKeep, int[] aiIntArray) global native
- Given a list of indices to keep (the first parameter) and a list of item counts / stack sizes that was originally passed into an event (the second argument), returns a new array that only keeps the item counts at indices in the list of indices to keep.
- Usage similar to
ApplyInventoryEventFilterToForms
, except it filters an array of ints instead of an array of Forms. - Included as of version 2.2.0.
ObjectReference[] Function ApplyInventoryEventFilterToObjs(int[] aiIndicesToKeep, ObjectReference[] akObjArray) global native
- Given a list of indices to keep (the first parameter) and a list of ObjectReferences that was originally passed into an event (the second argument), returns a new array that only keeps the ObjectReferences at indices in the list of indices to keep.
- Usage similar to
ApplyInventoryEventFilterToForms
, except it filters an array of ObjectReferences instead of an array of Forms. - Included as of version 2.2.0.
The following functions are miscellaneous functions that do not fit into any of the particular categories used above.
int[] Function GetPaperVersion() global native
- This function returns an array with three entries, representing the currently-loaded version of the PAPER plugin.
- The first entry is the MAJOR version, the second MINOR, and the third PATCH.
- May be used to check whether the user has a correct version installed if your mod requires a certain minimum version.
- Included as of version 1.0.0.