Call a Module
Put a helper file under scripts/.
// scripts/math_helpers.aeo
fn add(a, b) {
return a + b
}
Load it from another script:
const helper = scripts.math_helpers.aeo
debug.log(helper.add(10, 20))
Different Module files keep separate state. Reusing the same Module path reuses its state for the current game session.
Attach a Module to an Actor
Attach the script under the Actor in the project hierarchy. Inside the attached Module, self.parent is that Actor.
const actor = self.parent
actor.on_touch = fn(thing) {
debug.log("Touched by:", thing)
}
The same file attached to two Actors keeps separate state for each Actor. A standalone Module has no Actor parent; reading self.parent there reports an error.
Player Modules
Files in playerscripts/ attach to the Player. Use player.controller or player.find("Inventory") to reach them. There is no playerscripts language namespace.
Waiting in attached Modules [BETA]
Attached Modules can pause and resume while keeping their Actor parent. This behavior is repaired in the v0.8.1 development series. For lookup details, see the Project and Module reference.