game

Read the visible players and mobs, the local player position and project world positions to the screen. It lives at xiao.game.


Functions

xiao.game.players(): entity[]

xiao.game.players(): entity[]

  • Returns an array of entities for the visible players.

xiao.game.entities(): entity[]

xiao.game.entities(): entity[]

  • Returns an array of entities for the visible mobs.

xiao.game.local_player(): vector3 | nil

xiao.game.local_player(): vector3 | nil

  • Returns a vector3 of the local player position, or nil.

xiao.game.world_to_screen(point: vector3): vector2 | nil

xiao.game.world_to_screen(point: vector3): vector2 | nil

  • Returns a vector2 on screen, or nil when behind the camera.

xiao.game.world_to_screen(x: number, y: number, z: number): vector2 | nil

xiao.game.world_to_screen(x: number, y: number, z: number): vector2 | nil

  • Same as the point form, with the coordinates given separately.

xiao.game.time(): number

xiao.game.time(): number

  • Returns the seconds since the system started.

Types

entity

Field Type Description
id number runtime id
name string entity name
x number x position
y number y position
z number z position
position vector3 position as a vector3
health number present when known
max_health number present when known

Example

local paint = xiao.paint
local gold = paint.color.hex("#F0C250")
paint.add("names", function(w, h)
    for _, player in ipairs(xiao.game.players()) do
        local head = paint.point.vector3(player.x, player.y + 2, player.z)
        paint.text.center(head, player.name, gold, paint.color.rgb(0, 0, 0))
    end
end)