aboutsummaryrefslogtreecommitdiff
path: root/src/script/common/c_converter.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2018-03-03 10:59:43 +0100
committerGitHub <noreply@github.com>2018-03-03 10:59:43 +0100
commitebbd158774853a2fae21cb3ee3787803b94d7b93 (patch)
tree1d0b66fbb9ec2b43179649e454a2367b4a51884e /src/script/common/c_converter.cpp
parenta1cf8a127c57719d18fa0ccbe4a3fa3ac5504ef2 (diff)
downloadminetest-ebbd158774853a2fae21cb3ee3787803b94d7b93.tar.gz
minetest-ebbd158774853a2fae21cb3ee3787803b94d7b93.tar.bz2
minetest-ebbd158774853a2fae21cb3ee3787803b94d7b93.zip
c_converter: Function template for numeric fields, add v3s16 default (#7090)
Diffstat (limited to 'src/script/common/c_converter.cpp')
-rw-r--r--src/script/common/c_converter.cpp72
1 files changed, 7 insertions, 65 deletions
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp
index ce2548e83..0ee5afa3e 100644
--- a/src/script/common/c_converter.cpp
+++ b/src/script/common/c_converter.cpp
@@ -467,71 +467,6 @@ bool getstringfield(lua_State *L, int table,
return got;
}
-bool getintfield(lua_State *L, int table,
- const char *fieldname, int &result)
-{
- lua_getfield(L, table, fieldname);
- bool got = false;
- if(lua_isnumber(L, -1)){
- result = lua_tointeger(L, -1);
- got = true;
- }
- lua_pop(L, 1);
- return got;
-}
-
-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_tointeger(L, -1);
- got = true;
- }
- lua_pop(L, 1);
- return got;
-}
-
-bool getintfield(lua_State *L, int table,
- const char *fieldname, s8 &result)
-{
- lua_getfield(L, table, fieldname);
- bool got = false;
- if (lua_isnumber(L, -1)) {
- result = lua_tointeger(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);
- bool got = false;
- if(lua_isnumber(L, -1)){
- result = lua_tointeger(L, -1);
- got = true;
- }
- lua_pop(L, 1);
- return got;
-}
-
-bool getintfield(lua_State *L, int table,
- const char *fieldname, u32 &result)
-{
- lua_getfield(L, table, fieldname);
- bool got = false;
- if(lua_isnumber(L, -1)){
- result = lua_tointeger(L, -1);
- got = true;
- }
- lua_pop(L, 1);
- return got;
-}
-
bool getfloatfield(lua_State *L, int table,
const char *fieldname, float &result)
{
@@ -612,6 +547,13 @@ bool getboolfield_default(lua_State *L, int table,
return result;
}
+v3s16 getv3s16field_default(lua_State *L, int table,
+ const char *fieldname, v3s16 default_)
+{
+ getv3intfield(L, table, fieldname, default_);
+ return default_;
+}
+
void setstringfield(lua_State *L, int table,
const char *fieldname, const char *value)
{