Tutorials:XML to Lua

Themers who have worked inside StepMania "3.95"/4.0 betas and final/OpenITG have gotten quite familiar with XML. However, StepMania 5.0 (and sm-ssc) drops XML in favor of Lua. For those themers who know XML, Lua may seem daunting, but in reality, Lua is actually not that different from XML. Generally, tags are replaced with their Lua equivalents, and commands are wrapped in.

Conversion Guides
This section contains examples of commonly used theme elements in both XML and Lua.

General Notes
In XML, everything is wrapped in tags. In Lua, everything is contained within curly braces:. This is explained further in ActorFrame.

Commands have slightly changed as well:
 * XML:
 * Lua (simple):

The command syntax itself hasn't changed, so the same commands from StepMania 3.9 onward work in SM4 (with a few differences for certain commands). Do note the semicolon at the end, though. Those get important when making an element with more than one Command. Close every set of curly braces with a semicolon as well.

ActorFrame
ActorFrames occur naturally in XML, and they also appear in Lua. The key difference here is that the Lua equivalent of  is rarely used, usually relegated to ActorScrollers.

Layer
Layers are the primary way to create objects with XML. They can be purposed for multiple things with the Type attribute. Since SM4 splits out certain object types, conversion is not 1:1.

If attempting to convert a , see Quad. For converting, see LoadFont.

XML
or

Complete XML to Lua Example
This example specifically deals with ScreenGameplay ready, as it is simple. The code has been slightly changed in order to remove horizontal scrollbars; everything is normally in the OnCommand.

Lua
This example (and any other time where you just need to load a single file) can actually be flattened down to just: