Prism

The prism module contains the core engine and commonly used utilities. Its classes and functions can be accessed from the prism global, e.g. prism.Level.

Registries

Registries get automatically loaded by prism.loadModule(). They hold all of the game objects, making them easy to access, e.g. prism.actors.Player().

  • prism.actors: table<string, fun(...): Actor>

    The actor registry.

  • prism.actions: table<string, Action>

    The actions registry.

  • prism.components: table<string, Component>

    The component registry.

  • prism.cells: table<string, fun(...): Cell>

    The cell registry.

  • prism.targets: table<string, fun(...): Target>

    The target registry.

  • prism.messages: table<string, Message>

    The message registry.

  • prism.systems: table<string, System>

    The system registry.

  • prism.decisions: table<string, Decision>

    The decision registry.

  • prism.schedulers: table<string, Scheduler>

    The scheduler registry.

Functions

  • prism.loadModule(directory: string)

    Loads a module into prism, automatically loading objects based on directory. Will also run module/module.lua or module/init.lua for any other set up.

    Parameters:

    directory (string) – The root directory of the module.

  • prism.registerActor(name: string, factory: fun(...): Actor)

    Registers an actor factory into the actors registry.

  • prism.registerCell(name: string, factory: fun(...): Cell)

    Registers a cell factory into the cells registry.

  • prism.registerTarget(name: string, factory: fun(...): Target)

    Registers a target factory into the targets.

  • prism.register(object: Object)

    Registers an object into its registry. Errors if the object has no registry.

  • prism.registerRegistry(
        name: string,
        type: Object,
        factory?: boolean,
        module?: string
    )

    Registers a registry, a global list of game objects.

  • prism.advanceCoroutine()

    Runs the level coroutine and returns the next message, or nil if the coroutine has halted.

Core systems

Math & algorithms

  • alias PassableCallback = fun(x: integer, y: integer, mask: Bitmask)

Functions

  • prism.Ellipse(
        mode: ("fill" | "line"),
        center: Vector2,
        rx: integer,
        ry: integer,
        callback?: PassableCallback
    )

    Generates points for an ellipse on a grid using the Vector2 class.

    Parameters:
    • mode (("fill" | "line")) – Whether to fill the ellipse or just an outline.

    • center (Vector2) – The center of the ellipse.

    • rx (integer) – The radius on the x axis.

    • ry (integer) – The radius on the y axis.

    • callback? (PassableCallback) – An optional callback to determine passability.

  • prism.Bresenham(
        x0: integer,
        y0: integer,
        x1: integer,
        y1: integer,
        callback: PassableCallback
    )

    Generates points for an ellipse on a grid using the Vector2 class.

    Parameters:
    • x0 (integer) – The x coordinate of the first point.

    • y0 (integer) – The y coordinate of the first point.

    • x1 (integer) – The x coordinate of the second point.

    • y1 (integer) – The y coordinate of the second point.

    • callback? (PassableCallback) – An optional callback to determine passability.