about summary refs log tree commit diff stats
path: root/lua
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2023-06-10 19:08:03 -0400
committerelioat <elioat@tilde.institute>2023-06-10 19:08:03 -0400
commitdd562aefcb84ab4ab0ab8dc0cbac0506609d419f (patch)
treea969219bbe06546ad1ab8a56514bc365fbc87ba9 /lua
parent793ec6fd50144bffd1b91c520cf9156fe1dfccba (diff)
downloadtour-dd562aefcb84ab4ab0ab8dc0cbac0506609d419f.tar.gz
*
Diffstat (limited to 'lua')
-rw-r--r--lua/enum.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/lua/enum.lua b/lua/enum.lua
new file mode 100644
index 0000000..60c657e
--- /dev/null
+++ b/lua/enum.lua
@@ -0,0 +1,19 @@
+-- because sometimes you need an enum
+
+function enum(tbl)
+    local length = #tbl
+    for i = 1, length do
+        local v = tbl[i]
+        tbl[v] = i
+    end
+    return tbl
+end
+
+local Game_Status = enum {
+	"MENU",
+	"PLAY",
+	"QUIT"
+}
+
+print(Game_Status.MENU) -- 1
+print(Game_Status.PLAY) -- 2, .etc
\ No newline at end of file