Register walls as mvps stoppers

I also cleaned up the registration code somewhat.
This commit is contained in:
Jude Melton-Houghton 2021-07-14 22:09:06 -04:00
parent 031940b253
commit 3bd12ff1f4

101
nodes.lua
View File

@ -1,66 +1,63 @@
function merged_table(a, b)
local merged = table.copy(a)
local merged = {}
for key, value in pairs(a) do
merged[key] = value
end
for key, value in pairs(b) do
merged[key] = value
end
return merged
end
function area_containers.register_nodes()
-- Container node definition
local container_spec = table.copy(area_containers.container)
container_spec.tiles = {"area_containers_wall.png"}
container_spec.groups = {
crumbly = 3,
soil = 1,
tubedevice = 1,
tubedevice_receiver = 1,
}
minetest.register_node("area_containers:container", container_spec)
if minetest.global_exists("mesecon") and
mesecon.register_mvps_stopper then
--mesecon.register_mvps_stopper("area_containers:container")
end
-- Information shared by all walls
local wall_spec_base = {
function register_wall(local_name, def)
local name = "area_containers:" .. local_name
local base_def = {
paramtype = "light",
light_source = minetest.LIGHT_MAX,
groups = {not_in_creative_inventory = 1},
groups = {},
is_ground_content = false,
diggable = false,
on_blast = function() end,
}
-- Regular wall definition
local wall_spec = table.copy(wall_spec_base)
wall_spec.tiles = {"area_containers_wall.png"}
minetest.register_node("area_containers:wall", wall_spec)
-- Exit wall tile definition
local exit_spec = merged_table(wall_spec_base, area_containers.exit)
exit_spec.tiles = {
"area_containers_wall.png^area_containers_exit.png",
}
minetest.register_node("area_containers:exit", exit_spec)
-- Digiline port definition
local digiline_spec =
merged_table(wall_spec_base, area_containers.digiline)
digiline_spec.tiles = {
"area_containers_wall.png^area_containers_digiline.png",
}
minetest.register_node("area_containers:digiline", digiline_spec)
-- Pipe definition
local pipe_spec =
merged_table(wall_spec_base, area_containers.pipe)
pipe_spec.tiles = {
"area_containers_wall.png^area_containers_pipe.png",
}
pipe_spec.groups = merged_table(pipe_spec.groups, {
tubedevice = 1,
tubedevice_receiver = 1,
})
minetest.register_node("area_containers:pipe", pipe_spec)
local full_def = merged_table(base_def, def)
full_def.groups.not_in_creative_inventory = 1
minetest.register_node(name, def)
if minetest.global_exists("mesecon") and
mesecon.register_mvps_stopper then
mesecon.register_mvps_stopper(name)
end
end
function area_containers.register_nodes()
local container_def = merged_table(area_containers.container, {
tiles = {"area_containers_wall.png"},
groups = {
crumbly = 3,
soil = 1,
tubedevice = 1,
tubedevice_receiver = 1,
},
})
minetest.register_node("area_containers:container", container_def)
register_wall("wall", {
tiles = {"area_containers_wall.png"},
})
register_wall("exit", merged_table(area_containers.exit, {
tiles = {"area_containers_wall.png^area_containers_exit.png"},
}))
register_wall("digiline", merged_table(area_containers.digiline, {
tiles = {"area_containers_wall.png^" ..
"area_containers_digiline.png"},
}))
register_wall("pipe", merged_table(area_containers.pipe, {
tiles = {"area_containers_wall.png^area_containers_pipe.png"},
groups = {
tubedevice = 1,
tubedevice_receiver = 1,
},
}))
end