Skip to Content
Modlock

The world

Place text, models and effects, and load what they need.

Each call on this page places something in the world, such as text, a model, an effect or fog, and returns an object you can move, change or remove later. Loading a new map, stopping the mod or reloading it removes every object the mod placed.

Place text

import { createText } from 'modlock'

const label = createText({
  text: 'START',
  position: { x: 0, y: 0, z: 200 },
  fontSize: 96,
  faceCamera: true,
})
label?.setText('GO!')
label?.move({ x: 0, y: 0, z: 260 })
label?.remove()
local label = modlock.createText({
	text = "START",
	position = { x = 0, y = 0, z = 200 },
	fontSize = 96,
	faceCamera = true,
})
if label then
	label:setText("GO!")
	label:move({ x = 0, y = 0, z = 260 })
	label:remove()
end
label = modlock.create_text(
    modlock.TextOptions(
        text="START",
        position=modlock.Vector(0, 0, 200),
        font_size=96,
        face_camera=True,
    )
)
if label is not None:
    label.set_text("GO!")
    label.move(modlock.Vector(0, 0, 260))
    label.remove()
size, faceCamera := float32(96), true
label, err := mod.CreateText(&mod.TextOptions{
	Text:       "START",
	Position:   &mod.Vector{Z: 200},
	FontSize:   &size,
	FaceCamera: &faceCamera,
})
if err == nil {
	_ = label.SetText("GO!")
	_ = label.Move(&mod.Vector{Z: 260}, nil)
	_ = label.Remove()
}

Load heroes and resources

When your mod starts, precache the heroes, models and effects your mode uses. The game loads them with the next world, and one it has not loaded shows nothing the first time your mod uses it.

import { onStart, precache } from 'modlock'

onStart(() => {
  precache({ heroes: ['hero_atlas', 'hero_haze'] })
})
modlock.onStart(function()
	modlock.precache({ heroes = { "hero_atlas", "hero_haze" } })
end)
@modlock.on_start
def load(args: list[str]) -> None:
    modlock.precache(modlock.PrecacheOptions(heroes=["hero_atlas", "hero_haze"]))
mod.OnStart(func([]string) {
	_ = mod.Precache(&mod.PrecacheOptions{Heroes: []string{"hero_atlas", "hero_haze"}})
})

Forget objects when the world changes

When a new world loads, the game has already removed everything your mod placed. In your world event handler, drop your references to the old objects and place them again.

Every call

Python spells each call in snake_case, and Go capitalizes it. Dropper is TypeScript only.

CallEffect
createText, createModel, createParticlePlace text, a model or an effect to move, change or remove later.
createFog({ position, mins, maxs, strength, color })Fill a box with tinted fog. Tile boxes to darken all but one area.
precache({ heroes, resources })Load heroes and resources with the next world.
serverCommand(line)Run a line at the server console, within its limits.
moveEntityMove an entity.
pushEntitySet or add to an entity's velocity.
emitSoundPlay a sound on an entity.
modifierState(entity, state), holdModifierStateTest or hold a modifier state on an entity.
silenceVoice(concepts), player.silenceVoiceKeep every hero, or one, from speaking the listed voice concepts.
giveEntityModifier, holdEntityModifierGive or hold a modifier on a live entity, such as an NPC.
readField, writeField, entityClassRead or write any schema field of a live entity, or read its class; see Entities.
loadSpot(spot)Place a spot on the running map.
encodeSpot, decodeSpotSave a spot, or restore a saved one.
new Dropper(catalog, spot)Let players build a spot while they play.

Spots

A spot is a base map plus the solid objects players placed on it. examples/dropper builds a spot on Midtown. /build opens the catalog, and every player drops into the same spot. The document at mod/spot/spot.proto stores a spot with each model path and builder written once, so a few hundred objects fit in a few kilobytes.

On this page