3 local function rshift(x, by)
4 return math.floor(x / 2 ^ by)
10 {x = -1, y = 0, z = 0},
11 {x = 0, y = 0, z = -1},
14 local function update_pane(pos, name)
15 if not minetest.get_node(pos).name:find("^xpanes:"..name) then
19 for i, dir in pairs(directions) do
20 local node = minetest.get_node({
25 local def = minetest.registered_nodes[node.name]
26 local pane_num = def and def.groups.pane or 0
27 if pane_num > 0 or not def or (def.walkable ~= false and
28 def.drawtype ~= "nodebox") then
29 sum = sum + 2 ^ (i - 1)
35 minetest.set_node(pos, {name = "xpanes:"..name.."_"..sum})
38 local function update_nearby(pos, node)
39 node = node or minetest.get_node(pos)
40 if node.name:sub(1, 7) ~= "xpanes:" then return end
41 local underscore_pos = node.name:find("_") or 0
42 local name = node.name:sub(8, underscore_pos - 1)
43 for i, dir in pairs(directions) do
53 {0, -0.5, -1/32, 0.5, 0.5, 1/32},
54 {-1/32, -0.5, 0, 1/32, 0.5, 0.5},
55 {-0.5, -0.5, -1/32, 0, 0.5, 1/32},
56 {-1/32, -0.5, -0.5, 1/32, 0.5, 0}
60 {-0.5, -0.5, -1/32, 0.5, 0.5, 1/32},
61 {-1/32, -0.5, -0.5, 1/32, 0.5, 0.5}
64 local sb_half_boxes = {
65 {0, -0.5, -0.06, 0.5, 0.5, 0.06},
66 {-0.06, -0.5, 0, 0.06, 0.5, 0.5},
67 {-0.5, -0.5, -0.06, 0, 0.5, 0.06},
68 {-0.06, -0.5, -0.5, 0.06, 0.5, 0}
71 local sb_full_boxes = {
72 {-0.5, -0.5, -0.06, 0.5, 0.5, 0.06},
73 {-0.06, -0.5, -0.5, 0.06, 0.5, 0.5}
76 function xpanes.register_pane(name, def)
81 if rshift(i, j - 1) % 2 == 1 then
88 if need[1] == true and need[3] == true then
91 table.insert(take, full_boxes[1])
92 table.insert(take2, sb_full_boxes[1])
94 if need[2] == true and need[4] == true then
97 table.insert(take, full_boxes[2])
98 table.insert(take2, sb_full_boxes[2])
100 for k in pairs(need) do
101 table.insert(take, half_boxes[k])
102 table.insert(take2, sb_half_boxes[k])
104 local texture = def.textures[1]
106 texture = def.textures[1].."^"..def.textures[2]
108 minetest.register_node("xpanes:"..name.."_"..i, {
109 drawtype = "nodebox",
110 tiles = {def.textures[3], def.textures[3], texture},
113 drop = "xpanes:"..name,
126 minetest.register_node("xpanes:"..name, def)
128 minetest.register_craft({
129 output = "xpanes:"..name.." 16",
134 minetest.register_on_placenode(update_nearby)
135 minetest.register_on_dignode(update_nearby)
137 xpanes.register_pane("pane", {
138 description = "Glass Pane",
139 tiles = {"xpanes_space.png"},
140 drawtype = "airlike",
142 sunlight_propagates = true,
147 air_equivalent = true,
148 textures = {"default_glass.png","xpanes_pane_half.png","xpanes_white.png"},
149 inventory_image = "default_glass.png",
150 wield_image = "default_glass.png",
151 sounds = default.node_sound_glass_defaults(),
152 groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
153 on_construct = function(pos)
154 update_pane(pos, "pane")
157 {'default:glass', 'default:glass', 'default:glass'},
158 {'default:glass', 'default:glass', 'default:glass'}
162 xpanes.register_pane("bar", {
163 description = "Iron bar",
164 tiles = {"xpanes_space.png"},
165 drawtype = "airlike",
167 sunlight_propagates = true,
172 air_equivalent = true,
173 textures = {"xpanes_bar.png","xpanes_bar.png","xpanes_space.png"},
174 inventory_image = "xpanes_bar.png",
175 wield_image = "xpanes_bar.png",
176 groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
177 sounds = default.node_sound_stone_defaults(),
178 on_construct = function(pos)
179 update_pane(pos, "bar")
182 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
183 {'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}