Skip to Content
Modlock

Testing

Try a mod in seconds without the game, and test a whole round in it.

In the sandbox

On macOS, or on any computer without Deadlock, modlock dev runs your mod in the sandbox. The sandbox has the same runtime and limits as a server, and one stand-in player with no hero. When you type /hello and press Enter, the sandbox sends it as that player's chat. The terminal shows your mod's log and everything it sends to players. Calls that need the game, such as reading a hero's position, return nothing.

The preview page at http://127.0.0.1:4322/ draws the screens your mod shows that player, as the game would. On the page you can press their buttons, send chat commands and pick a screenshot of the game as the backdrop. The page also shows a build in progress, a failed build's errors, and why a mod stopped.

FlagDoes
--sandboxUses the sandbox even where the game is installed.
--preview-portServes the page on another port, or turns it off with 0. When another program holds the port, the page takes a free one and the terminal prints its address.

In a Python mod, the sandbox also runs a terminal line that starts with > as Python inside the running mod. See Python.

You can test game rules that make no calls into the game with plain go test, as the race example does.

In the game

To test a whole round in the game, build the test into the mod. Started with modlock play --arg probe, the mod seats bots with addBot and plays the round. The mod then checks the outcome, logs PASS or FAIL and quits with serverCommand('quit'), as examples/arena does.

In TypeScript, ProbeRun keeps track of the probe's steps. Call tick on each frame with the step the probe waits on and a check. The check returns true to pass, a message to fail, or false to keep waiting. ProbeRun logs each new step once and fails the run when its timeout passes. Then it logs <name> probe PASS or FAIL and quits:

const run = new ProbeRun('Duel', 120)
onFrame((frame) => {
  run.tick(frame.timeSeconds, 'two fighters', () => fighters() >= 2)
})

On this page