Skip to content

Commit 1f85f00

Browse files
Rui914paramat
Rui914
authored andcommittedSep 29, 2015
Remove ugly def of xpanes
1 parent 279b85f commit 1f85f00

File tree

1 file changed

+25
-37
lines changed

1 file changed

+25
-37
lines changed
 

Diff for: ‎mods/xpanes/init.lua

+25-37
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ local function update_pane(pos, name)
1717
end
1818
local sum = 0
1919
for i, dir in pairs(directions) do
20-
local node = minetest.get_node({
21-
x = pos.x + dir.x,
22-
y = pos.y + dir.y,
23-
z = pos.z + dir.z
24-
})
20+
local node = minetest.get_node(vector.add(pos, dir))
2521
local def = minetest.registered_nodes[node.name]
2622
local pane_num = def and def.groups.pane or 0
2723
if pane_num > 0 or not def or (def.walkable ~= false and
@@ -50,14 +46,13 @@ local function update_nearby(pos, node)
5046
name = name:sub(8, underscore_pos - 1)
5147
end
5248
for i, dir in pairs(directions) do
53-
update_pane({
54-
x = pos.x + dir.x,
55-
y = pos.y + dir.y,
56-
z = pos.z + dir.z
57-
}, name)
49+
update_pane(vector.add(pos, dir), name)
5850
end
5951
end
6052

53+
minetest.register_on_placenode(update_nearby)
54+
minetest.register_on_dignode(update_nearby)
55+
6156
local half_boxes = {
6257
{0, -0.5, -1/32, 0.5, 0.5, 1/32},
6358
{-1/32, -0.5, 0, 1/32, 0.5, 0.5},
@@ -82,6 +77,18 @@ local sb_full_boxes = {
8277
{-0.06, -0.5, -0.5, 0.06, 0.5, 0.5}
8378
}
8479

80+
local pane_def_fields = {
81+
drawtype = "airlike",
82+
paramtype = "light",
83+
is_ground_content = false,
84+
sunlight_propagates = true,
85+
walkable = false,
86+
pointable = false,
87+
diggable = false,
88+
buildable_to = true,
89+
air_equivalent = true,
90+
}
91+
8592
function xpanes.register_pane(name, def)
8693
for i = 1, 15 do
8794
local need = {}
@@ -132,6 +139,10 @@ function xpanes.register_pane(name, def)
132139
})
133140
end
134141

142+
for k, v in pairs(pane_def_fields) do
143+
def[k] = def[k] or v
144+
end
145+
135146
def.on_construct = function(pos)
136147
update_pane(pos, name)
137148
end
@@ -144,52 +155,29 @@ function xpanes.register_pane(name, def)
144155
})
145156
end
146157

147-
minetest.register_on_placenode(update_nearby)
148-
minetest.register_on_dignode(update_nearby)
149-
150158
xpanes.register_pane("pane", {
151159
description = "Glass Pane",
152-
tiles = {"xpanes_space.png"},
153-
drawtype = "airlike",
154-
paramtype = "light",
155-
is_ground_content = false,
156-
sunlight_propagates = true,
157-
walkable = false,
158-
pointable = false,
159-
diggable = false,
160-
buildable_to = true,
161-
air_equivalent = true,
162160
textures = {"default_glass.png","xpanes_pane_half.png","xpanes_white.png"},
163161
inventory_image = "default_glass.png",
164162
wield_image = "default_glass.png",
165163
sounds = default.node_sound_glass_defaults(),
166164
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
167165
recipe = {
168-
{'default:glass', 'default:glass', 'default:glass'},
169-
{'default:glass', 'default:glass', 'default:glass'}
166+
{"default:glass", "default:glass", "default:glass"},
167+
{"default:glass", "default:glass", "default:glass"}
170168
}
171169
})
172170

173171
xpanes.register_pane("bar", {
174172
description = "Iron bar",
175-
tiles = {"xpanes_space.png"},
176-
drawtype = "airlike",
177-
paramtype = "light",
178-
is_ground_content = false,
179-
sunlight_propagates = true,
180-
walkable = false,
181-
pointable = false,
182-
diggable = false,
183-
buildable_to = true,
184-
air_equivalent = true,
185173
textures = {"xpanes_bar.png","xpanes_bar.png","xpanes_space.png"},
186174
inventory_image = "xpanes_bar.png",
187175
wield_image = "xpanes_bar.png",
188176
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
189177
sounds = default.node_sound_stone_defaults(),
190178
recipe = {
191-
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
192-
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}
179+
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
180+
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
193181
}
194182
})
195183

0 commit comments

Comments
 (0)
Please sign in to comment.