mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-01 15:01:06 +01:00
Add check for unknown nodes.
* Check if node has a definition table before attempting to evaluate its attributes. * Define local variable to cache multiple accesses to `registered_nodes[]` and improve readability.
This commit is contained in:
parent
9bac0da01a
commit
3f4dafc68f
1 changed files with 4 additions and 3 deletions
|
@ -210,7 +210,8 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
local posses = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } }
|
local posses = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } }
|
||||||
for _, p in pairs(posses) do
|
for _, p in pairs(posses) do
|
||||||
if minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name].walkable then
|
local ndef = minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name]
|
||||||
|
if ndef and ndef.walkable then
|
||||||
local posy = pos.y
|
local posy = pos.y
|
||||||
while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do
|
while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do
|
||||||
local pos = vector.new(pos.x, posy, pos.z)
|
local pos = vector.new(pos.x, posy, pos.z)
|
||||||
|
@ -841,7 +842,7 @@ minetest.register_abm({
|
||||||
-- If this was mycelium, uproot plant above
|
-- If this was mycelium, uproot plant above
|
||||||
if n2.name == "mcl_core:mycelium" then
|
if n2.name == "mcl_core:mycelium" then
|
||||||
local tad = minetest.registered_nodes[minetest.get_node(above).name]
|
local tad = minetest.registered_nodes[minetest.get_node(above).name]
|
||||||
if tad.groups and tad.groups.non_mycelium_plant then
|
if tad and tad.groups and tad.groups.non_mycelium_plant then
|
||||||
minetest.dig_node(above)
|
minetest.dig_node(above)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1333,7 +1334,7 @@ minetest.register_abm({
|
||||||
function mcl_core.supports_vines(nodename)
|
function mcl_core.supports_vines(nodename)
|
||||||
local def = minetest.registered_nodes[nodename]
|
local def = minetest.registered_nodes[nodename]
|
||||||
-- Rules: 1) walkable 2) full cube
|
-- Rules: 1) walkable 2) full cube
|
||||||
return def.walkable and
|
return def and def.walkable and
|
||||||
(def.node_box == nil or def.node_box.type == "regular") and
|
(def.node_box == nil or def.node_box.type == "regular") and
|
||||||
(def.collision_box == nil or def.collision_box.type == "regular")
|
(def.collision_box == nil or def.collision_box.type == "regular")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue