diff options
Diffstat (limited to 'src/script/common')
-rw-r--r-- | src/script/common/c_converter.cpp | 13 | ||||
-rw-r--r-- | src/script/common/c_converter.h | 2 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp index 157db3b7d..fc489ea95 100644 --- a/src/script/common/c_converter.cpp +++ b/src/script/common/c_converter.cpp @@ -332,6 +332,19 @@ bool getintfield(lua_State *L, int table, } bool getintfield(lua_State *L, int table, + const char *fieldname, u8 &result) +{ + lua_getfield(L, table, fieldname); + bool got = false; + if(lua_isnumber(L, -1)){ + result = lua_tonumber(L, -1); + got = true; + } + lua_pop(L, 1); + return got; +} + +bool getintfield(lua_State *L, int table, const char *fieldname, u16 &result) { lua_getfield(L, table, fieldname); diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h index 1d5be6971..0847f47c9 100644 --- a/src/script/common/c_converter.h +++ b/src/script/common/c_converter.h @@ -54,6 +54,8 @@ size_t getstringlistfield(lua_State *L, int table, bool getintfield(lua_State *L, int table, const char *fieldname, int &result); bool getintfield(lua_State *L, int table, + const char *fieldname, u8 &result); +bool getintfield(lua_State *L, int table, const char *fieldname, u16 &result); bool getintfield(lua_State *L, int table, const char *fieldname, u32 &result); |