On this page
  1. tecs
  2. Module contents
    1. Submodules
    2. Constructors
    3. Types
    4. Functions
    5. Values
  3. Constructors
    1. newApplication
  4. Types
    1. Closeable
    2. Scope
  5. Functions
    1. scoped
  6. Values
    1. version

tecs

Module contents

Submodules

Submodule Description
tecs.Application The application lifecycle, entry plugin, frame, checkpoints, and crash state
tecs.Future Settle-once values, asynchronous composition, waiting, cancellation, and sequence tracking
tecs.assets Asynchronous byte, image, sound, and static glTF loading through futures
tecs.audio Clips, voices, groups, limits, entity sounds, snapshots, and audio devices
tecs.data Typed stores, JSON, byte encodings, DEFLATE, text transcoding, UTF-8, UUIDs, hashes, and checksums
tecs.ecs Worlds, entities, components, systems, plugins, queries, archetypes, phases, and resources
tecs.events Typed event definitions and address-based message buses
tecs.gfx 2D and 3D cameras, render components, meshes, the GPU renderer, images, shadows, and text
tecs.input Gameplay input in three tiers behind a layer stack, with gamepads and standalone sensors
tecs.io Binary I/O, nonblocking sockets, HTTP, files, and external tools
tecs.log Named loggers, priority filtering, platform output, and JSON Lines files
tecs.math Angle wrapping and shortest turns, with two-dimensional geometry beneath them.
tecs.physics Entity-first Rapier 2D rigid bodies, colliders, queries, contacts, sensors, and snapshots
tecs.platform Platform events, operating-system services, time, and windows
tecs.regex Compiled Rust regular expressions over Lua byte strings
tecs.runtime Process-wide polling for asynchronous work in applications and headless programs
tecs.sequence Snapshot-safe programs, waits, ownership, actions, and tween timelines
tecs.ui Retained layout, clipping, scrolling, and interaction for composed UI entities
tecs.workers Separate Lua states connected by serialized task and result channels

Constructors

Constructor Description
newApplication Builds the application an entry file returns.

Types

Type Kind Description
Closeable interface An owned value that releases its active lifetime explicitly.
Scope interface Scope owns resources while preserving each concrete type.

Functions

Function Kind Description
scoped Static Runs a callback inside a fresh resource scope.

Values

Value Type Description
version string Read-only. Version of this build.

Constructors

tecs.newApplication Static

Builds the application an entry file returns.

Not a function that runs until done: an entry file ends with return tecs.newApplication(config) and the host drives it from there, because a platform that never hands control back has no loop to block in.

function tecs.newApplication(
    config: Application.Config
): Application

Arguments

Name Type Description
config Application.Config Read here, so a field changed on the table afterwards is not seen. Nothing is opened yet: the window, the GPU device and the audio mixer are the host's to bring up on the first callback, which is what lets an entry file be loaded by a tool that never runs one.

Returns

Type Description
Application The application the host drives through its init, event, iterate and quit callbacks. Returning it is the whole contract; a game that calls into it itself is doing the host's job.

Types

tecs.Closeable interface

An owned value that releases its active lifetime explicitly.

close may report a delayed finalization failure. Every implementation returns true on success. Its own contract defines whether repeated calls are safe.

interface tecs.Closeable
    close: function(self): boolean, string
end

tecs.Closeable:close Instance

Releases the value's active lifetime.

function tecs.Closeable.close(self): boolean, string
Arguments
Name Type Description
self Closeable The value to close.
Returns
Type Description
boolean Returns true when finalization succeeds.
string Returns a finalization reason when the first return is false.

Examples

local destination <const> = tecs.io.newFileStream("save.bin")
local writer <const> = assert(destination:newWriter())

assert(writer:write("complete"))
assert(writer:close())
destination:close()

tecs.Scope interface

Scope owns resources while preserving each concrete type.

interface tecs.Scope
    own: function<T is Closeable>(self, value: T, reason: string): T
end

tecs.Scope:own Instance

Registers one owned value for cleanup and returns it unchanged.

The scope is active only inside the callback passed to scoped. Calling a captured scope after that callback returns, raises, or begins cleanup raises instead of creating an ownership obligation nobody will run. Passing nil raises with reason when one is supplied, which lets a constructor's value, reason result pass directly to own. Without a supplied reason, or with a value that has no close method, own raises its own argument error.

function tecs.Scope.own<T is Closeable>(
    self, value: T, reason: string
): T
Type Parameters
Name Constraint Description
T Closeable
Arguments
Name Type Description
self Scope The active scope that will own the value.
value T An open Closeable or Lua file. Each call adds one cleanup obligation, including repeated calls with the same value.
reason string The operational failure returned beside a nil value. own raises this string at the call site.
Returns
Type Description
T The same value with its concrete type unchanged.

Functions

tecs.scoped Static

Runs a callback inside a fresh resource scope.

The callback runs synchronously and must not yield. Every value it registers closes in reverse order before this function returns or propagates a failure. Cleanup begins by making the scope inactive, and one failing close does not prevent the remaining closes.

function tecs.scoped(body: function(Scope))

Arguments

Name Type Description
body function(Scope) The callback that receives the only active Scope for this invocation. Returned values are ignored, and registered resources must not be used after the callback ends.

Returns

None.

Values

tecs.version variable

Read-only. Version of this build.

tecs.version: string