Skip to content

Class PackageLoader

Namespace: Apogee.Scripting
Assembly: Apogee.Scripting.dll

Runs the packages of a in a VM. Each package's scripts run in the order its manifest lists them, packages in load order; a package's base-game scripts run as the VM's base owner, a mod's as an owner of its own (its own memory category and limits), with:

  • @<id>/… as a require alias for each package, so that a mod can use a dependency's modules;
  • confinement: a mod may require files of its own package and of the packages it depends on (and res://), nothing else;
  • the fs library with the same rules: a mod reads res://, its own package, its dependencies', and user://moddata/<id>/, and writes only user://moddata/<id>/;
  • modules that run as the owner of the package they are in, whoever required them.

A script that fails stops its package (the error is logged and in the result), and what depends on it is not run; it never stops the game. Content the package brought stays loaded.

public sealed class PackageLoader

Inheritance

object ← PackageLoader

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

PackageLoader(VirtualFileSystem, PackageSet, PackageLoaderOptions?)

public PackageLoader(VirtualFileSystem files, PackageSet packages, PackageLoaderOptions? options = null)

Parameters

files VirtualFileSystem

packages PackageSet

options PackageLoaderOptions?

Methods

CanAccessFile(ScriptOwner, string, bool)

Gives .

public bool CanAccessFile(ScriptOwner owner, string path, bool write)

Parameters

owner ScriptOwner

path string

write bool

Returns

bool

CanLoadModule(ScriptOwner, string)

Gives .

public bool CanLoadModule(ScriptOwner requester, string path)

Parameters

requester ScriptOwner

path string

Returns

bool

Load(LuauVm)

Makes the owners, aliases and roots, and runs every package's scripts in vm, which was made with this loader's hooks.

public IReadOnlyList<PackageRunResult> Load(LuauVm vm)

Parameters

vm LuauVm

Returns

IReadOnlyList<PackageRunResult>

OwnerOfModule(string)

Gives : a module in a package runs as that package's owner.

public ScriptOwner? OwnerOfModule(string path)

Parameters

path string

Returns

ScriptOwner?