Traitor/mods/vents/junction.lua
2022-05-23 20:51:28 -05:00

70 lines
1.8 KiB
Lua

--[[
Hyperloop Mod
=============
Copyright (C) 2017-2019 Joachim Stolberg
LGPLv2.1+
See LICENSE.txt for more information
]]--
-- for lazy programmers
local SP = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Load support for intllib.
local S = vents.S
local NS = vents.NS
local Tube = vents.Tube
local Stations = vents.Stations
Tube:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir)
if node.name == "vents:station" then
if out_dir <= 5 then
Stations:update_connections(pos, out_dir, peer_pos)
local s = vents.get_connection_string(pos)
M(pos):set_string("infotext", S("Station connected to ")..s)
end
elseif node.name == "vents:junction" then
Stations:update_connections(pos, out_dir, peer_pos)
local s = vents.get_connection_string(pos)
M(pos):set_string("infotext", S("Junction connected to ")..s)
elseif Tube.secondary_node_names[node.name] then
if out_dir == 5 then
Stations:update_connections(pos, out_dir, peer_pos)
local s = vents.get_connection_string(pos)
M(pos):set_string("conn_to", s)
end
end
end)
minetest.register_node("vents:junction", {
description = S("Vent Junction"),
tiles = {"vents_station_connection.png"},
after_place_node = function(pos, placer, itemstack, pointed_thing)
vents.check_network_level(pos, placer)
M(pos):set_string("infotext", S("Junction"))
Stations:set(pos, "Junction", {
owner = placer:get_player_name(), junction = true})
Tube:after_place_node(pos)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
Tube:after_dig_node(pos)
Stations:delete(pos)
end,
paramtype2 = "facedir",
on_rotate = screwdriver.disallow,
paramtype = "light",
groups = {breakable=1},
is_ground_content = false,
sounds = {footstep = {name = 'metal', gain = 1}},
})