Remove ugly def of xpanes
This commit is contained in:
parent
279b85fc45
commit
1f85f001f9
@ -17,11 +17,7 @@ local function update_pane(pos, name)
|
|||||||
end
|
end
|
||||||
local sum = 0
|
local sum = 0
|
||||||
for i, dir in pairs(directions) do
|
for i, dir in pairs(directions) do
|
||||||
local node = minetest.get_node({
|
local node = minetest.get_node(vector.add(pos, dir))
|
||||||
x = pos.x + dir.x,
|
|
||||||
y = pos.y + dir.y,
|
|
||||||
z = pos.z + dir.z
|
|
||||||
})
|
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
local pane_num = def and def.groups.pane or 0
|
local pane_num = def and def.groups.pane or 0
|
||||||
if pane_num > 0 or not def or (def.walkable ~= false and
|
if pane_num > 0 or not def or (def.walkable ~= false and
|
||||||
@ -50,14 +46,13 @@ local function update_nearby(pos, node)
|
|||||||
name = name:sub(8, underscore_pos - 1)
|
name = name:sub(8, underscore_pos - 1)
|
||||||
end
|
end
|
||||||
for i, dir in pairs(directions) do
|
for i, dir in pairs(directions) do
|
||||||
update_pane({
|
update_pane(vector.add(pos, dir), name)
|
||||||
x = pos.x + dir.x,
|
|
||||||
y = pos.y + dir.y,
|
|
||||||
z = pos.z + dir.z
|
|
||||||
}, name)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.register_on_placenode(update_nearby)
|
||||||
|
minetest.register_on_dignode(update_nearby)
|
||||||
|
|
||||||
local half_boxes = {
|
local half_boxes = {
|
||||||
{0, -0.5, -1/32, 0.5, 0.5, 1/32},
|
{0, -0.5, -1/32, 0.5, 0.5, 1/32},
|
||||||
{-1/32, -0.5, 0, 1/32, 0.5, 0.5},
|
{-1/32, -0.5, 0, 1/32, 0.5, 0.5},
|
||||||
@ -82,6 +77,18 @@ local sb_full_boxes = {
|
|||||||
{-0.06, -0.5, -0.5, 0.06, 0.5, 0.5}
|
{-0.06, -0.5, -0.5, 0.06, 0.5, 0.5}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local pane_def_fields = {
|
||||||
|
drawtype = "airlike",
|
||||||
|
paramtype = "light",
|
||||||
|
is_ground_content = false,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
|
pointable = false,
|
||||||
|
diggable = false,
|
||||||
|
buildable_to = true,
|
||||||
|
air_equivalent = true,
|
||||||
|
}
|
||||||
|
|
||||||
function xpanes.register_pane(name, def)
|
function xpanes.register_pane(name, def)
|
||||||
for i = 1, 15 do
|
for i = 1, 15 do
|
||||||
local need = {}
|
local need = {}
|
||||||
@ -132,6 +139,10 @@ function xpanes.register_pane(name, def)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for k, v in pairs(pane_def_fields) do
|
||||||
|
def[k] = def[k] or v
|
||||||
|
end
|
||||||
|
|
||||||
def.on_construct = function(pos)
|
def.on_construct = function(pos)
|
||||||
update_pane(pos, name)
|
update_pane(pos, name)
|
||||||
end
|
end
|
||||||
@ -144,52 +155,29 @@ function xpanes.register_pane(name, def)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_placenode(update_nearby)
|
|
||||||
minetest.register_on_dignode(update_nearby)
|
|
||||||
|
|
||||||
xpanes.register_pane("pane", {
|
xpanes.register_pane("pane", {
|
||||||
description = "Glass Pane",
|
description = "Glass Pane",
|
||||||
tiles = {"xpanes_space.png"},
|
|
||||||
drawtype = "airlike",
|
|
||||||
paramtype = "light",
|
|
||||||
is_ground_content = false,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
pointable = false,
|
|
||||||
diggable = false,
|
|
||||||
buildable_to = true,
|
|
||||||
air_equivalent = true,
|
|
||||||
textures = {"default_glass.png","xpanes_pane_half.png","xpanes_white.png"},
|
textures = {"default_glass.png","xpanes_pane_half.png","xpanes_white.png"},
|
||||||
inventory_image = "default_glass.png",
|
inventory_image = "default_glass.png",
|
||||||
wield_image = "default_glass.png",
|
wield_image = "default_glass.png",
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
|
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:glass', 'default:glass', 'default:glass'},
|
{"default:glass", "default:glass", "default:glass"},
|
||||||
{'default:glass', 'default:glass', 'default:glass'}
|
{"default:glass", "default:glass", "default:glass"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
xpanes.register_pane("bar", {
|
xpanes.register_pane("bar", {
|
||||||
description = "Iron bar",
|
description = "Iron bar",
|
||||||
tiles = {"xpanes_space.png"},
|
|
||||||
drawtype = "airlike",
|
|
||||||
paramtype = "light",
|
|
||||||
is_ground_content = false,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
pointable = false,
|
|
||||||
diggable = false,
|
|
||||||
buildable_to = true,
|
|
||||||
air_equivalent = true,
|
|
||||||
textures = {"xpanes_bar.png","xpanes_bar.png","xpanes_space.png"},
|
textures = {"xpanes_bar.png","xpanes_bar.png","xpanes_space.png"},
|
||||||
inventory_image = "xpanes_bar.png",
|
inventory_image = "xpanes_bar.png",
|
||||||
wield_image = "xpanes_bar.png",
|
wield_image = "xpanes_bar.png",
|
||||||
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
|
groups = {snappy=2, cracky=3, oddly_breakable_by_hand=3, pane=1},
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
recipe = {
|
recipe = {
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'},
|
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"},
|
||||||
{'default:steel_ingot', 'default:steel_ingot', 'default:steel_ingot'}
|
{"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user