API overview
FilaSignal adds functions, device objects, events and constants to FilaScript. Everything here is
generated from the mod’s own definitions, so signatures, errors and events match what programs run with. The
language built-ins, such as print, str and json, are available too.
Two kinds of programs
Section titled “Two kinds of programs”| Computer program | Drive program on a device | |
|---|---|---|
| Written in | the computer’s editor | the editor, on a drive |
| Uses devices | any device of its network, by name | only its own device, as device |
| Other devices | full access through device constants | events only, plus Storage Server storage |
| Own storage | globals | globals and the drive’s storage |
| Network functions | devices.list(), drives.from(...), older port functions |
none |
Each reference entry lists the capability it needs. The execution page lists which program holds which capabilities.
Results and errors
Section titled “Results and errors”Most device functions can fail for reasons outside the program: the device may be unloaded, renamed or out of range. They return two values, the result and an error. FilaScript gives you three ways to use them:
const gate = detectors.named("gate")
on timer.every(100) { // 1. As one value: the result, or the handler stops with the device's explanation. hostiles = gate.count(Entity.HOSTILE)
// 2. On its own line: a failure prints a warning and the handler continues. gate.scan(Entity.PLAYER)
// 3. Both values: handle the failure yourself. players, err = gate.count(Entity.PLAYER) if err is not nil { print("Detector problem: " + err.code) return } print(str(hostiles) + " hostile, " + str(players) + " players")}An error has code, such as device.unavailable, and message. The codes are listed in error codes.
A nil result with a nil error is a normal answer, for example nearest() when nothing is near.
Programming mistakes, such as passing a number where a name is needed, are not returned: they stop the handler with
TYPE_MISMATCH or ARGUMENT_COUNT.
Reading the reference
Section titled “Reading the reference”Each entry shows the call, what it does, its parameters with their accepted types, what it gives back, the error codes it can return, the capability it needs and its cost in operations against the handler’s budget of 10,000. Device calls also add a lookup cost. Examples come from the mod’s own metadata.