Documentation
¶
Overview ¶
Package project reads, creates and builds mod source projects. A project is a directory with mod.json, whose manifest names the mod and its language; building it writes the built mod, a directory modlock-host loads, to the project's build directory.
Index ¶
Constants ¶
const BuildDir = "build"
BuildDir is the built mod's directory within a project.
const ContentDir = "content"
ContentDir is a project's directory of client content: the files of the mod's content addon, without the addon's name. A file at content/<kind>/<path>, such as content/layout/inventory.xml, builds to panorama/<kind>/<addon>/<path> in the built mod, and one in an asset kind, such as content/models/pawn.vmdl_c, to models/<addon>/pawn.vmdl_c.
const Entry = "mod.wasm"
Entry is the built WebAssembly module's file name in a built mod.
const LibraryDir = ".modlock"
LibraryDir is where a Luau or Python project's copy of the modlock library lives, so the checker and editors resolve it.
const ManifestFile = check.ManifestFile
ManifestFile is the manifest's file name in a project and a built mod.
const MapsDir = "maps"
MapsDir is the directory of a project, and of its built mod, that holds the map the mod plays on when the mod ships its own: maps/<map>.vpk, and maps/<map>.bsp for the Quake collision its movement model walks on.
const Module = "github.com/paralin/modlock"
Module is the Go module of the Modlock library mods import.
const ScriptEntry = "mod.js"
ScriptEntry is the bundled JavaScript's file name in a built mod.
const SourcesEntry = "mod.zip"
SourcesEntry is the zip of a Luau or Python mod's sources in a built mod, which its runtime reads in place.
Variables ¶
This section is empty.
Functions ¶
func ReadManifest ¶
func ReadManifest(dir string) (*manifestpb.Manifest, error)
ReadManifest reads the mod.json in dir, a project or a built mod.
func WriteManifest ¶
func WriteManifest(path string, manifest *manifestpb.Manifest) error
WriteManifest writes manifest to path as indented JSON, one field per line, with enums by name. It replaces path whole.
Types ¶
type CheckError ¶
type CheckError struct {
// Err describes the failure in one line.
Err error
// Diagnostics lists the problems.
Diagnostics []*cli.Diagnostic
}
CheckError is a build that failed on problems in the sources. Diagnostics locates each problem the checks and compilers reported.
func (*CheckError) Error ¶
func (e *CheckError) Error() string
Error returns the one-line description.
func (*CheckError) Unwrap ¶
func (e *CheckError) Unwrap() error
Unwrap returns the one-line description's error.
type Mode ¶ added in v0.1.4
type Mode int
Mode chooses what a script mod's build favors.
const ( // Release is the build publishing makes. A script mod whose mod.json // asks for RUNTIME_WASM compiles to WebAssembly with scriptc, which runs // it faster, and bundles for QuickJS when scriptc cannot compile it; // every other script mod bundles for QuickJS. scriptc takes about a // minute and gigabytes of memory, so a mod asks for it only when its // frames run too long on QuickJS. Release Mode = iota // Dev bundles a script mod for QuickJS, which builds in a moment. Dev )
type Project ¶
type Project struct {
// Dir is the project directory.
Dir string
// Manifest is the project's mod.json.
Manifest *manifestpb.Manifest
}
Project is a mod's source directory.
func New ¶
func New(ctx context.Context, dir, name string, language manifestpb.Manifest_Language, version string, output io.Writer) (*Project, error)
New writes a project for a mod named name in language to dir, which must not exist or be empty. A Go project fetches the Modlock library at version, such as "v0.2.0" or "latest"; a script, Luau or Python project receives this release's library. output receives the tools' messages.
func (*Project) Build ¶
Build checks the project and writes the built mod to Output. Check and compiler errors go to output and fail the build with a *CheckError that locates them; a failed build leaves the previous built mod in place.
func (*Project) Fingerprint ¶ added in v0.1.18
Fingerprint hashes the built mod: every file's path and content in Output, leaving out logs and hidden staging files, which change without the mod changing. Two builds with the same fingerprint run the same mod, so a watch that rebuilt for a save outside the mod's inputs, such as a note in the project, need not reload it.