mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add NodeResolver and clean up node name -> content ID resolution system
This commit is contained in:
parent
b49e5cfc70
commit
d274cbfce6
11 changed files with 445 additions and 342 deletions
|
@ -227,6 +227,25 @@ std::vector<aabb3f> read_aabb3f_vector(lua_State *L, int index, f32 scale)
|
|||
return boxes;
|
||||
}
|
||||
|
||||
bool read_stringlist(lua_State *L, int index, std::vector<const char *> &result)
|
||||
{
|
||||
if (index < 0)
|
||||
index = lua_gettop(L) + 1 + index;
|
||||
|
||||
if (lua_istable(L, index)) {
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, index)) {
|
||||
result.push_back(lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else if (lua_isstring(L, index)) {
|
||||
result.push_back(lua_tostring(L, index));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Table field getters
|
||||
*/
|
||||
|
@ -287,6 +306,17 @@ bool getboolfield(lua_State *L, int table,
|
|||
return got;
|
||||
}
|
||||
|
||||
bool getstringlistfield(lua_State *L, int table, const char *fieldname,
|
||||
std::vector<const char *> &result)
|
||||
{
|
||||
lua_getfield(L, table, fieldname);
|
||||
|
||||
bool got = read_stringlist(L, -1, result);
|
||||
|
||||
lua_pop(L, 1);
|
||||
return got;
|
||||
}
|
||||
|
||||
std::string checkstringfield(lua_State *L, int table,
|
||||
const char *fieldname)
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ extern "C" {
|
|||
#include <lua.h>
|
||||
}
|
||||
|
||||
std::string getstringfield_default (lua_State *L, int table,
|
||||
std::string getstringfield_default(lua_State *L, int table,
|
||||
const char *fieldname, const std::string &default_);
|
||||
bool getboolfield_default(lua_State *L, int table,
|
||||
const char *fieldname, bool default_);
|
||||
|
@ -48,9 +48,12 @@ int getintfield_default (lua_State *L, int table,
|
|||
|
||||
bool getstringfield(lua_State *L, int table,
|
||||
const char *fieldname, std::string &result);
|
||||
bool getstringlistfield(lua_State *L, int table,
|
||||
const char *fieldname,
|
||||
std::vector<const char *> &result);
|
||||
bool getintfield(lua_State *L, int table,
|
||||
const char *fieldname, int &result);
|
||||
void read_groups (lua_State *L, int index,
|
||||
void read_groups(lua_State *L, int index,
|
||||
std::map<std::string, int> &result);
|
||||
bool getboolfield(lua_State *L, int table,
|
||||
const char *fieldname, bool &result);
|
||||
|
@ -68,28 +71,29 @@ void setboolfield(lua_State *L, int table,
|
|||
const char *fieldname, bool value);
|
||||
|
||||
|
||||
v3f checkFloatPos (lua_State *L, int index);
|
||||
v3f check_v3f (lua_State *L, int index);
|
||||
v3s16 check_v3s16 (lua_State *L, int index);
|
||||
v3f checkFloatPos (lua_State *L, int index);
|
||||
v3f check_v3f (lua_State *L, int index);
|
||||
v3s16 check_v3s16 (lua_State *L, int index);
|
||||
|
||||
v3f read_v3f (lua_State *L, int index);
|
||||
v2f read_v2f (lua_State *L, int index);
|
||||
v2s16 read_v2s16 (lua_State *L, int index);
|
||||
v2s32 read_v2s32 (lua_State *L, int index);
|
||||
video::SColor readARGB8 (lua_State *L, int index);
|
||||
aabb3f read_aabb3f (lua_State *L, int index, f32 scale);
|
||||
v3s16 read_v3s16 (lua_State *L, int index);
|
||||
std::vector<aabb3f>
|
||||
read_aabb3f_vector (lua_State *L, int index, f32 scale);
|
||||
v3f read_v3f (lua_State *L, int index);
|
||||
v2f read_v2f (lua_State *L, int index);
|
||||
v2s16 read_v2s16 (lua_State *L, int index);
|
||||
v2s32 read_v2s32 (lua_State *L, int index);
|
||||
video::SColor readARGB8 (lua_State *L, int index);
|
||||
aabb3f read_aabb3f (lua_State *L, int index, f32 scale);
|
||||
v3s16 read_v3s16 (lua_State *L, int index);
|
||||
std::vector<aabb3f> read_aabb3f_vector (lua_State *L, int index, f32 scale);
|
||||
bool read_stringlist (lua_State *L, int index,
|
||||
std::vector<const char *> &result);
|
||||
|
||||
void push_v3s16 (lua_State *L, v3s16 p);
|
||||
void pushFloatPos (lua_State *L, v3f p);
|
||||
void push_v3f (lua_State *L, v3f p);
|
||||
void push_v2f (lua_State *L, v2f p);
|
||||
void push_v3s16 (lua_State *L, v3s16 p);
|
||||
void pushFloatPos (lua_State *L, v3f p);
|
||||
void push_v3f (lua_State *L, v3f p);
|
||||
void push_v2f (lua_State *L, v2f p);
|
||||
|
||||
|
||||
|
||||
void warn_if_field_exists (lua_State *L,
|
||||
void warn_if_field_exists (lua_State *L,
|
||||
int table,
|
||||
const char *fieldname,
|
||||
const std::string &message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue