mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-16 01:45:36 +02:00
Reduce code duplication between c_converter.cpp and helper.cpp
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user