summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-22 23:06:26 -0500
committersanine <sanine.not@pm.me>2023-03-22 23:06:26 -0500
commitdc8f29206201fcc977443ce9c6138c2f3129c1c8 (patch)
treed2acf572e965f3fdabf4fdb02ee0779ddacfb846 /src/util
parent78eb15d59190c079b1edb405eeae6696724f1b2e (diff)
re-implement bouncing ball
Diffstat (limited to 'src/util')
-rw-r--r--src/util/util.c8
-rw-r--r--src/util/util.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c
index 564ffd4..0e71f22 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -16,6 +16,14 @@ void create_table(lua_State *L, struct honey_tbl_t *tbl)
lua_pushcfunction(L, pair->value.function);
lua_setfield(L, t, pair->key);
}
+ else if (pair->type == LUA_TSTRING) {
+ lua_pushstring(L, pair->value.string);
+ lua_setfield(L, t, pair->key);
+ }
+ else if (pair->type == LUA_TNUMBER) {
+ lua_pushnumber(L, pair->value.number);
+ lua_setfield(L, t, pair->key);
+ }
else {
/* bad type, ignore */
}
diff --git a/src/util/util.h b/src/util/util.h
index 293397c..c73ba54 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -9,6 +9,7 @@ struct honey_tbl_t {
int type;
union {
lua_Integer integer;
+ lua_Number number;
lua_CFunction function;
const char *string;
} value;
@@ -18,6 +19,7 @@ struct honey_tbl_t {
#define H_ENUM(v) { .key=#v, .type=LUA_TNUMBER, .value.integer=v }
#define H_FUNC(k, v) { .key=k, .type=LUA_TFUNCTION, .value.function=v }
#define H_STR(k, v) { .key=k, .type=LUA_TSTRING, .value.string=v }
+#define H_NUM(k, v) { .key=k, .type=LUA_TNUMBER, .value.number=v }
#define H_END { .key=NULL, .type=LUA_TNIL, .value.integer=0 }