forked from VoxeLibre/VoxeLibre
Fix several crashes, fix doors that don't wax both halves
This commit is contained in:
parent
a6ea84b55d
commit
614ccce1f6
|
@ -1,8 +1,9 @@
|
||||||
-- Functions used to strip wax from the other half of the door
|
-- Functions used to strip wax from the other half of the door
|
||||||
local function strip(pos, node, node_def)
|
local function strip(pos, node, node_def)
|
||||||
local node = node or minetest.get_node(pos)
|
local node = node or minetest.get_node(pos)
|
||||||
local node_def = node_def or registered_nodes[node.name]
|
local node_def = node_def or minetest.registered_nodes[node.name]
|
||||||
if not node_def then return end
|
if not node_def then return end
|
||||||
|
if not node_def._mcl_stripped_variant then return end
|
||||||
|
|
||||||
node.name = node_def._mcl_stripped_variant
|
node.name = node_def._mcl_stripped_variant
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
|
@ -17,14 +18,15 @@ end
|
||||||
-- Functions used to wax the other half of the door
|
-- Functions used to wax the other half of the door
|
||||||
local function wax(pos, node, node_def)
|
local function wax(pos, node, node_def)
|
||||||
local node = node or minetest.get_node(pos)
|
local node = node or minetest.get_node(pos)
|
||||||
local node_def = node_def or registered_nodes[node.name]
|
local node_def = node_def or minetest.registered_nodes[node.name]
|
||||||
if not node_def then return end
|
if not node_def then return end
|
||||||
|
if not node_def._mcl_waxed_variant then return end
|
||||||
|
|
||||||
node.name = node_def._mcl_waxed_variant
|
node.name = node_def._mcl_waxed_variant
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
end
|
end
|
||||||
local function wax_door_top(pos, node, node_def)
|
local function wax_door_top(pos, node, node_def)
|
||||||
wax(vector.offset(pos,0,-1.0))
|
wax(vector.offset(pos,0,-1,0))
|
||||||
end
|
end
|
||||||
local function wax_door_bottom(pos, node, node_def)
|
local function wax_door_bottom(pos, node, node_def)
|
||||||
wax(vector.offset(pos,0,1,0))
|
wax(vector.offset(pos,0,1,0))
|
||||||
|
@ -134,20 +136,20 @@ local function register_waxing_and_scraping(mod_name, subname, decay_chain)
|
||||||
elseif subname == "waxed_door" then
|
elseif subname == "waxed_door" then
|
||||||
for i = 1,4 do
|
for i = 1,4 do
|
||||||
local is = tostring(i)
|
local is = tostring(i)
|
||||||
minetest.override_item(waxed_item.."_b_1", {
|
minetest.override_item(waxed_item.."_b_"..is, {
|
||||||
_mcl_stripped_variant = unwaxed_item.."_b_1",
|
_mcl_stripped_variant = unwaxed_item.."_b_"..is,
|
||||||
_mcl_on_strip = strip_door_bottom,
|
_mcl_on_strip = strip_door_bottom,
|
||||||
})
|
})
|
||||||
minetest.override_item(unwaxed_item.."_b_1", {
|
minetest.override_item(unwaxed_item.."_b_"..is, {
|
||||||
_mcl_waxed_variant = waxed_item.."_b_1",
|
_mcl_waxed_variant = waxed_item.."_b_"..is,
|
||||||
_mcl_on_wax = wax_door_bottom,
|
_mcl_on_wax = wax_door_bottom,
|
||||||
})
|
})
|
||||||
minetest.override_item(waxed_item.."_t_1", {
|
minetest.override_item(waxed_item.."_t_"..is, {
|
||||||
_mcl_stripped_variant = unwaxed_item.."_t_1",
|
_mcl_stripped_variant = unwaxed_item.."_t_"..is,
|
||||||
_mcl_on_strip = strip_door_top,
|
_mcl_on_strip = strip_door_top,
|
||||||
})
|
})
|
||||||
minetest.override_item(unwaxed_item.."_t_1", {
|
minetest.override_item(unwaxed_item.."_t_"..is, {
|
||||||
_mcl_waxed_variant = waxed_item.."_t_1",
|
_mcl_waxed_variant = waxed_item.."_t_"..is,
|
||||||
_mcl_on_wax = wax_door_top,
|
_mcl_on_wax = wax_door_top,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,12 +21,15 @@ function mcl_honey.wax_block(pos, node, player, itemstack, pointed_thing)
|
||||||
return def.on_rightclick(pos, node, player, itemstack, pointed_thing)
|
return def.on_rightclick(pos, node, player, itemstack, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- We shouldn't try to wax blocks that don't have a waxed variant
|
||||||
|
if not def._mcl_waxed_variant then return end
|
||||||
|
|
||||||
-- Wax the node
|
-- Wax the node
|
||||||
node.name = def._mcl_waxed_variant
|
node.name = def._mcl_waxed_variant
|
||||||
minetest.swap_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
|
|
||||||
-- Call the node's waxed hook
|
-- Call the node's waxed hook
|
||||||
local hook = def._mcl_on_waxed
|
local hook = def._mcl_on_wax
|
||||||
if hook then hook(pos, node, def) end
|
if hook then hook(pos, node, def) end
|
||||||
|
|
||||||
-- Handle the award
|
-- Handle the award
|
||||||
|
|
Loading…
Reference in New Issue