Add support for colored cables
As requested by player "anju64".
This commit is contained in:
parent
3918f61437
commit
4770885e5f
@ -32,7 +32,9 @@ local Cable = tubelib2.Tube:new({
|
|||||||
"techage:power_pole2", "techage:powerswitch_box", "techage:powerswitch_box_on"},
|
"techage:power_pole2", "techage:powerswitch_box", "techage:powerswitch_box_on"},
|
||||||
secondary_node_names = {},
|
secondary_node_names = {},
|
||||||
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||||
local name = minetest.get_node(pos).name
|
local node = minetest.get_node(pos)
|
||||||
|
local name = node.name
|
||||||
|
local color_param2 = math.floor(node.param2 / 32) * 32
|
||||||
if name == "techage:powerswitch_box" or name == "techage:powerswitch_box_on" or name == "techage:powerswitch_box_off" then
|
if name == "techage:powerswitch_box" or name == "techage:powerswitch_box_on" or name == "techage:powerswitch_box_off" then
|
||||||
minetest.swap_node(pos, {name = name, param2 = param2 % 32})
|
minetest.swap_node(pos, {name = name, param2 = param2 % 32})
|
||||||
elseif name == "techage:power_line" or name == "techage:power_lineS" or name == "techage:power_lineA" then
|
elseif name == "techage:power_line" or name == "techage:power_lineS" or name == "techage:power_lineA" then
|
||||||
@ -40,9 +42,10 @@ local Cable = tubelib2.Tube:new({
|
|||||||
elseif name == "techage:power_pole2" then
|
elseif name == "techage:power_pole2" then
|
||||||
-- nothing
|
-- nothing
|
||||||
elseif not networks.hidden_name(pos) then
|
elseif not networks.hidden_name(pos) then
|
||||||
minetest.swap_node(pos, {name = "techage:electric_cable"..tube_type, param2 = param2 % 32})
|
minetest.swap_node(pos, {name = "techage:electric_cable"..tube_type, param2 = param2 % 32 + color_param2})
|
||||||
end
|
end
|
||||||
M(pos):set_int("netw_param2", param2)
|
M(pos):set_int("netw_param2", param2)
|
||||||
|
M(pos):set_int("netw_color_param2", color_param2)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -55,6 +58,15 @@ Cable:register_on_tube_update2(function(pos, outdir, tlib2, node)
|
|||||||
power.update_network(pos, outdir, tlib2, node)
|
power.update_network(pos, outdir, tlib2, node)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
local preserve_metadata = function(pos, oldnode, oldmeta, drops)
|
||||||
|
for _,drop in ipairs(drops) do
|
||||||
|
local meta = drop:get_meta()
|
||||||
|
if meta:get_int("palette_index") == 0 then
|
||||||
|
meta:set_string("palette_index", "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("techage:electric_cableS", {
|
minetest.register_node("techage:electric_cableS", {
|
||||||
description = S("TA Electric Cable"),
|
description = S("TA Electric Cable"),
|
||||||
tiles = {
|
tiles = {
|
||||||
@ -63,8 +75,16 @@ minetest.register_node("techage:electric_cableS", {
|
|||||||
"techage_electric_cable.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable_end.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable_end.png",
|
"techage_electric_cable.png",
|
||||||
|
},
|
||||||
|
overlay_tiles = {
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||||
|
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||||
},
|
},
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
@ -79,7 +99,8 @@ minetest.register_node("techage:electric_cableS", {
|
|||||||
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
paramtype2 = "colorfacedir", -- important!
|
||||||
|
palette = "techage_cable_palette.png",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
@ -94,6 +115,7 @@ minetest.register_node("techage:electric_cableS", {
|
|||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
|
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
|
preserve_metadata = preserve_metadata,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("techage:electric_cableA", {
|
minetest.register_node("techage:electric_cableA", {
|
||||||
@ -101,18 +123,27 @@ minetest.register_node("techage:electric_cableA", {
|
|||||||
tiles = {
|
tiles = {
|
||||||
-- up, down, right, left, back, front
|
-- up, down, right, left, back, front
|
||||||
"techage_electric_cable.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable_end.png",
|
|
||||||
"techage_electric_cable.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable.png",
|
"techage_electric_cable.png",
|
||||||
"techage_electric_cable_end.png",
|
"techage_electric_cable.png",
|
||||||
|
"techage_electric_cable.png",
|
||||||
|
},
|
||||||
|
overlay_tiles = {
|
||||||
|
"",
|
||||||
|
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
{ name = "techage_electric_cable_end.png", color = "white" },
|
||||||
},
|
},
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
paramtype2 = "colorfacedir", -- important!
|
||||||
|
palette = "techage_cable_palette.png",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
@ -129,7 +160,12 @@ minetest.register_node("techage:electric_cableA", {
|
|||||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3,
|
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3,
|
||||||
techage_trowel = 1, not_in_creative_inventory = 1},
|
techage_trowel = 1, not_in_creative_inventory = 1},
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
drop = "techage:electric_cableS",
|
drop = {
|
||||||
|
items = {
|
||||||
|
{ items = { "techage:electric_cableS" }, inherit_color = true },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
preserve_metadata = preserve_metadata,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
@ -142,4 +178,16 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
|
|
||||||
techage.ElectricCable = Cable
|
techage.ElectricCable = Cable
|
||||||
techage.ELE1_MAX_CABLE_LENGHT = ELE1_MAX_CABLE_LENGHT
|
techage.ELE1_MAX_CABLE_LENGTH = ELE1_MAX_CABLE_LENGTH
|
||||||
|
|
||||||
|
|
||||||
|
for idx, color in ipairs({ "white", "grey", "black", "brown", "yellow", "red", "dark_green", "blue" }) do
|
||||||
|
minetest.register_craft({
|
||||||
|
output = idx == 1 and "techage:electric_cableS 8" or minetest.itemstring_with_palette("techage:electric_cableS 8", (idx-1)*32),
|
||||||
|
recipe = {
|
||||||
|
{ "techage:electric_cableS", "techage:electric_cableS", "techage:electric_cableS", },
|
||||||
|
{ "techage:electric_cableS", "dye:"..color, "techage:electric_cableS", },
|
||||||
|
{ "techage:electric_cableS", "techage:electric_cableS", "techage:electric_cableS", },
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
BIN
textures/techage_cable_palette.png
Normal file
BIN
textures/techage_cable_palette.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 134 B |
Binary file not shown.
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 123 B |
Loading…
Reference in New Issue
Block a user