-
Notifications
You must be signed in to change notification settings - Fork 1
Headless Export
Chromatischer edited this page Jan 9, 2026
·
1 revision
The simplest way to export images from the command line.
cd /path/to/stormworks.nvim
./bin/stormworks-export \
--script my_script.lua \
--output output.pngAdd the bin directory to your PATH:
export PATH="/path/to/stormworks.nvim/bin:$PATH"Or create a symlink:
ln -s /path/to/stormworks.nvim/bin/stormworks-export /usr/local/bin/stormworks-export [options]-
--script <path>- Path to microcontroller script -
--output <path>- Output image path
-
--ticks <N>- Number of ticks to run (default: 1) -
--capture <which>- "debug", "game", or "both" (default: "debug") -
--format <fmt>- "png" or "jpg" (auto-detected from extension) -
--inputs <spec>- Inline inputs:"B1=true,N1=0.5,N2=123" -
--inputs-file <path>- JSON file with inputs -
--outputs-file <path>- Write outputs to JSON file -
--result-file <path>- Write result to JSON file -
--tiles <WxH>- Screen tile dimensions (e.g., "3x2") -
--debug-canvas-size <WxH>- Debug canvas size (e.g., "512x512") -
--props <spec>- Properties:"key=val,key2=val2" -
--help- Show help message
stormworks-export \
--script test.lua \
--output debug.pngstormworks-export \
--script autopilot.lua \
--output autopilot.png \
--ticks 60 \
--inputs "B1=true,N1=45,N2=100"stormworks-export \
--script display.lua \
--output game.png \
--capture game \
--tiles 3x2stormworks-export \
--script test.lua \
--output result.png \
--capture both
# Creates: result_game.png and result_debug.pngstormworks-export \
--script test.lua \
--output debug.png \
--debug-canvas-size 800x600stormworks-export \
--script test.lua \
--output output.png \
--result-file result.json
cat result.json | jq .The command outputs JSON to stdout:
{
"success": true,
"image": "/tmp/output.png",
"images": ["/tmp/output.png"],
"ticks_run": 10,
"outputs": {
"B": {"1": true},
"N": {"3": 42.5}
},
"errors": [],
"exit_code": 0
}Extract JSON result:
result=$(stormworks-export --script test.lua --output out.png 2>&1 | grep -E '^\{')
echo "$result" | jq .
# Check if successful
success=$(echo "$result" | jq -r '.success')
if [ "$success" = "true" ]; then
echo "Export succeeded!"
fi
# Get output path
image=$(echo "$result" | jq -r '.image')
echo "Image saved to: $image"#!/bin/bash
for script in scripts/*.lua; do
name=$(basename "$script" .lua)
echo "Exporting $name..."
stormworks-export \
--script "$script" \
--output "output/${name}.png" \
--ticks 1 2>&1 | grep -E '^\{' | jq -c .
done-
0- Success -
1- Error (check stderr or JSON result for details)
Command not found:
- Make sure the
bindirectory is executable:chmod +x bin/stormworks-export - Add to PATH or use full path
Export fails:
- Check the JSON output for error details
- Use
--result-fileto save full result - Check stderr output:
2>&1 | tee output.log
If you prefer not to use the wrapper script:
nvim --headless --noplugin -u NONE \
-S /path/to/stormworks.nvim/bin/stormworks-export.vim -- \
--script test.lua \
--output output.png 2>&1 | grep -E '^\{'