2019-05-21 01:05:53 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
2020-01-26 01:15:44 +03:00
|
|
|
Copyright (C) 2019-2020 Joachim Stolberg
|
2019-05-21 01:05:53 +03:00
|
|
|
|
2020-10-19 20:09:17 +03:00
|
|
|
AGPL v3
|
2019-05-21 01:05:53 +03:00
|
|
|
See LICENSE.txt for more information
|
2022-01-03 23:40:31 +03:00
|
|
|
|
2019-05-21 01:05:53 +03:00
|
|
|
TA3/TA4 Junction box for electrical power distribution
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
-- for lazy programmers
|
|
|
|
local M = minetest.get_meta
|
2019-07-02 22:33:12 +03:00
|
|
|
local S = techage.S
|
2019-05-21 01:05:53 +03:00
|
|
|
|
2019-06-20 15:01:37 +03:00
|
|
|
local Cable = techage.ElectricCable
|
2021-06-05 12:42:30 +03:00
|
|
|
local power = networks.power
|
2019-06-20 15:01:37 +03:00
|
|
|
|
2019-05-21 01:05:53 +03:00
|
|
|
local size = 3/32
|
|
|
|
local Boxes = {
|
|
|
|
{{-size, -size, size, size, size, 0.5 }}, -- z+
|
|
|
|
{{-size, -size, -size, 0.5, size, size}}, -- x+
|
|
|
|
{{-size, -size, -0.5, size, size, size}}, -- z-
|
|
|
|
{{-0.5, -size, -size, size, size, size}}, -- x-
|
|
|
|
{{-size, -0.5, -size, size, size, size}}, -- y-
|
|
|
|
{{-size, -size, -size, size, 0.5, size}}, -- y+
|
|
|
|
}
|
|
|
|
|
2021-06-05 12:42:30 +03:00
|
|
|
local names = networks.register_junction("techage:electric_junction", 2/8, Boxes, Cable, {
|
2019-07-02 22:33:12 +03:00
|
|
|
description = S("TA Electric Junction Box"),
|
2019-05-21 01:05:53 +03:00
|
|
|
tiles = {"techage_electric_junction.png"},
|
2021-07-29 22:08:44 +03:00
|
|
|
use_texture_alpha = techage.CLIP,
|
2021-06-05 12:42:30 +03:00
|
|
|
is_ground_content = false,
|
2019-05-21 01:05:53 +03:00
|
|
|
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
|
|
|
|
sounds = default.node_sound_defaults(),
|
|
|
|
|
2020-01-26 01:15:44 +03:00
|
|
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
2021-06-05 12:42:30 +03:00
|
|
|
local name = "techage:electric_junction" .. networks.junction_type(pos, Cable)
|
2019-05-21 01:05:53 +03:00
|
|
|
minetest.swap_node(pos, {name = name, param2 = 0})
|
2020-01-26 01:15:44 +03:00
|
|
|
Cable:after_place_node(pos)
|
2019-05-21 01:05:53 +03:00
|
|
|
end,
|
2020-01-26 01:15:44 +03:00
|
|
|
tubelib2_on_update2 = function(pos, dir1, tlib2, node)
|
2021-06-05 21:18:04 +03:00
|
|
|
if not networks.hidden_name(pos) then
|
|
|
|
local name = "techage:electric_junction" .. networks.junction_type(pos, Cable)
|
|
|
|
minetest.swap_node(pos, {name = name, param2 = 0})
|
|
|
|
end
|
2021-06-05 12:42:30 +03:00
|
|
|
power.update_network(pos, 0, tlib2, node)
|
2019-07-02 22:33:12 +03:00
|
|
|
end,
|
2020-01-26 01:15:44 +03:00
|
|
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
|
|
Cable:after_dig_node(pos)
|
|
|
|
end,
|
|
|
|
})
|
2020-02-22 22:43:14 +03:00
|
|
|
|
2021-06-05 12:42:30 +03:00
|
|
|
power.register_nodes(names, Cable, "junc")
|
|
|
|
|
2020-02-25 21:43:27 +03:00
|
|
|
minetest.register_craft({
|
|
|
|
output = "techage:electric_junction0 2",
|
|
|
|
recipe = {
|
|
|
|
{"", "basic_materials:plastic_sheet", ""},
|
|
|
|
{"basic_materials:plastic_sheet", "default:copper_ingot", "basic_materials:plastic_sheet"},
|
|
|
|
{"", "basic_materials:plastic_sheet", ""},
|
|
|
|
},
|
2022-01-04 21:40:27 +03:00
|
|
|
})
|