@skyrim-platform/papyrus-util
Version:
TypeScript library for the PapyrusUtil Skyrim modding utility
308 lines (292 loc) • 21.1 kB
JavaScript
/*
==============================================
Typescript definitions for v4.2
==============================================
This file was automatically generated by Papyrus-2-Typescript.exe
https://github.com/CarlosLeyvaAyala/Papyrus-2-Typescript
The program has no way to know the intention of the humans that made
the scripts, so it's always advisable to manually check all generated
files to make sure everything is declared as it should.
Take note the program assumes this script exists in some subfolder
to the folder where `skyrimPlatform.ts` is found, otherwise you'll get
"Cannot find module..." type of errors.
If you want to have this script in some other place, just change the
relative path of each `import`.
*/
import * as sp from "skyrimPlatform";
var sn = sp.JsonUtil;
/** MOD AUTHORS, READ!
These functions all work in exactly the same way as their StorageUtil.psc equivalents. See them for usage docs.
The important difference between these functions and the ones on StorageUtil.psc, is that instead of giving "Form ObjKey"
argument for the location to save the data, you give it a "string FileName" argument, pointing to an external JSON formatted file.
These files will be saved/loaded in JSON format, and the starting location for the files to save/load from is as follows:
data/skse/plugins/StorageUtilData/
Some important notes on usage to keep in mind:
- You may specific a folder path in the filename, i.e. "../MyData/config" will save to data/skse/plugins/MyData/config.json
- If not given in the filename argument, the filename will have the extension .json appended to it automatically when used.
- You do not need to call Load() or Save() manually unless you have a specific need to.
- When the player saves their game any modified file will be automatically saved, written to, or created if it does not exist.
- When the player loads another save without saving themselves or the Save() function having been manually called by a script,
the loaded data will be discarded and revert back to whatever the contents of the current saved file are. */
export var Load = function (FileName) { return sn.Load(FileName); };
export var Save = function (FileName, minify) {
if (minify === void 0) { minify = false; }
return sn.Save(FileName, minify);
};
export var Unload = function (FileName, saveChanges, minify) {
if (saveChanges === void 0) { saveChanges = true; }
if (minify === void 0) { minify = false; }
return sn.Unload(FileName, saveChanges, minify);
};
// Check if given file has had any changes to it they haven't yet been saved
export var IsPendingSave = function (FileName) { return sn.IsPendingSave(FileName); };
// Check if the given file was succesfully loaded and has no json parser errors
export var IsGood = function (FileName) { return sn.IsGood(FileName); };
// Get a formatted error string of any json parser errors on a file, returns as empty string if no errors.
export var GetErrors = function (FileName) { return sn.GetErrors(FileName); };
// Returns a list of all filenames in a given folder that end in .json
export var JsonInFolder = function (folderPath) { return sn.JsonInFolder(folderPath); };
// Check if a json file exists or not
export var JsonExists = function (FileName) { return sn.JsonExists(FileName); };
// See StorageUtil.psc for equivalent function usage instructions
export var SetIntValue = function (FileName, KeyName, value) { return sn.SetIntValue(FileName, KeyName, value); };
export var SetFloatValue = function (FileName, KeyName, value) { return sn.SetFloatValue(FileName, KeyName, value); };
export var SetStringValue = function (FileName, KeyName, value) { return sn.SetStringValue(FileName, KeyName, value); };
export var SetFormValue = function (FileName, KeyName, value) { return sn.SetFormValue(FileName, KeyName, value); };
export var GetIntValue = function (FileName, KeyName, missing) {
if (missing === void 0) { missing = 0; }
return sn.GetIntValue(FileName, KeyName, missing);
};
export var GetFloatValue = function (FileName, KeyName, missing) {
if (missing === void 0) { missing = 0.0; }
return sn.GetFloatValue(FileName, KeyName, missing);
};
export var GetStringValue = function (FileName, KeyName, missing) {
if (missing === void 0) { missing = ""; }
return sn.GetStringValue(FileName, KeyName, missing);
};
export var GetFormValue = function (FileName, KeyName, missing) {
if (missing === void 0) { missing = null; }
return sn.GetFormValue(FileName, KeyName, missing);
};
export var UnsetIntValue = function (FileName, KeyName) { return sn.UnsetIntValue(FileName, KeyName); };
export var UnsetFloatValue = function (FileName, KeyName) { return sn.UnsetFloatValue(FileName, KeyName); };
export var UnsetStringValue = function (FileName, KeyName) { return sn.UnsetStringValue(FileName, KeyName); };
export var UnsetFormValue = function (FileName, KeyName) { return sn.UnsetFormValue(FileName, KeyName); };
export var HasIntValue = function (FileName, KeyName) { return sn.HasIntValue(FileName, KeyName); };
export var HasFloatValue = function (FileName, KeyName) { return sn.HasFloatValue(FileName, KeyName); };
export var HasStringValue = function (FileName, KeyName) { return sn.HasStringValue(FileName, KeyName); };
export var HasFormValue = function (FileName, KeyName) { return sn.HasFormValue(FileName, KeyName); };
export var IntListAdd = function (FileName, KeyName, value, allowDuplicate) {
if (allowDuplicate === void 0) { allowDuplicate = true; }
return sn.IntListAdd(FileName, KeyName, value, allowDuplicate);
};
export var FloatListAdd = function (FileName, KeyName, value, allowDuplicate) {
if (allowDuplicate === void 0) { allowDuplicate = true; }
return sn.FloatListAdd(FileName, KeyName, value, allowDuplicate);
};
export var StringListAdd = function (FileName, KeyName, value, allowDuplicate) {
if (allowDuplicate === void 0) { allowDuplicate = true; }
return sn.StringListAdd(FileName, KeyName, value, allowDuplicate);
};
export var FormListAdd = function (FileName, KeyName, value, allowDuplicate) {
if (allowDuplicate === void 0) { allowDuplicate = true; }
return sn.FormListAdd(FileName, KeyName, value, allowDuplicate);
};
export var IntListGet = function (FileName, KeyName, index) { return sn.IntListGet(FileName, KeyName, index); };
export var FloatListGet = function (FileName, KeyName, index) { return sn.FloatListGet(FileName, KeyName, index); };
export var StringListGet = function (FileName, KeyName, index) { return sn.StringListGet(FileName, KeyName, index); };
export var FormListGet = function (FileName, KeyName, index) { return sn.FormListGet(FileName, KeyName, index); };
export var IntListSet = function (FileName, KeyName, index, value) { return sn.IntListSet(FileName, KeyName, index, value); };
export var FloatListSet = function (FileName, KeyName, index, value) { return sn.FloatListSet(FileName, KeyName, index, value); };
export var StringListSet = function (FileName, KeyName, index, value) { return sn.StringListSet(FileName, KeyName, index, value); };
export var FormListSet = function (FileName, KeyName, index, value) { return sn.FormListSet(FileName, KeyName, index, value); };
export var IntListRemove = function (FileName, KeyName, value, allInstances) {
if (allInstances === void 0) { allInstances = true; }
return sn.IntListRemove(FileName, KeyName, value, allInstances);
};
export var FloatListRemove = function (FileName, KeyName, value, allInstances) {
if (allInstances === void 0) { allInstances = true; }
return sn.FloatListRemove(FileName, KeyName, value, allInstances);
};
export var StringListRemove = function (FileName, KeyName, value, allInstances) {
if (allInstances === void 0) { allInstances = true; }
return sn.StringListRemove(FileName, KeyName, value, allInstances);
};
export var FormListRemove = function (FileName, KeyName, value, allInstances) {
if (allInstances === void 0) { allInstances = true; }
return sn.FormListRemove(FileName, KeyName, value, allInstances);
};
export var IntListInsertAt = function (FileName, KeyName, index, value) { return sn.IntListInsertAt(FileName, KeyName, index, value); };
export var FloatListInsertAt = function (FileName, KeyName, index, value) { return sn.FloatListInsertAt(FileName, KeyName, index, value); };
export var StringListInsertAt = function (FileName, KeyName, index, value) { return sn.StringListInsertAt(FileName, KeyName, index, value); };
export var FormListInsertAt = function (FileName, KeyName, index, value) { return sn.FormListInsertAt(FileName, KeyName, index, value); };
export var IntListRemoveAt = function (FileName, KeyName, index) { return sn.IntListRemoveAt(FileName, KeyName, index); };
export var FloatListRemoveAt = function (FileName, KeyName, index) { return sn.FloatListRemoveAt(FileName, KeyName, index); };
export var StringListRemoveAt = function (FileName, KeyName, index) { return sn.StringListRemoveAt(FileName, KeyName, index); };
export var FormListRemoveAt = function (FileName, KeyName, index) { return sn.FormListRemoveAt(FileName, KeyName, index); };
export var IntListClear = function (FileName, KeyName) { return sn.IntListClear(FileName, KeyName); };
export var FloatListClear = function (FileName, KeyName) { return sn.FloatListClear(FileName, KeyName); };
export var StringListClear = function (FileName, KeyName) { return sn.StringListClear(FileName, KeyName); };
export var FormListClear = function (FileName, KeyName) { return sn.FormListClear(FileName, KeyName); };
export var IntListCount = function (FileName, KeyName) { return sn.IntListCount(FileName, KeyName); };
export var FloatListCount = function (FileName, KeyName) { return sn.FloatListCount(FileName, KeyName); };
export var StringListCount = function (FileName, KeyName) { return sn.StringListCount(FileName, KeyName); };
export var FormListCount = function (FileName, KeyName) { return sn.FormListCount(FileName, KeyName); };
export var IntListCountValue = function (FileName, KeyName, value, exclude) {
if (exclude === void 0) { exclude = false; }
return sn.IntListCountValue(FileName, KeyName, value, exclude);
};
export var FloatListCountValue = function (FileName, KeyName, value, exclude) {
if (exclude === void 0) { exclude = false; }
return sn.FloatListCountValue(FileName, KeyName, value, exclude);
};
export var StringListCountValue = function (FileName, KeyName, value, exclude) {
if (exclude === void 0) { exclude = false; }
return sn.StringListCountValue(FileName, KeyName, value, exclude);
};
export var FormListCountValue = function (FileName, KeyName, value, exclude) {
if (exclude === void 0) { exclude = false; }
return sn.FormListCountValue(FileName, KeyName, value, exclude);
};
export var IntListFind = function (FileName, KeyName, value) { return sn.IntListFind(FileName, KeyName, value); };
export var FloatListFind = function (FileName, KeyName, value) { return sn.FloatListFind(FileName, KeyName, value); };
export var StringListFind = function (FileName, KeyName, value) { return sn.StringListFind(FileName, KeyName, value); };
export var FormListFind = function (FileName, KeyName, value) { return sn.FormListFind(FileName, KeyName, value); };
export var IntListHas = function (FileName, KeyName, value) { return sn.IntListHas(FileName, KeyName, value); };
export var FloatListHas = function (FileName, KeyName, value) { return sn.FloatListHas(FileName, KeyName, value); };
export var StringListHas = function (FileName, KeyName, value) { return sn.StringListHas(FileName, KeyName, value); };
export var FormListHas = function (FileName, KeyName, value) { return sn.FormListHas(FileName, KeyName, value); };
export var IntListSlice = function (FileName, KeyName, slice, startIndex) {
if (startIndex === void 0) { startIndex = 0; }
return sn.IntListSlice(FileName, KeyName, slice, startIndex);
};
export var FloatListSlice = function (FileName, KeyName, slice, startIndex) {
if (startIndex === void 0) { startIndex = 0; }
return sn.FloatListSlice(FileName, KeyName, slice, startIndex);
};
export var StringListSlice = function (FileName, KeyName, slice, startIndex) {
if (startIndex === void 0) { startIndex = 0; }
return sn.StringListSlice(FileName, KeyName, slice, startIndex);
};
export var FormListSlice = function (FileName, KeyName, slice, startIndex) {
if (startIndex === void 0) { startIndex = 0; }
return sn.FormListSlice(FileName, KeyName, slice, startIndex);
};
export var IntListResize = function (FileName, KeyName, toLength, filler) {
if (filler === void 0) { filler = 0; }
return sn.IntListResize(FileName, KeyName, toLength, filler);
};
export var FloatListResize = function (FileName, KeyName, toLength, filler) {
if (filler === void 0) { filler = 0.0; }
return sn.FloatListResize(FileName, KeyName, toLength, filler);
};
export var StringListResize = function (FileName, KeyName, toLength, filler) {
if (filler === void 0) { filler = ""; }
return sn.StringListResize(FileName, KeyName, toLength, filler);
};
export var FormListResize = function (FileName, KeyName, toLength, filler) {
if (filler === void 0) { filler = null; }
return sn.FormListResize(FileName, KeyName, toLength, filler);
};
export var IntListCopy = function (FileName, KeyName, copy) { return sn.IntListCopy(FileName, KeyName, copy); };
export var FloatListCopy = function (FileName, KeyName, copy) { return sn.FloatListCopy(FileName, KeyName, copy); };
export var StringListCopy = function (FileName, KeyName, copy) { return sn.StringListCopy(FileName, KeyName, copy); };
export var FormListCopy = function (FileName, KeyName, copy) { return sn.FormListCopy(FileName, KeyName, copy); };
export var IntListToArray = function (FileName, KeyName) { return sn.IntListToArray(FileName, KeyName); };
export var FloatListToArray = function (FileName, KeyName) { return sn.FloatListToArray(FileName, KeyName); };
export var StringListToArray = function (FileName, KeyName) { return sn.StringListToArray(FileName, KeyName); };
export var FormListToArray = function (FileName, KeyName) { return sn.FormListToArray(FileName, KeyName); };
export var AdjustIntValue = function (FileName, KeyName, amount) { return sn.AdjustIntValue(FileName, KeyName, amount); };
export var AdjustFloatValue = function (FileName, KeyName, amount) { return sn.AdjustFloatValue(FileName, KeyName, amount); };
export var IntListAdjust = function (FileName, KeyName, index, amount) { return sn.IntListAdjust(FileName, KeyName, index, amount); };
export var FloatListAdjust = function (FileName, KeyName, index, amount) { return sn.FloatListAdjust(FileName, KeyName, index, amount); };
export var CountIntValuePrefix = function (FileName, PrefixKey) { return sn.CountIntValuePrefix(FileName, PrefixKey); };
export var CountFloatValuePrefix = function (FileName, PrefixKey) { return sn.CountFloatValuePrefix(FileName, PrefixKey); };
export var CountStringValuePrefix = function (FileName, PrefixKey) { return sn.CountStringValuePrefix(FileName, PrefixKey); };
export var CountFormValuePrefix = function (FileName, PrefixKey) { return sn.CountFormValuePrefix(FileName, PrefixKey); };
export var CountIntListPrefix = function (FileName, PrefixKey) { return sn.CountIntListPrefix(FileName, PrefixKey); };
export var CountFloatListPrefix = function (FileName, PrefixKey) { return sn.CountFloatListPrefix(FileName, PrefixKey); };
export var CountStringListPrefix = function (FileName, PrefixKey) { return sn.CountStringListPrefix(FileName, PrefixKey); };
export var CountFormListPrefix = function (FileName, PrefixKey) { return sn.CountFormListPrefix(FileName, PrefixKey); };
export var CountAllPrefix = function (FileName, PrefixKey) { return sn.CountAllPrefix(FileName, PrefixKey); };
// Experimental custom json formatting handlers. Paths are resolved using typical json syntax.
// The path will be created as necessary when setting data and the path does not yet exists.
// examples:
// JSON File: /** "foo": /** "bar": [3, 10, 7] */ */
// Function: GetPathIntValue("filename.json", ".foo.bar[1]")
// Return: 10
export var SetPathIntValue = function (FileName, Path, value) { return sn.SetPathIntValue(FileName, Path, value); };
export var SetPathFloatValue = function (FileName, Path, value) { return sn.SetPathFloatValue(FileName, Path, value); };
export var SetPathStringValue = function (FileName, Path, value) { return sn.SetPathStringValue(FileName, Path, value); };
export var SetPathFormValue = function (FileName, Path, value) { return sn.SetPathFormValue(FileName, Path, value); };
export var SetRawPathValue = function (FileName, Path, RawJSON) { return sn.SetRawPathValue(FileName, Path, RawJSON); };
export var GetPathIntValue = function (FileName, Path, missing) {
if (missing === void 0) { missing = 0; }
return sn.GetPathIntValue(FileName, Path, missing);
};
export var GetPathFloatValue = function (FileName, Path, missing) {
if (missing === void 0) { missing = 0.0; }
return sn.GetPathFloatValue(FileName, Path, missing);
};
export var GetPathStringValue = function (FileName, Path, missing) {
if (missing === void 0) { missing = ""; }
return sn.GetPathStringValue(FileName, Path, missing);
};
export var GetPathFormValue = function (FileName, Path, missing) {
if (missing === void 0) { missing = null; }
return sn.GetPathFormValue(FileName, Path, missing);
};
export var GetPathBoolValue = function (FileName, Path, missing) {
if (missing === void 0) { missing = false; }
return sn.GetPathBoolValue(FileName, Path, missing);
};
export var PathIntElements = function (FileName, Path, invalidType) {
if (invalidType === void 0) { invalidType = 0; }
return sn.PathIntElements(FileName, Path, invalidType);
};
export var PathFloatElements = function (FileName, Path, invalidType) {
if (invalidType === void 0) { invalidType = 0.0; }
return sn.PathFloatElements(FileName, Path, invalidType);
};
export var PathStringElements = function (FileName, Path, invalidType) {
if (invalidType === void 0) { invalidType = ""; }
return sn.PathStringElements(FileName, Path, invalidType);
};
export var PathFormElements = function (FileName, Path, invalidType) {
if (invalidType === void 0) { invalidType = null; }
return sn.PathFormElements(FileName, Path, invalidType);
};
export var FindPathIntElement = function (FileName, Path, toFind) { return sn.FindPathIntElement(FileName, Path, toFind); };
export var FindPathFloatElement = function (FileName, Path, toFind) { return sn.FindPathFloatElement(FileName, Path, toFind); };
export var FindPathStringElement = function (FileName, Path, toFind) { return sn.FindPathStringElement(FileName, Path, toFind); };
export var FindPathFormElement = function (FileName, Path, toFind) { return sn.FindPathFormElement(FileName, Path, toFind); };
export var PathCount = function (FileName, Path) { return sn.PathCount(FileName, Path); };
export var PathMembers = function (FileName, Path) { return sn.PathMembers(FileName, Path); };
export var CanResolvePath = function (FileName, Path) { return sn.CanResolvePath(FileName, Path); };
export var IsPathString = function (FileName, Path) { return sn.IsPathString(FileName, Path); };
export var IsPathNumber = function (FileName, Path) { return sn.IsPathNumber(FileName, Path); };
export var IsPathForm = function (FileName, Path) { return sn.IsPathForm(FileName, Path); };
export var IsPathBool = function (FileName, Path) { return sn.IsPathBool(FileName, Path); };
export var IsPathArray = function (FileName, Path) { return sn.IsPathArray(FileName, Path); };
export var IsPathObject = function (FileName, Path) { return sn.IsPathObject(FileName, Path); };
export var SetPathIntArray = function (FileName, Path, arr, append) {
if (append === void 0) { append = false; }
return sn.SetPathIntArray(FileName, Path, arr, append);
};
export var SetPathFloatArray = function (FileName, Path, arr, append) {
if (append === void 0) { append = false; }
return sn.SetPathFloatArray(FileName, Path, arr, append);
};
export var SetPathStringArray = function (FileName, Path, arr, append) {
if (append === void 0) { append = false; }
return sn.SetPathStringArray(FileName, Path, arr, append);
};
export var SetPathFormArray = function (FileName, Path, arr, append) {
if (append === void 0) { append = false; }
return sn.SetPathFormArray(FileName, Path, arr, append);
};
export var ClearPath = function (FileName, Path) { return sn.ClearPath(FileName, Path); };
export var ClearPathIndex = function (FileName, Path, Index) { return sn.ClearPathIndex(FileName, Path, Index); };
// Debug use
export var ClearAll = function (FileName) { return sn.ClearAll(FileName); };