Files and packages
- Source files use the
.aesextension and live underscripts/in the project. Any directory underscripts/is a package; files in one directory belong to one package. - The package path is
project.module + "/" + directory(mygame/player). Thepackageclause must equal the directory's base name (package player); a mismatch isAES4001. - A module path uses
[a-z0-9_/-]only, no dots: qualified names (mygame/player.State) are split on the last dot. importworks as in Go; there are no import aliases. Importing a package that is not underscripts/and not a host module isAES4002; cycles areAES4005. Unused imports are warnings.- Host modules (
aego/input,mygame/combat) and script packages share one namespace. A script directory whose package path equals a host module path isAES4010. Theaego/prefix is reserved for the standard library;module = "aego"is a project error. - Visibility follows Go: identifiers starting with an uppercase letter are exported from the package; everything else is package-private.
@exportis unrelated to visibility (see Attributes). *_test.aesfiles are compiled only byaego test.
A package that fails to compile keeps its last good build; its files are marked invalid and Play is blocked until they compile again.
Run it: one package with exported and package-private declarations. The sandbox compiles a single file, so imports between script packages need a project.
package inventory
import (
"aego/log"
"aego/math"
)
// MaxSlots is exported: other packages read it as inventory.MaxSlots.
const MaxSlots int = 8
// stackSize is package-private.
const stackSize int = 20
// Fit is exported and can be called from other packages.
func Fit(count int) int {
return math.MinInt(count, MaxSlots * stackSize)
}
script Bag {
@export var Count int = 200
func Ready() {
log.Info("package inventory keeps " + string(Fit(Count)) + " of " + string(Count) + " items")
}
}