mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 03:23:45 +01:00
Fix core.get_node_or_nil in emerge env
"ignore" does not mean unloaded, we have to properly check it.
This commit is contained in:
parent
91ea47fddf
commit
e734b3f0d8
@ -31,11 +31,6 @@ function core.get_node(pos)
|
||||
return core.vmanip:get_node_at(pos)
|
||||
end
|
||||
|
||||
function core.get_node_or_nil(pos)
|
||||
local node = core.vmanip:get_node_at(pos)
|
||||
return node.name ~= "ignore" and node
|
||||
end
|
||||
|
||||
function core.get_perlin(seed, octaves, persist, spread)
|
||||
local params
|
||||
if type(seed) == "table" then
|
||||
|
@ -1534,6 +1534,19 @@ void ModApiEnv::InitializeClient(lua_State *L, int top)
|
||||
if (!vm) \
|
||||
return 0
|
||||
|
||||
// get_node_or_nil(pos)
|
||||
int ModApiEnvVM::l_get_node_or_nil(lua_State *L)
|
||||
{
|
||||
GET_VM_PTR;
|
||||
|
||||
v3s16 pos = read_v3s16(L, 1);
|
||||
if (vm->exists(pos))
|
||||
pushnode(L, vm->getNodeRefUnsafe(pos));
|
||||
else
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// get_node_max_level(pos)
|
||||
int ModApiEnvVM::l_get_node_max_level(lua_State *L)
|
||||
{
|
||||
@ -1703,6 +1716,7 @@ MMVManip *ModApiEnvVM::getVManip(lua_State *L)
|
||||
void ModApiEnvVM::InitializeEmerge(lua_State *L, int top)
|
||||
{
|
||||
// other, more trivial functions are in builtin/emerge/env.lua
|
||||
API_FCT(get_node_or_nil);
|
||||
API_FCT(get_node_max_level);
|
||||
API_FCT(get_node_level);
|
||||
API_FCT(set_node_level);
|
||||
|
@ -247,6 +247,9 @@ public:
|
||||
class ModApiEnvVM : public ModApiEnvBase {
|
||||
private:
|
||||
|
||||
// get_node_or_nil(pos)
|
||||
static int l_get_node_or_nil(lua_State *L);
|
||||
|
||||
// get_node_max_level(pos)
|
||||
static int l_get_node_max_level(lua_State *L);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user