summaryrefslogtreecommitdiff
path: root/libs/honeysuckle/examples/table_creation
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-04-16 11:55:09 -0500
committersanine <sanine.not@pm.me>2022-04-16 11:55:09 -0500
commitdb81b925d776103326128bf629cbdda576a223e7 (patch)
tree58bea8155c686733310009f6bed7363f91fbeb9d /libs/honeysuckle/examples/table_creation
parent55860037b14fb3893ba21cf2654c83d349cc1082 (diff)
move 3rd-party librarys into libs/ and add built-in honeysuckle
Diffstat (limited to 'libs/honeysuckle/examples/table_creation')
-rw-r--r--libs/honeysuckle/examples/table_creation/table_creation.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/libs/honeysuckle/examples/table_creation/table_creation.c b/libs/honeysuckle/examples/table_creation/table_creation.c
new file mode 100644
index 0000000..42088c6
--- /dev/null
+++ b/libs/honeysuckle/examples/table_creation/table_creation.c
@@ -0,0 +1,28 @@
+#include <honeysuckle.h>
+
+int main()
+{
+ lua_State *L = luaL_newstate();
+ luaL_openlibs(L);
+
+ /* create the table
+ * { "one"=1, "two"=2, "half"=0.5, "runme"=[some function] }
+ */
+ luaL_dostring(L,
+ "return function(self) \n" \
+ "print(self.one)\n" \
+ "print(self.two)\n" \
+ "print(self.half)\n" \
+ "end");
+ int func_index = lua_gettop(L);
+
+ hs_create_table(L,
+ hs_str_int("one", 1),
+ hs_str_int("two", 2),
+ hs_str_num("half", 0.5f),
+ hs_str_func("runme", func_index));
+ lua_setglobal(L, "runnable");
+
+ luaL_dostring(L, "runnable:runme()");
+ return 0;
+}