Doors: Clean up nodedef usage

Allows for more properties to be passed through. Somewhat simplifies
the code as well.
This commit is contained in:
Auke Kok 2016-03-12 16:12:37 -08:00 committed by paramat
parent 5775c9147c
commit 3e9afe097c

View File

@ -321,6 +321,15 @@ function doors.register(name, def)
return itemstack return itemstack
end end
}) })
def.inventory_image = nil
if def.recipe then
minetest.register_craft({
output = name,
recipe = def.recipe,
})
end
def.recipe = nil
local can_dig = function(pos, digger) local can_dig = function(pos, digger)
if not def.protected then if not def.protected then
@ -386,76 +395,22 @@ function doors.register(name, def)
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
end end
minetest.register_node(":" .. name .. "_a", { def.drawtype = "mesh"
description = def.description, def.paramtype = "light"
visual = "mesh", def.paramtype2 = "facedir"
mesh = "door_a.obj", def.sunlight_propagates = true
tiles = def.tiles, def.use_texture_alpha = true
drawtype = "mesh", def.walkable = true
paramtype = "light", def.is_ground_content = false
paramtype2 = "facedir", def.buildable_to = false
sunlight_propagates = true, def.selection_box = { type = "fixed", fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16} }
walkable = true, def.collision_box = { type = "fixed", fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16} }
is_ground_content = false,
buildable_to = false,
drop = def.drop,
groups = def.groups,
sounds = def.sounds,
door = def.door,
on_rightclick = def.on_rightclick,
after_dig_node = def.after_dig_node,
can_dig = def.can_dig,
on_rotate = def.on_rotate,
on_blast = def.on_blast,
on_destruct = def.on_destruct,
selection_box = {
type = "fixed",
fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16}
},
collision_box = {
type = "fixed",
fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16}
},
})
minetest.register_node(":" .. name .. "_b", { def.mesh = "door_a.obj"
description = def.description, minetest.register_node(":" .. name .. "_a", def)
visual = "mesh",
mesh = "door_b.obj",
tiles = def.tiles,
drawtype = "mesh",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
walkable = true,
is_ground_content = false,
buildable_to = false,
drop = def.drop,
groups = def.groups,
sounds = def.sounds,
door = def.door,
on_rightclick = def.on_rightclick,
after_dig_node = def.after_dig_node,
can_dig = def.can_dig,
on_rotate = def.on_rotate,
on_blast = def.on_blast,
on_destruct = def.on_destruct,
selection_box = {
type = "fixed",
fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16}
},
collision_box = {
type = "fixed",
fixed = { -1/2,-1/2,-1/2,1/2,3/2,-6/16}
},
})
if def.recipe then def.mesh = "door_b.obj"
minetest.register_craft({ minetest.register_node(":" .. name .. "_b", def)
output = name,
recipe = def.recipe,
})
end
_doors.registered_doors[name .. "_a"] = true _doors.registered_doors[name .. "_a"] = true
_doors.registered_doors[name .. "_b"] = true _doors.registered_doors[name .. "_b"] = true