Skip to content

Types

The function passed to usems.register_command. Invoked by the engine whenever a player runs your command, once per dispatch.

type CommandCallback = (...args: string) -> ()

Arguments are the console arguments after the command name, in order.

usems.register_command("my_give", function(item, count)
-- console: my_give cubecar 3
print(("give %s x%s"):format(item, count)) --> give cubecar x3
end, 0, "Give an item")

The function passed to usems.hook("frame", ...). Called every rendered frame inside Source’s HudUpdate.

type FrameHookCallback = (dt: number) -> ()

dt is frametime in seconds, read live from the engine’s gpGlobals.

usems.hook("frame", function(dt: number)
-- integrate anything time-based:
elapsed += dt
end)

The function passed to usems.hook("tick", ...). Called once per server tick inside GameFrame — 66/s in single-player, fixed regardless of frame rate.

type TickHookCallback = () -> ()
usems.hook("tick", function()
-- fixed-rate simulation logic:
sim_steps += 1
end)

The parsed mod.toml, as consumed by the loader (see Package Format). Scripts never see this table directly — it’s shown here because usems.mod_name mirrors its name field and validation errors reference these field names.

Field Type Rules
id string 1–64 chars [a-z0-9_.-], starts alphanumeric; unique across packages.
name string 1–128 chars.
version string 1–128 chars, free-form.
author string 1–128 chars.
language string "luau" today; others parsed but skipped.
entry string Normalized relative path, inside the package, .luau for Luau.
enabled boolean Optional, default true.

How print renders each Luau type:

Type Renders as
string unquoted text
number (integral) 42
number (fractional) 0.66666666666667
boolean true / false
nil nil
table <table>
function / thread <function>
userdata <userdata>
vector <vector>
error values <error: message>

These arrive with the entity/reflection tiers of Phase 7 and will get their own pages as they land:

  • Vector, QAngle, Quaternion, VMatrix — Source math types, native where Luau provides them (vector) and bridged where not
  • CBaseEntity and the class hierarchy — entity handles with datamap field access
  • EHandle<T> — safe entity references across frames
  • trace_t, Ray_t — trace results and inputs for util::TraceLine-style functions
  • ConVarRef — live reference to any engine cvar (not just USEMS-registered ones)
  • GameEvent — event fields, listen/fire