Scripting API

Scripting API

AddOnSettings

Class in Abyss.Core, from Abyss.Core.

Where a game downloads its add-ons from: settings/addons.json, which Project Settings' Add-ons page lays out — the content address, and whether the game reads the list there as it starts.

public sealed class AddOnSettings

Remarks

The content address is one for every platform, AddOnSettings.PlatformToken in it given way to the name of the folder a build for the platform is made in — win64, macos, linux64, web — so builds/win64-addons is uploaded to https://cdn.example.com/knight/win64/ as it is. With none, a game downloads nothing, and attaches only the add-ons on the computer.

Checked on start, the game reads its list there in the background as it starts, which lists an add-on made after the game shipped, and a newer build of one.

Named with their hash (AddOnSettings.HashedNames), each add-on is hosted as levels_3f9a1c2bd4e5f607.abypack, a name no other build of it has, and each version of the game reads a list of its own, named by Player's Version, catalog_1.23.1.json: so a host's cache never gives an old add-on for a new one, the add-ons are uploaded before the list that names them, every version's lists and add-ons are kept in one place, an add-on two versions share is kept once, and an older list put back names the add-ons it named. Named plainly, each is hosted as levels.abypack, and every version reads AddOnList.FileName. On the player's computer an add-on keeps its plain name either way.

Properties

Address

public string Address { get; set; }

Where the add-ons are, AddOnSettings.PlatformToken in it for the platform's folder: https://cdn.example.com/knight/{platform}/; empty for none.

CheckOnStart

public bool CheckOnStart { get; set; }

Whether the game reads the list at AddOnSettings.Address as it starts.

HashedNames

public bool HashedNames { get; set; }

Whether each add-on is named on the host with its hash, levels_3f9a1c2bd4e5f607.abypack, and each version of the game reads a list of its own, catalog_1.23.1.json; else each is named as on the player's computer, levels.abypack, and every version reads AddOnList.FileName.

Platform

public static string Platform { get; }

The name of the folder a build for the platform the game runs on is made in, which AddOnSettings.PlatformToken gives way to: win64, macos, linux64 or web.

Methods

FileIn

public static string FileIn(string game)

Where a game keeps it: settings/addons.json in its folder.

Parameters

  • game

AddressFor

public Uri? AddressFor(string platform, string version)

The address as a platform reads it, its tokens given way to the platform's folder and the game's version, and ending in a slash, so a file's name is put after it; null for no address, or one that is not a whole http or https address.

Parameters

  • platform: The platform's folder: AddOnSettings.Platform for the one the game runs on.
  • version: The game's version, as Player says it: 1.23.1.

ListFor

public string ListFor(string version)

The list a game of version reads at the address, and a build writes beside its add-ons: AddOnList.FileName, or the version's own, catalog_1.23.1.json.

Parameters

  • version

WhyNot

public string? WhyNot(string version)

What is wrong with the settings for a game of version: an address that is not a whole http or https address, or a version that is no file's name where a list or the address is named by it; null for nothing.

Parameters

  • version

IsVersionName

public static bool IsVersionName(string version)

Whether a version can name a file and a folder of an address alike: letters, digits, dots, dashes, underscores and plus signs, not dots alone.

Parameters

  • version

Read

public static AddOnSettings Read(string game)

A game's settings; the defaults, no address, for one with no addons.json.

Parameters

  • game

Exceptions

  • FormatException: The file is not settings this build reads, saying why.
  • IOException: The file is there and cannot be read.

Parse

public static AddOnSettings Parse(string json)

Settings from their text.

Parameters

  • json

Exceptions

  • FormatException: It is not settings this build reads, saying why.

ToJson

public string ToJson()

The settings as their file holds them.

Write

public void Write(string game)

Writes the settings into a game's folder.

Parameters

  • game

Copy

public AddOnSettings Copy()

A copy, to change without changing this.

Constants

FileName

public const string FileName = "addons.json"

The file, under the game's settings folder.

PathName

public const string PathName = "settings/addons.json"

What it is called in a game's folder and in its pack: settings/addons.json.

CurrentVersion

public const int CurrentVersion = 1

The version of the file this build writes, and the newest it reads.

PlatformToken

public const string PlatformToken = "{platform}"

What a content address names the platform by: {platform}.

VersionToken

public const string VersionToken = "{version}"

What a content address names the game's version by: {version}, Player's Version.