mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-11-09 17:03:58 +01:00
Make tubes opaque when entities are not used (#29)
* Make tubes opaque when entities are not used
This commit is contained in:
parent
e3d94cb3a8
commit
55ded7e569
@ -49,12 +49,13 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", {
|
|||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
description = S("Airtight panel embedded tube"),
|
description = S("Airtight panel embedded tube"),
|
||||||
tiles = {
|
tiles = {
|
||||||
"pipeworks_pane_embedded_tube_sides.png^[transformR90",
|
pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"),
|
||||||
"pipeworks_pane_embedded_tube_sides.png^[transformR90",
|
pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"),
|
||||||
"pipeworks_pane_embedded_tube_sides.png",
|
pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"),
|
||||||
"pipeworks_pane_embedded_tube_sides.png",
|
pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"),
|
||||||
"pipeworks_pane_embedded_tube_ends.png", "pipeworks_pane_embedded_tube_ends.png",
|
pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_ends.png"),
|
||||||
},
|
pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_ends.png"),
|
||||||
|
},
|
||||||
use_texture_alpha = texture_alpha_mode,
|
use_texture_alpha = texture_alpha_mode,
|
||||||
node_box = pane_box,
|
node_box = pane_box,
|
||||||
selection_box = pane_box,
|
selection_box = pane_box,
|
||||||
|
23
init.lua
23
init.lua
@ -69,6 +69,29 @@ function pipeworks.fix_image_names(table, replacement)
|
|||||||
return outtable
|
return outtable
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function overlay_tube_texture(texture)
|
||||||
|
-- The texture appears the first time to be colorized as the opaque background.
|
||||||
|
return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture)
|
||||||
|
end
|
||||||
|
|
||||||
|
function pipeworks.make_tube_tile(tile)
|
||||||
|
if pipeworks.use_real_entities then
|
||||||
|
return tile
|
||||||
|
elseif type(tile) == "string" then
|
||||||
|
return overlay_tube_texture(tile)
|
||||||
|
else
|
||||||
|
tile = table.copy(tile)
|
||||||
|
if tile.color then
|
||||||
|
-- Won't work 100% of the time, but good enough.
|
||||||
|
tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
|
||||||
|
tile.color = nil
|
||||||
|
end
|
||||||
|
tile.name = overlay_tube_texture(tile.name)
|
||||||
|
tile.backface_culling = nil -- The texture is opaque
|
||||||
|
return tile
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function pipeworks.add_node_box(t, b)
|
function pipeworks.add_node_box(t, b)
|
||||||
if not t or not b then return end
|
if not t or not b then return end
|
||||||
for i in ipairs(b)
|
for i in ipairs(b)
|
||||||
|
@ -143,10 +143,14 @@ local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
|
|||||||
and "clip" or true
|
and "clip" or true
|
||||||
|
|
||||||
if pipeworks.enable_one_way_tube then
|
if pipeworks.enable_one_way_tube then
|
||||||
|
local tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
|
||||||
|
"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"}
|
||||||
|
for i, tile in ipairs(tiles) do
|
||||||
|
tiles[i] = pipeworks.make_tube_tile(tile)
|
||||||
|
end
|
||||||
minetest.register_node("pipeworks:one_way_tube", {
|
minetest.register_node("pipeworks:one_way_tube", {
|
||||||
description = S("One way tube"),
|
description = S("One way tube"),
|
||||||
tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
|
tiles = tiles,
|
||||||
"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"},
|
|
||||||
use_texture_alpha = texture_alpha_mode,
|
use_texture_alpha = texture_alpha_mode,
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
|
@ -77,4 +77,5 @@ pipeworks_drop_on_routing_fail (Drop On Routing Fail) bool false
|
|||||||
pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true
|
pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true
|
||||||
|
|
||||||
#Use real visible entities in tubes within active areas.
|
#Use real visible entities in tubes within active areas.
|
||||||
|
#When disabled, tubes are made opaque.
|
||||||
pipeworks_use_real_entities (Use real entities) bool true
|
pipeworks_use_real_entities (Use real entities) bool true
|
||||||
|
@ -80,6 +80,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
|
|||||||
wscale = {x = 1, y = 1, z = 0.01}
|
wscale = {x = 1, y = 1, z = 0.01}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for i, tile in ipairs(outimgs) do
|
||||||
|
outimgs[i] = pipeworks.make_tube_tile(tile)
|
||||||
|
end
|
||||||
|
|
||||||
local rname = string.format("%s_%s", name, tname)
|
local rname = string.format("%s_%s", name, tname)
|
||||||
table.insert(tubenodes, rname)
|
table.insert(tubenodes, rname)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user