techage_modpack/techage/power/junctionbox.lua

67 lines
1.9 KiB
Lua
Raw Permalink Normal View History

2020-05-31 23:31:18 +03:00
--[[
TechAge
=======
Copyright (C) 2019-2020 Joachim Stolberg
2020-10-25 23:32:47 +03:00
AGPL v3
2020-05-31 23:31:18 +03:00
See LICENSE.txt for more information
2022-01-04 21:43:30 +03:00
2020-05-31 23:31:18 +03:00
TA3/TA4 Junction box for electrical power distribution
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local Cable = techage.ElectricCable
2021-08-01 12:00:22 +03:00
local power = networks.power
2020-05-31 23:31:18 +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-08-01 12:00:22 +03:00
local names = networks.register_junction("techage:electric_junction", 2/8, Boxes, Cable, {
2020-05-31 23:31:18 +03:00
description = S("TA Electric Junction Box"),
tiles = {"techage_electric_junction.png"},
2021-08-01 12:00:22 +03:00
use_texture_alpha = techage.CLIP,
is_ground_content = false,
2020-05-31 23:31:18 +03:00
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
sounds = default.node_sound_defaults(),
after_place_node = function(pos, placer, itemstack, pointed_thing)
2021-08-01 12:00:22 +03:00
local name = "techage:electric_junction" .. networks.junction_type(pos, Cable)
2020-05-31 23:31:18 +03:00
minetest.swap_node(pos, {name = name, param2 = 0})
Cable:after_place_node(pos)
end,
tubelib2_on_update2 = function(pos, dir1, tlib2, node)
2021-08-01 12:00:22 +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
power.update_network(pos, 0, tlib2, node)
2020-05-31 23:31:18 +03:00
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Cable:after_dig_node(pos)
end,
})
2021-08-01 12:00:22 +03:00
power.register_nodes(names, Cable, "junc")
2020-05-31 23:31:18 +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", ""},
},
})