mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Update set_mapgen_params and set_gen_notify Lua API to use new flag format
This commit is contained in:
parent
db98ef6b45
commit
28d6326bd4
3 changed files with 43 additions and 27 deletions
|
@ -840,23 +840,32 @@ void push_hit_params(lua_State *L,const HitParams ¶ms)
|
|||
}
|
||||
|
||||
/******************************************************************************/
|
||||
u32 getflagsfield(lua_State *L, int table, const char *fieldname,
|
||||
FlagDesc *flagdesc, u32 *flagmask)
|
||||
|
||||
bool getflagsfield(lua_State *L, int table, const char *fieldname,
|
||||
FlagDesc *flagdesc, u32 *flags, u32 *flagmask)
|
||||
{
|
||||
u32 flags = 0;
|
||||
|
||||
lua_getfield(L, table, fieldname);
|
||||
|
||||
if (lua_isstring(L, -1)) {
|
||||
std::string flagstr = lua_tostring(L, -1);
|
||||
flags = readFlagString(flagstr, flagdesc, flagmask);
|
||||
} else if (lua_istable(L, -1)) {
|
||||
flags = read_flags_table(L, -1, flagdesc, flagmask);
|
||||
}
|
||||
bool success = read_flags(L, -1, flagdesc, flags, flagmask);
|
||||
|
||||
lua_pop(L, 1);
|
||||
|
||||
return flags;
|
||||
return success;
|
||||
}
|
||||
|
||||
bool read_flags(lua_State *L, int index, FlagDesc *flagdesc,
|
||||
u32 *flags, u32 *flagmask)
|
||||
{
|
||||
if (lua_isstring(L, index)) {
|
||||
std::string flagstr = lua_tostring(L, index);
|
||||
*flags = readFlagString(flagstr, flagdesc, flagmask);
|
||||
} else if (lua_istable(L, index)) {
|
||||
*flags = read_flags_table(L, index, flagdesc, flagmask);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 read_flags_table(lua_State *L, int table, FlagDesc *flagdesc, u32 *flagmask)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue