Lua enum

When you start scripting with lua you may notice that its functional range is some how reduced to a very tiny set of essential basics. One thing you might be missing is an enum type. But we could implement something very close.

Before we start I want to recommend the online demo at Just paste your lua code into the lua-shell window and press “run” to see if it works.

A very simple enum function could be something like this:


These enums do not support non-array enums, though.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.