Label ports in their textures

The outside wire labels are consistent with the luacontroller.
This commit is contained in:
Jude Melton-Houghton 2021-07-17 11:59:34 -04:00
parent 905f4398a4
commit 6259ad403d
8 changed files with 46 additions and 46 deletions

View File

@ -14,22 +14,17 @@ local container_name_prefix = "area_containers:container_"
local exit_offset = vector.new(0, 2, 1)
local digiline_offset = vector.new(3, 0, 3)
local port_labels = {
px = "+X", nx = "-X",
pz = "+Z", nz = "-Z",
py = "+Y", ny = "-Y",
}
local port_offsets = {
px = vector.new(0, 2, 4), nx = vector.new(0, 2, 6),
pz = vector.new(0, 2, 8), nz = vector.new(0, 2, 10),
nx = vector.new(0, 2, 4), pz = vector.new(0, 2, 6),
px = vector.new(0, 2, 8), nz = vector.new(0, 2, 10),
py = vector.new(0, 2, 12), ny = vector.new(0, 2, 14),
}
local port_dirs = {
px = vector.new(1, 0, 0), nx = vector.new(-1, 0, 0),
pz = vector.new(0, 0, 1), nz = vector.new(0, 0, -1),
nx = vector.new(-1, 0, 0), pz = vector.new(0, 0, 1),
px = vector.new(1, 0, 0), nz = vector.new(0, 0, -1),
py = vector.new(0, 1, 0), ny = vector.new(0, -1, 0),
}
local port_ids_horiz = {"px", "nx", "pz", "nz"}
local port_ids_horiz = {"nx", "pz", "px", "nz"}
local port_name_prefix = "area_containers:port_"
@ -68,8 +63,6 @@ local function set_up_ports(param1, param2, inside_pos)
name = port_name_prefix .. id .. "_off",
param1 = param1, param2 = param2,
})
local meta = minetest.get_meta(pos)
meta:set_string("infotext", port_labels[id])
end
end
@ -275,6 +268,11 @@ area_containers.container.mesecons = {conductor = {
states = area_containers.all_container_states,
}}
local function container_rules_add_port(rules, port_id, self_pos, inside_pos)
local port_pos = vector.add(inside_pos, port_offsets[port_id])
local offset_to_port = vector.subtract(port_pos, self_pos)
rules[#rules + 1] = offset_to_port
end
function area_containers.container.mesecons.conductor.rules(node)
local rules = {
{
@ -303,13 +301,10 @@ function area_containers.container.mesecons.conductor.rules(node)
if self_pos then
local inside_pos = area_containers.get_related_inside(
node.param1, node.param2)
for i, id in ipairs(port_ids_horiz) do
local port_pos =
vector.add(inside_pos, port_offsets[id])
local offset = vector.subtract(port_pos, self_pos)
local face_rules = rules[i]
face_rules[#face_rules + 1] = offset
end
container_rules_add_port(rules[1], "px", self_pos, inside_pos)
container_rules_add_port(rules[2], "nx", self_pos, inside_pos)
container_rules_add_port(rules[3], "pz", self_pos, inside_pos)
container_rules_add_port(rules[4], "nz", self_pos, inside_pos)
end
return rules
end

View File

@ -41,13 +41,11 @@ local function register_wall(local_name, def)
end
function area_containers.register_nodes()
local outer_tile_on = "area_containers_outer_port.png"
local outer_tile_off = "area_containers_outer_port.png"
if minetest.global_exists("mesecon") then
outer_tile_on = outer_tile_on .. "^" ..
outer_wire_texture(mesecon_on_color)
outer_tile_off = outer_tile_off .. "^" ..
outer_wire_texture(mesecon_off_color)
local container_tiles = {}
local container_tile_ids = {"py", "ny", "px", "nx", "pz", "nz"}
for i, id in ipairs(container_tile_ids) do
container_tiles[i] = "area_containers_outer_port.png^" ..
"area_containers_" .. id .. ".png"
end
local container_activations = {
{0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 0, 1, 1},
@ -58,20 +56,26 @@ function area_containers.register_nodes()
for i, name in ipairs(area_containers.all_container_states) do
local container_def = merged_table(area_containers.container, {
description = "Area container",
tiles = {
"area_containers_outer_port.png", -- +Y
"area_containers_outer_port.png", -- -Y
"area_containers_outer_port.png", -- +X
"area_containers_outer_port.png", -- -X
"area_containers_outer_port.png", -- +Z
"area_containers_outer_port.png", -- -Z
},
tiles = table.copy(container_tiles),
drop = area_containers.all_container_states[1],
})
local activation = container_activations[i]
local tile_choices = {outer_tile_off, outer_tile_on}
for i, active in ipairs(activation) do
container_def.tiles[7 - i] = tile_choices[active + 1]
if minetest.global_exists("mesecon") then
local activation = container_activations[i]
local wire_choices = {
outer_wire_texture(mesecon_off_color),
outer_wire_texture(mesecon_on_color),
}
for i, active in ipairs(activation) do
-- The tile corresponding to this bit:
local tile_idx = 7 - i
local label = "area_containers_" ..
container_tile_ids[tile_idx] .. ".png"
container_def.tiles[tile_idx] = table.concat({
"area_containers_outer_port.png",
wire_choices[active + 1],
label,
}, "^")
end
end
if minetest.global_exists("default") and
default.node_sound_metal_defaults then
@ -113,6 +117,7 @@ function area_containers.register_nodes()
for variant, def in pairs(area_containers.all_port_variants) do
local full_def = merged_table(area_containers.port, def)
full_def.description = "Container's mesecon/tube connection"
local tile = "area_containers_wall.png"
local mesecons_spec = full_def.mesecons
if mesecons_spec and mesecon_maybe.state then
local color = mesecon_off_color
@ -121,15 +126,15 @@ function area_containers.register_nodes()
mesecons_spec.conductor.state == on then
color = mesecon_on_color
end
full_def.tiles = {table.concat({
"area_containers_wall.png",
wire_texture(color),
"area_containers_port.png",
}, "^")}
else
full_def.tiles = {"area_containers_wall.png^" ..
"area_containers_port.png"}
tile = tile .. "^" .. wire_texture(color)
end
local label_id = string.sub(variant, 1, 2)
tile = table.concat({
tile, "^",
"area_containers_port.png^",
"area_containers_", label_id, ".png",
}, "")
full_def.tiles = {tile}
register_wall("port_" .. variant, full_def)
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B