mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Reduce code duplication between c_converter.cpp and helper.cpp
This commit is contained in:
parent
8ff3fadba0
commit
1d512ef7f4
4 changed files with 32 additions and 84 deletions
|
@ -61,23 +61,10 @@ bool getintfield(lua_State *L, int table,
|
|||
return got;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool getv3intfield(lua_State *L, int index,
|
||||
const char *fieldname, T &result)
|
||||
{
|
||||
lua_getfield(L, index, fieldname);
|
||||
bool got = false;
|
||||
if (lua_istable(L, -1)) {
|
||||
got |= getintfield(L, -1, "x", result.X);
|
||||
got |= getintfield(L, -1, "y", result.Y);
|
||||
got |= getintfield(L, -1, "z", result.Z);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
return got;
|
||||
}
|
||||
|
||||
// Retrieve an v3s16 where all components are optional (falls back to default)
|
||||
v3s16 getv3s16field_default(lua_State *L, int table,
|
||||
const char *fieldname, v3s16 default_);
|
||||
|
||||
bool getstringfield(lua_State *L, int table,
|
||||
const char *fieldname, std::string &result);
|
||||
size_t getstringlistfield(lua_State *L, int table,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue