From dc8f29206201fcc977443ce9c6138c2f3129c1c8 Mon Sep 17 00:00:00 2001 From: sanine Date: Wed, 22 Mar 2023 23:06:26 -0500 Subject: re-implement bouncing ball --- src/util/util.c | 8 ++++++++ src/util/util.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'src/util') 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 } -- cgit v1.2.1