Scripting reference
The functions you will use most, by topic. Prefabs shows how they fit together. This page is the lookup.
In an object script boz is already there. In main.lua and other files, start with:
local boz = require("boz")
The basics
| Call | What it does |
|---|---|
log(...) |
Writes to boz-log.txt and the editor's Log area |
boz.get(name) |
The object with that name, as its class. A part is "Prefab.Part". |
boz.all(class) |
Every object of a class: boz.all(boz.Perk) |
boz.player() |
You |
boz.players() |
Every player in the match, including the other players in co-op |
boz.on(name, fn) |
Calls fn(data, name) on a game event or a boz.send |
boz.send(name, data) |
Sends an event to every boz.on and every on_event |
boz.after(seconds, fn) |
Runs fn once, later |
boz.every(seconds, fn) |
Runs fn again and again; :cancel() stops it |
boz.saved |
A table all scripts share, kept in saved games |
for _, perk in ipairs(boz.all(boz.Perk)) do
perk.settings.cost = 500
end
Positions are tables {x = 0, y = 100, z = 0} in centimetres, with y up.
Objects
Anything from boz.get, and self in a script. The full list, with examples, is
What every object has.
| Call | What it does |
|---|---|
.name, .kind, .settings |
Its name, "model"/"volume"/"prefab"/"zone"/"sector", and its settings |
class_name(), is_a(class) |
Its class |
part_name(), parent(), part(name), parts() |
Prefabs and their parts |
position(), rotation(), near(target, cm), exists() |
Where it is |
visible(), show(), hide(), set_visible(on) |
Visible |
blocks_walking(), set_blocks_walking(on) |
Walking |
stops_bullets(), set_stops_bullets(on) |
Stops bullets |
links(name), linked_from(name) |
Links |
on(event, fn), send(name, data) |
Events |
move_to(place, options), move_by(offset, options) |
Moves it, at once or over seconds (Moving and turning) |
turn_to(degrees, options), turn_by(degrees, options) |
Turns it about the vertical axis |
set_position(position), set_rotation(degrees), moving(), stop() |
Puts it somewhere at once; whether it glides; stops a glide |
play_animation(state), bone_position(bone) |
An animated object: plays one of its animation states; where a bone is |
Volumes add type(), set_off_by(), once(), used(), prompt(), set_prompt(text), cost() and
set_cost(points). Each game prefab's own methods are on Game prefabs.
Players
Get one with boz.player(), or from a hook's player argument.
| Call | What it does |
|---|---|
points() |
Points the player has |
give_points(n) |
Gives points; a negative number takes them |
spend(n) |
Takes points if the player has enough; returns true when paid |
health(), set_health(n) |
Health |
set_god(on), god() |
No damage |
give_perk(name), take_perk(name), has_perk(name), perks() |
Perks |
give_weapon(name), take_weapon(name), weapon() |
Weapons. The new weapon goes in hand. |
position() |
Where the player is (eye height) |
teleport(place, options) |
Moves the player. On an object they stand on it, facing its way (a prefab of yours: where it is placed); a position is eye height, like position(). Options: via (an object to stop over at first, held still with their view fixed, as in the game's wormhole), seconds (the stop-over, 2: the game's wormhole time), effect (the teleport flash, true), done(player) (runs on arrival). |
zone(), sector() |
The zone and sector the player is in, or nil |
movement(), set_movement(on, look) |
Off holds the player where they stand. With look false their view is held too. |
downed(), kill() |
Down in last stand, or killed |
stance(), set_stance(name) |
"standing", "crouching", "prone", "downed" |
speed(name), set_speed(name, value) |
A movement speed, like "SprintSpeed" |
stat(name), add_stat(name, n) |
A stat, like "STAT_ZOMBIESKILLED" |
message(text, seconds) |
A line of text on the screen |
is_local() |
True for you, false for another player in co-op |
local player = boz.player()
if player:spend(1000) then
player:give_perk("Juggernog")
player:set_speed("SprintSpeed", 1.5)
end
Zombies
| Call | What it does |
|---|---|
boz.zombies(kind) |
The zombies alive. kind is "zombie", "dog", "monkey" or "all". |
boz.spawn_zombie(spec, position, options) |
Spawns one. spec is "zombie", "zombie_dog", ... Options: health, speed. |
boz.lure(place, options) |
Pulls zombies to a position or an object, like a monkey bomb. Options: seconds (0: until stop()), zombies (0: all, else the nearest that many), radius (cm), arrive ("wait" or "attack"). Returns the lure: stop(), running(), zombies(). |
A zombie that just died stays in the list for a moment, with 0 health.
Each zombie has .zombie (always true, to tell it from a player in a volume's hooks), and:
| Call | What it does |
|---|---|
kind(), alive() |
What it is, and whether it is still in the match |
position(), teleport(position) |
Where it is |
health(), max_health(), set_health(n) |
Health |
damage(n), kill() |
Hurts or kills it. The kill counts for the player. |
set_speed(tier) |
"walk", "walk_fast", "run" or "sprint" |
freeze(), burn(), explode(), lightning(), gersch(), shockwave() |
The game's weapon effects |
boz.on("round_started", function(data)
if data.round == 5 then
boz.spawn_zombie("zombie", boz.get("Boss_Spot"):position(), {health = 5000, speed = "sprint"})
end
end)
for _, zombie in ipairs(boz.zombies("dog")) do
zombie:freeze()
end
Rounds
| Call | What it does |
|---|---|
boz.round() |
The round number |
boz.start_round(n) |
Goes to a round |
boz.rounds.zombies_left() |
Zombies still to kill this round |
boz.rounds.alive() |
Zombies alive now |
boz.rounds.powered() |
True once the power is on |
boz.rounds.special() |
True during a dog or monkey round |
boz.rounds.set_spawning(on) |
Stops or starts spawning |
boz.rounds.start_next() |
Starts the next round |
boz.rounds.set_wave(field, value) |
Changes the running round, such as "m_ZombieHealth" |
| boz.end_match(options) | Ends the match with the game's game over and results. {win = true}: scripts hear match_ended with win = true. |
To shape a map's rounds as a whole, use the Game tab. boz.rules reads
what it set:
| Call | What it does |
|---|---|
boz.rules.mode() |
The mode being played: "easy", "normal", "hard", "coop2", "coop3" or "coop4" |
boz.rules.mode_names() |
Every mode, in that order |
boz.rules.round_set(mode) |
The round set a mode plays (default: this one; "": the base map's own) |
boz.rules.sets() |
The map's round set names |
boz.rules.modes() |
Each mode's {set, zombies, health} from the Modes table |
Zones and sectors
boz.get gives a zone by its zone name, as a boz.Zone:
| Call | What it does |
|---|---|
open() |
Opens it, as a door that opens it would. False when it was open already. |
close() |
Closes it: its spawns aren't used until it opens again. False when it was closed. |
is_open(), starting() |
Whether its spawns are used, and whether it's the starting zone |
spawns(), doors() |
Its zombie spawns, and the doors and debris that open it |
contains(target), players() |
Whether a position or object is inside it, and the players in it |
position() |
The middle of its first box |
Events: opened, closed, enter(player) and exit(player). Every script also hears the game
events zone_opened and zone_closed, with zone, its name.
local cellar = boz.get("Cellar")
cellar:on("enter", function(zone, player)
player:message("It's cold down here")
end)
boz.on("zone_opened", function(data)
log(data.zone .. " is open")
end)
A sector is a boz.Sector, by its name:
| Call | What it does |
|---|---|
contains(target), players() |
Whether a position or object is inside it, and the players in it |
drawn() |
True when the game drew it this frame |
position() |
Its middle |
Events: enter(player) and exit(player). boz.sectors.set_culling(false) draws every sector in
view, ignoring portals, to compare against; boz.sectors.culling() says which is on.
Systems
Each one is ready as boz.<name>.
boz.hud
boz.hud.message("The power is on", 3)
boz.hud.hide("Clip_Label")
boz.hud.show("Clip_Label")
boz.hud.ELEMENTS lists the names.
boz.audio
boz.audio.play("my_sound") -- everywhere
boz.audio.play("gersch_opens", self:position()) -- at a place
boz.audio.sequence("dog_wave_start") -- a voice line or sting
boz.audio.music("115.mp3", {loop = true})
boz.audio.music_volume(0.5)
See Sounds for finding names and adding your own.
boz.effects
Effects and projectiles, yours from the Effects tab or the game's.
| Call | What it does |
|---|---|
spawn(name, position, options) |
An effect. Options: lifetime (seconds), rotation. Returns it. |
projectile(name, position, options) |
A projectile, flying on its own (trigger, lifetime, hidden, freeze). |
explode(position, options) |
An explosion: radius, inner, damage, min_damage. |
attach(name, target, options) |
An effect that follows an object, an entity, or "weapon" (the gun in hand). Options: bone (e.g. "tag_flash"), offset, lifetime. |
detach(effect) |
Stops it following (it stays where it is). |
effect:set(settings) |
Changes it while it plays: scale, rate = {min, max}, velocity, spread, position, duration, spawning. |
effect:remove(), effect:alive(), effect:position() |
The effect itself |
boz.effects.spawn("frost", self:position(), {lifetime = 3})
boz.effects.attach("frost", "weapon", {bone = "tag_flash"})
boz.effects.explode(self:position())
Your projectiles and effects can have scripts of their own (boz.Projectile, boz.Effect). See
Effects and projectiles.
boz.pickups
boz.pickups.spawn("max_ammo", self:position()) -- drops one
boz.pickups.give("insta_kill") -- as if collected
Names are in Events.
boz.camera and boz.screen
boz.camera.set_fov(90)
boz.camera.shake("romero-transform-shake")
boz.screen.effect("nuke") -- a full-screen flash
boz.screen.fog("Monkeys") -- a fog setting
boz.input
Works with the game's actions, whatever keys the player bound: shoot, aim, reload, use,
melee, grenade, tactical, crouch, fire_mode, switch_weapon.
boz.input.on_action("melee", function(down)
if down then log("knife") end
end)
boz.input.send("reload")
For keys, use the client's input.bind("F5", fn) (Script mods).
boz.console and boz.cvars
The game's own settings and cheats (Console reference):
boz.console.set("WeaponsUnlimitedAmmo", true)
log(boz.console.get("WalkSpeed"))
boz.console.exec("SwitchPowerOn")
boz.menu
Rows in the pause menu's Settings page (example):
boz.menu.add_checkbox{
id = "hard_mode",
label = "Hard mode",
get = function() return settings.get("hard_mode", false) end,
set = function(on) settings.set("hard_mode", on) end,
}
boz.text
Your own text for the game's menus and prompts: boz.text.add(id, value).
boz.stats
log(boz.stats.get("STAT_ZOMBIESKILLED"))
boz.stats.add("STAT_HEADSHOTS", 1)
boz.stats.unlock("BOGravity")
boz.weapons
The player's weapons by name: give, take, upgrade, refill, owned, current.
boz.weapons.give("mp40")
boz.weapons.upgrade("mp40")
boz.weapons.refill("mp40")
boz.weapons.current() is the weapon in hand, with:
| Call | What it does |
|---|---|
play(clip, blend), stop_animation() |
Plays one of its animations, such as a clip you added in the Weapons tab |
projectile(), set_projectile(name) |
The projectile it fires |
entity() |
The gun model in hand (for boz.effects.attach and bones like tag_flash) |
set_ammo(clip, reserve), set_fire_rate(rpm), set_damage(head, torso, limbs) |
Its values while it's in hand |
| Call | What it does |
|---|---|
boz.weapons.replace_animation(weapon, state, clip or fn) |
Plays another clip instead of one of the game's (a reload, for example). |
boz.weapons.set_fires_projectile(weapon, on) |
Every shot launches its projectile instead of bullets. |
boz.charge(weapon, options) |
A charged shot: hold fire to charge, release to fire. Options: levels ({projectile, after, ammo} each), effect, bone, clip, sound, max, and on_start, on_level, on_fire. |
boz.charge("ice_rifle", {
levels = {{projectile = "ice_bolt"}, {after = 1.2, projectile = "ice_blast", ammo = 3}},
effect = "frost", bone = "tag_flash", clip = "charge", max = 3,
})
boz.animation
Animated objects and characters: play(entity, state, blend), stop(entity), state(entity),
view_model() (the gun model in hand), bone_position(entity, bone), and on_play(fn), which
can swap the state the game is about to play for another. Objects have play_animation(state) and
bone_position(bone) too.
boz.net
Your own messages between the games in a co-op match: boz.net.send, boz.net.on,
boz.is_host() and boz["local"](fn). See Scripts in co-op.
boz.online
Online play: server() (the server the player chose in the launcher, "" when it's off),
check(host, fn) and connected(). Players choose the server in the launcher's
Settings → Online; set_server no longer does anything. See the
network module.
boz.map
The level: boz.map.set_time_scale(0.5), boz.map.toggle_pause(), boz.map.playing().
boz.fly and boz.deadops
boz.fly.set(true) turns noclip on. boz.deadops is for the Dead Ops mini-game.
Classes of your own
boz.class is what every class here is built on. You can use it for your own helpers:
local Counter = boz.class:extend("Counter")
function Counter:init(limit)
self.count, self.limit = 0, limit
end
function Counter:add()
self.count = self.count + 1
return self.count >= self.limit
end
local kills = Counter:new(10)
Your own effects and projectiles are classes too: a projectile's script extends
boz.Projectile, an effect's extends boz.Effect (Scripts for effects and
projectiles).
Advanced
Below all this is boz.engine.*: require("boz.engine.reflect") reaches every field of the
game's data, require("boz.engine.entities") every entity, and
require("boz.engine.game_events") the low-level events. Each file in the SDK's
lib/boz/engine starts with a short description. Most mods never need them.
GitHub ↗