Skip to content

Audio and sprites

Play your own sounds and look up your own sprites. Client only.

client

Plays a sound from your audio/ folder, by file name without extension. It plays only in the client VM; on the server the call does nothing, so it is safe in a handler that runs in both. A missing sound does nothing. A file named like one of the game’s own sounds replaces that sound.

Parameter Type
name string File name without .ogg / .wav.
options table? volume 0 to 1 (default 0.6), pitch 0.25 to 4, pan -1 to 1.

Raises

  • name must be text
mod.on("weapon_landed", function()
mod.audio.play("boom", { volume = 0.8, pitch = 0.9 })
end)

client

True if your mod ships that sound.

Parameter Type
name string File name without extension.

Returns boolean

if not mod.audio.has("boom") then mod.warn("audio/boom.ogg is missing") end

client

A PNG of your own in sprites/ (64x64 at most). Sizes are filled in once the game has started: 0 before that and on the server. Draw it with g.sprite.

Parameter Type
name string File name without .png.

Returns { name, w, h } or nil

Raises

  • name must be text
local icon = mod.sprite("flare")
if not icon then mod.warn("sprites/flare.png is missing") end