109 lines
3.8 KiB
Lua
109 lines
3.8 KiB
Lua
|
panes_embedded = {}
|
||
|
|
||
|
panes_embedded.add_pane = function(name, def, orig_name)
|
||
|
-- xpanes defines *two* nodes per pane; we only need one here
|
||
|
if(minetest.registered_nodes[ "panes_embedded:" .. name .. "_embedded" ]) then
|
||
|
return false
|
||
|
end
|
||
|
-- this cannot register as a pane because auto-connecting would screw things up
|
||
|
local groups_without_pane = table.copy(def.groups)
|
||
|
groups_without_pane.pane = nil
|
||
|
-- when two textures take up the same place, it might get a bit messy;
|
||
|
-- thus: make the pane a tiny bit smaller
|
||
|
local no_flicker = 1/4096
|
||
|
minetest.register_node(":panes_embedded:" .. name .. "_embedded", {
|
||
|
description = "Embedded "..tostring(def.description),
|
||
|
drawtype = "nodebox",
|
||
|
paramtype = "light",
|
||
|
is_ground_content = false,
|
||
|
sunlight_propagates = true,
|
||
|
inventory_image = def.inventory_image,
|
||
|
wield_image = def.wield_image,
|
||
|
paramtype2 = "facedir",
|
||
|
tiles = def.tiles,
|
||
|
-- change compared to xpanes: it is *not* a pane in the technical sense (relevant for abms)
|
||
|
groups = groups_without_pane,
|
||
|
-- change compared to xpanes: drops itself
|
||
|
-- drop = "xpanes:" .. name .. "_flat", -- no: drops itself
|
||
|
sounds = def.sounds,
|
||
|
use_texture_alpha = def.use_texture_alpha and "blend" or "clip",
|
||
|
-- this pane does not (visually) sit in the middle of the node it is placed (and stoerd) in
|
||
|
-- but in the node *behind* that one
|
||
|
node_box = {
|
||
|
type = "fixed",
|
||
|
fixed = {{-1/2+no_flicker, -1/2+no_flicker, -1/32+1, 1/2-no_flicker, 1/2-no_flicker, 1/32+1}},
|
||
|
},
|
||
|
selection_box = {
|
||
|
type = "fixed",
|
||
|
fixed = {{-1/2, -1/2, -8/32+0.5, 1/2, 1/2, 1.0}},
|
||
|
},
|
||
|
-- change compared to xpanes: no connected sides - the pane visually sits elsewhere;
|
||
|
-- behaving as a normal pane would be very problematic
|
||
|
-- connect_sides = { "left", "right" },
|
||
|
})
|
||
|
|
||
|
-- lone-standing pane; more or less the same as above, but not moved to the node behind - only
|
||
|
-- to the edge of its own node (sometimes helpful for building something; those xpanes can be
|
||
|
-- terribly annoying when they decide to connect to chairs and the like)
|
||
|
no_flicker = 0
|
||
|
minetest.register_node(":panes_embedded:" .. name.."_unconnected", {
|
||
|
description = "Unconnected "..tostring(def.description),
|
||
|
drawtype = "nodebox",
|
||
|
paramtype = "light",
|
||
|
is_ground_content = false,
|
||
|
sunlight_propagates = true,
|
||
|
inventory_image = def.inventory_image,
|
||
|
wield_image = def.wield_image,
|
||
|
paramtype2 = "facedir",
|
||
|
tiles = def.tiles,
|
||
|
-- change compared to xpanes: it is *not* a pane in the technical sense (relevant for abms)
|
||
|
groups = groups_without_pane,
|
||
|
-- change compared to xpanes: drops itself
|
||
|
-- drop = "xpanes:" .. name .. "_flat", -- no: drops itself
|
||
|
sounds = def.sounds,
|
||
|
use_texture_alpha = def.use_texture_alpha and "blend" or "clip",
|
||
|
node_box = {
|
||
|
type = "fixed",
|
||
|
fixed = {{-1/2, -1/2, 0.5, 1/2, 1/2, 0.5-2/32}},
|
||
|
},
|
||
|
selection_box = {
|
||
|
type = "fixed",
|
||
|
fixed = {{-1/2, -1/2, 0.5, 1/2, 1/2, 1/2-4/32}},
|
||
|
},
|
||
|
-- change compared to xpanes: no connected sides - the pane visually sits elsewhere;
|
||
|
-- behaving as a normal pane would be very problematic
|
||
|
-- connect_sides = { "left", "right" },
|
||
|
})
|
||
|
|
||
|
-- craft chain: from xpane to the unconnected to the embedded one
|
||
|
minetest.register_craft({
|
||
|
output = "panes_embedded:" .. name.."_unconnected",
|
||
|
recipe = {
|
||
|
{orig_name},
|
||
|
}
|
||
|
})
|
||
|
|
||
|
minetest.register_craft({
|
||
|
output = "panes_embedded:" .. name .. "_embedded",
|
||
|
recipe = {
|
||
|
{"panes_embedded:" .. name.."_unconnected"},
|
||
|
}
|
||
|
})
|
||
|
|
||
|
minetest.register_craft({
|
||
|
output = orig_name,
|
||
|
recipe = {
|
||
|
{"panes_embedded:" .. name.."_embedded"},
|
||
|
}
|
||
|
})
|
||
|
-- embedded pane successfully created
|
||
|
return ture
|
||
|
end
|
||
|
|
||
|
for k, v in pairs(minetest.registered_nodes) do
|
||
|
if(minetest.get_item_group(k, "pane") > 0) then
|
||
|
local parts = string.split(k, ":")
|
||
|
panes_embedded.add_pane(parts[1].."_"..parts[2], v, k)
|
||
|
end
|
||
|
end
|