reskate.package reads files from your plugin’s own package: its mod folder, the folder that holds reskate-plugin.json. It cannot reach anything outside it, and it cannot write. Reading needs no permission.
It also reads and chooses your mod’s variants: variants needs no permission, and choose needs the variants permission.
To keep files you write, use reskate.files.
Paths
A path is relative to the package’s root (not to the entry’s folder):"data/spots.json", "sounds/beep.wav". A path is refused, with an error, when it:
- is empty, longer than 260 characters, or starts with
/; - has a
\, a:(a drive, or a stream), or a character outside printable ASCII; - has an empty,
.or..folder (a//b,./a,a/../b); - has a folder or file name that ends in
.or a space.
reskate.package.read(path)
A file’s contents.
The whole file, byte for byte, or
nil when there is no such file (or the path is a folder).reskate.package.read_json(path)
A JSON file’s contents as Lua values: objects become tables with string keys, arrays become lists, null becomes nil.
Raises an error for JSON that is not valid, has a key twice, or is nested deeper than 64.
reskate.package.list(folder)
The names in one of the package’s folders.
The folder’s path in the package. Leave it out, or pass
"", for the root.A sorted list of names. A folder’s name ends in
/. Names with characters outside printable ASCII are left out. A folder that is not there gives an empty list.read and read_json raise an error for a file larger than 16 MB, or one that cannot be read. list raises an error for a folder with more than 1000 entries. All three raise an error for a path that breaks the rules above.Variants
A mod can hold several takes on the same game data, such as several deck models for the one deck every board has. Each is a variant, and one is in the game at a time. Your manifest declares them withvariants. These two functions say which variants there are and put one in the game.
reskate.package.variants()
Your mod’s variants, and which is in the game.
nil when your manifest declares no variants, when its variants could not be read, and on a dedicated server.list within 2 seconds. You can call variants every frame, as a menu page does.
Needs no permission.
chosen can differ from in_play: a choice is in the game once the mods are applied and the level has loaded again, and a chosen variant that is no longer installed falls back to another.reskate.package.choose(name)
Puts one of your mod’s variants in the game. The choice is kept for your mod, and it is the one the game loads from then on, also at the next launch.
Why not:
"its mod declares no variants", "its mod has no variant <name>", "the mods are being applied" or "the choice could not be saved".in_play names it from then on. Choosing the variant already in the game only saves the choice.
Needs the
variants permission (and menu for the example’s page). On a dedicated server, choose returns false, "unavailable here".