techage/power/junctionbox.lua

56 lines
1.6 KiB
Lua
Raw Normal View History

2019-05-21 01:05:53 +03:00
--[[
TechAge
=======
Copyright (C) 2019 Joachim Stolberg
LGPLv2.1+
See LICENSE.txt for more information
TA3/TA4 Junction box for electrical power distribution
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
2019-05-21 01:05:53 +03:00
2019-06-20 15:01:37 +03:00
local Cable = techage.ElectricCable
2019-08-15 18:06:58 +03:00
local power = techage.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+
}
2019-06-20 15:01:37 +03:00
techage.register_junction("techage:electric_junction", 2/8, Boxes, Cable, {
description = S("TA Electric Junction Box"),
2019-05-21 01:05:53 +03:00
tiles = {"techage_electric_junction.png"},
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 3, techage_trowel = 1},
sounds = default.node_sound_defaults(),
on_construct = tubelib2.init_mem,
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
2019-06-20 15:01:37 +03:00
local name = "techage:electric_junction"..techage.junction_type(pos, Cable)
2019-05-21 01:05:53 +03:00
minetest.swap_node(pos, {name = name, param2 = 0})
2019-08-15 18:06:58 +03:00
power.network_changed(pos, tubelib2.get_mem(pos))
2019-05-21 01:05:53 +03:00
end,
is_power_available = function(pos)
2019-08-15 18:06:58 +03:00
return techage.power.power_accounting(pos, tubelib2.get_mem(pos))
end,
})
2019-05-21 01:05:53 +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", ""},
},
})