

To check for equality, use count = 5, which means "count is equal to 5". The expression count = 5 means "store the value 5 in count", which is not what we want here. That is, it is a command that means "store this value in this variable". Instead, the single equals sign represents assignment. In many programming languages, including Lua, the single equals sign does not mean "is equal to". Conditions can be combined using and and or. "=" mean "less than or equal to" and "greater than or equal to", respectively. The greater than and less than sign mean what you expect. The following are examples of boolean expressions. In most cases, you will be using Boolean expressions that can be true or false depending on the situation. You can use Booleans to evaluate if conditions or loops. If you want to type a normal backslash, type " \\".Īnother data type is the Boolean, which can only have two values: true or false. Note that the backslash ( \) is an "escape character" ( more info here). In Lua, you can join one string to another using the. They behave similarly to the variables in algebra, but can store any kind of data, not just numbers.Īnother simple data type in addition to numbers is the string, which represents text and is defined with quotes. Variables, data types, arithmetic, and logicĪ variable is the name of the place where you store data. You can find many good resources for learning Lua on the page. On the advice of some people who helped proofread this tutorial, I've vastly condensed this section, as it is not the main focus. This section will briefly introduce basic programming concepts using Lua. I recommend frequently referencing the documentation provided in the Aegisub user manual. If you already know Lua, or if you'd rather start writing macros right away and learn Lua as you go, then you can skip to "The Aegisub Environment". If you already know a programming language (HTML doesn’t count), you can skip to "Lua for Experienced Programmers". The next section will cover basic programming concepts for people who have never programmed before. This tutorial should provide a solid starting point, but advanced users will have to do their own research. There are many features of the Lua language and the Aegisub API that I've never used and won't cover. This tutorial is based on my own knowledge and experience. In most cases, these tasks can be automated using macros written in Lua code, and often quite easily. If you’ve worked on an advanced substation alpha script, especially if you’re a typesetter, you’ve probably encountered tasks that are tedious, repetitive, and/or require more calculations than you’re willing to do. This tutorial is meant to serve as a basic guide to creating Lua automations for use in Aegisub. Creating Lua Automation Scripts for Aegisub
