92 lines
2.3 KiB
Lua
92 lines
2.3 KiB
Lua
|
|
local lantern_box = {
|
|
type = "fixed",
|
|
fixed = {
|
|
{
|
|
-3/16, -0.5, -3/16,
|
|
3/16, -1/16, 3/16,
|
|
},
|
|
{
|
|
-2/16, -1/16, -2/16,
|
|
2/16, 1/16, 2/16
|
|
},
|
|
{
|
|
-1/16, 1/16, -1/16,
|
|
1/16, 3/16, 1/16
|
|
}
|
|
}
|
|
}
|
|
|
|
local hanging_lantern_box = {
|
|
type = "fixed",
|
|
fixed = {
|
|
{
|
|
-3/16, -7/16, -3/16,
|
|
3/16, 0, 3/16,
|
|
},
|
|
{
|
|
-2/16, 0, -2/16,
|
|
2/16, 2/16, 2/16
|
|
},
|
|
{
|
|
-1/16, 1/16, -1/16,
|
|
1/16, 0.5, 1/16
|
|
}
|
|
}
|
|
}
|
|
|
|
function rgt.register_lantern(type)
|
|
local function on_place(s, p, pt)
|
|
local out = ItemStack(s)
|
|
local target = minetest.registered_nodes[minetest.get_node(pt.under).name].buildable_to and pt.under or pt.above
|
|
local below = minetest.get_node(target:offset(0, -1, 0))
|
|
|
|
-- TODO: Check solidity, not just air-ness.
|
|
if below.name == "air" then
|
|
local above = minetest.get_node(target:offset(0, 1, 0))
|
|
|
|
if above.name == "air" then
|
|
return s
|
|
end
|
|
|
|
s:set_name("lantern_"..type.."_hanging")
|
|
else
|
|
s:set_name("lantern_"..type)
|
|
end
|
|
|
|
local stack = minetest.item_place_node(s, p, pt)
|
|
out:set_count(stack:get_count())
|
|
|
|
return out
|
|
end
|
|
|
|
rgt.register_node("lantern_"..type, {
|
|
drawtype = "mesh",
|
|
mesh = "rgt_lantern.gltf",
|
|
tiles = {"rgt_lantern_"..type..".png"},
|
|
paramtype = "light",
|
|
light_source = 11,
|
|
selection_box = lantern_box,
|
|
collision_box = lantern_box,
|
|
node_placement_prediction = "",
|
|
groups = {dig_immediate = 3},
|
|
on_place = on_place
|
|
})
|
|
|
|
rgt.register_node("lantern_"..type.."_hanging", {
|
|
drawtype = "mesh",
|
|
mesh = "rgt_lantern_hanging.gltf",
|
|
tiles = {"rgt_lantern_"..type..".png"},
|
|
paramtype = "light",
|
|
light_source = 11,
|
|
selection_box = hanging_lantern_box,
|
|
collision_box = hanging_lantern_box,
|
|
node_placement_prediction = "",
|
|
drop = "lantern_"..type,
|
|
groups = {dig_immediate = 3},
|
|
on_place = on_place
|
|
})
|
|
end
|
|
|
|
rgt.register_lantern("iron")
|
|
rgt.register_lantern("copper")
|