Stormworks: Build and Rescue Wiki

This article is a stub. You can help Stormworks: Build and Rescue Wiki by expanding it.

Lua Programming

Lua Programming   [ edit page ]

Lua in Stormworks

Lua programming in Stormworks is done inside microcontrollers. "Lua Script" is a logic component like every other, it has 2 inputs (composite and video) and 2 outputs (composite and video). The lua script can draw stuff onto the video feed and it can read and write composite values. These two functionalities are also split in the code, all the video related stuff is done inside the "onDraw()" function while all composite related stuff is done inside the "onTick()" function.

Programming Lua in Stormworks comes in with some special rules:

  • each lua script component can contain a maximum of 4096 characters of Lua code
  • only basic Lua libraries are supported: pairs, ipairs, next, tostring, tonumber, math, table, string

Additonally there are functions you can call to draw onto the video or interact with the composite input and output:

  • screen.drawXxx() functions
  • functions to manipulate a drawn minimap
  • functions to read input composite
  • functions to read values from properties in this microcontroller

Stormworks offers some code examples and documentation for all functions in the lua code editor (visible when you edit a Lua script component), but you should already have a basic knowledge of programming (any language).



Learn Lua

If you have no experience in programming learn Lua here:

MrNJersey offers some tutorial videos:

Special Lua Editors

CrazyFluffyPony offers a website where you can develop Lua code for Stormworks. It behaves 99% like in Stormworks and makes developing code easier.

Stormworks VSCode Extension

For Windows users wanting a full development environment with additional features: - A full debugger - Intellisense and error handling - Code libraries and ability to work across multiple files - Accurate, Multi-Monitor, Stormworks Simulator - Powerful build chain and Minimizer

Please look at the Stormworks VSCode Extension:

(Or download VSCode and search "stormworks" in the extensions tab)


Alternatively you can download ZeroBrane, a Lua IDE for Windows, Mac and Linux. Just be aware that its made for general Lua programming and not specialised for Stormworks.