1 local function rshift(x, by)
2 return math.floor(x / 2 ^ by)
8 {x = -1, y = 0, z = 0},
9 {x = 0, y = 0, z = -1},
12 local function update_pane(pos,name)
13 if minetest.get_node(pos).name:find("xpanes:"..name) == nil then
18 local node = minetest.get_node({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z})
19 local pane_num = minetest.registered_nodes[node.name].groups.pane or 0
20 if (minetest.registered_nodes[node.name].walkable ~= false and minetest.registered_nodes[node.name].drawtype ~= "nodebox") or pane_num > 0 then
21 sum = sum + 2 ^ (i - 1)
27 minetest.set_node(pos, {name = "xpanes:"..name.."_"..sum})
30 local function update_nearby(pos,n)
31 if n == nil then n = minetest.get_node(pos) end
32 if not n or not n.name then return end
33 local name = string.sub(n.name,8,10)
34 if name ~= "bar" then name = "pane" end
36 update_pane({x = pos.x + directions[i].x, y = pos.y + directions[i].y, z = pos.z + directions[i].z}, name)
41 {0, -0.5, -1/32, 0.5, 0.5, 1/32},
42 {-1/32, -0.5, 0, 1/32, 0.5, 0.5},
43 {-0.5, -0.5, -1/32, 0, 0.5, 1/32},
44 {-1/32, -0.5, -0.5, 1/32, 0.5, 0}
48 {-0.5, -0.5, -1/32, 0.5, 0.5, 1/32},
49 {-1/32, -0.5, -0.5, 1/32, 0.5, 0.5}
52 local sb_half_blocks = {
53 {0, -0.5, -0.06, 0.5, 0.5, 0.06},
54 {-0.06, -0.5, 0, 0.06, 0.5, 0.5},
55 {-0.5, -0.5, -0.06, 0, 0.5, 0.06},
56 {-0.06, -0.5, -0.5, 0.06, 0.5, 0}
59 local sb_full_blocks = {
60 {-0.5, -0.5, -0.06, 0.5, 0.5, 0.06},
61 {-0.06, -0.5, -0.5, 0.06, 0.5, 0.5}
63 --register panes and bars
64 local function register_panes(name, def)
69 if rshift(i, j - 1) % 2 == 1 then
76 if need[1] == true and need[3] == true then
79 table.insert(take, full_blocks[1])
80 table.insert(take2, sb_full_blocks[1])
82 if need[2] == true and need[4] == true then
85 table.insert(take, full_blocks[2])
86 table.insert(take2, sb_full_blocks[2])
88 for k in pairs(need) do
89 table.insert(take, half_blocks[k])
90 table.insert(take2, sb_half_blocks[k])
92 local texture = def.textures[1]
94 texture = def.textures[1].."^"..def.textures[2]
96 minetest.register_node("xpanes:"..name.."_"..i, {
98 tiles = {def.textures[3], def.textures[3], texture},
101 drop = "xpanes:"..name,
114 minetest.register_node("xpanes:"..name, def)
116 minetest.register_craft({
117 output = "xpanes:"..name.." 16",
122 minetest.register_on_placenode(update_nearby)
123 minetest.register_on_dignode(update_nearby)
125 register_panes("pane", {
126 description = "Glass Pane",
127 tiles = {"xpanes_space.png"},
128 drawtype = "airlike",
130 sunlight_propagates = true,
135 air_equivalent = true,
136 textures = {"default_glass.png","xpanes_pane_half.png","xpanes_white.png"},
137 inventory_image = "default_glass.png",
138 wield_image = "default_glass.png",
139 sounds = default.node_sound_glass_defaults(),
140 groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,pane=1},
141 on_construct = function(pos)
142 update_pane(pos, "pane")
145 {'default:glass', 'default:glass', 'default:glass'},
146 {'default:glass', 'default:glass', 'default:glass'}
150 register_panes("bar", {
151 description = "Iron bar",
152 tiles = {"xpanes_space.png"},
153 drawtype = "airlike",
155 sunlight_propagates = true,
160 air_equivalent = true,
161 textures = {"xpanes_bar.png","xpanes_bar.png","xpanes_space.png"},
162 inventory_image = "xpanes_bar.png",
163 wield_image = "xpanes_bar.png",
164 groups = {snappy=2,cracky=3,oddly_breakable_by_hand=3,pane=1},
165 sounds = default.node_sound_stone_defaults(),
166 on_construct = function(pos)
167 update_pane(pos, "bar")
170 {'default:steel_ingot', 'default:glass', 'default:glass'},
171 {'default:glass', 'default:glass', 'default:glass'}