Skip to content

game

Main top-level module. Provides access to most of the API. Available as the global variable game.

Fields

Functions

  • spawn_unit (unit: string, position: vector, team: Team, source: Entity?) -> Unit

    Spawns a new unit based on the provided unit definition. […]

  • spawn_projectile (spawn: SpawnProjectile) -> Unit

    Spawns a new projectile based on the provided projectile definition. […]

enums: Enums

See Enums

steering: SteeringBehaviors

game.spawn_unit(unit: string, position: vector, team: Team, source: Entity?) -> Unit

Spawns a new unit based on the provided unit definition.

Parameters

  • unit Required string

    The path of the unit definition file.

  • position Required vector

    The position to spawn the unit at. The z value will be ignored.

  • team Required Team

    The team of the unit.

  • source Optional Entity?

    The entity that spawned this unit.

Returns

  • The newly spawned unit.

game.spawn_unit("units/skeleton.unit.ron", vector.zero, game.enums.Team.player)

game.spawn_projectile(spawn: SpawnProjectile) -> Unit

Spawns a new projectile based on the provided projectile definition.

Parameters

{ projectile: string, position: vector } & ({ direction: vector } | { target: Unit }) & { team: Team, source: Entity? }

A table with the following fields:

  • projectile Required string

    The path of the projectile definition file.

  • position Required vector

    The absolute position to spawn the projectile at. The z value will be ignored.

  • Either:
    • direction Required vector

      The direction vector of the projectile. Will be normalized.

    • target Required Unit

      The target of the projectile.

  • team Required Team

    The team the projectile will belong to. Used for projectile abilities that find targets, and for projectiles that have collision filters.

  • source Optional Entity?

    The entity that spawned this projectile.

Returns

  • The newly spawned projectile.

game.spawn_projectile({
projectile = "projectiles/fireball.projectile.ron",
position = unit.position,
direction = vector.create(1, 0)
})