This commit is contained in:
Joachim Stolberg 2021-07-19 20:37:31 +02:00
parent 0b34edb5de
commit 10120979cd
4 changed files with 35 additions and 14 deletions

View File

@ -44,7 +44,7 @@ end
local function formspec1(pos, data)
local mem = techage.get_mem(pos)
local outdir = M(pos):get_int("outdir")
local netw = networks.get_network_table(pos, Cable, outdir) or {}
local netw = networks.get_network_table(pos, Cable, outdir, true) or {}
data = data or power.get_network_data(pos, Cable, outdir)
mem.star = ((mem.star or 0) + 1) % 2

View File

@ -29,6 +29,18 @@ local Param2ToDir = {
[5] = 3,
}
local function sign_in(pos, node)
local dir = Param2ToDir[node.param2]
local pos2 = tubelib2.get_pos(pos, dir)
M(pos2):set_int("switch_sign_in", 1)
end
local function sign_off(pos, node)
local dir = Param2ToDir[node.param2]
local pos2 = tubelib2.get_pos(pos, dir)
M(pos2):set_int("switch_sign_in", 0)
end
local function switch_on(pos, node, clicker, name)
if clicker and minetest.is_protected(pos, clicker:get_player_name()) then
return
@ -64,7 +76,6 @@ local function switch_off(pos, node, clicker, name)
techage.legacy_switches(pos2)
power.turn_switch_off(pos2, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on")
end
@ -92,12 +103,14 @@ minetest.register_node("techage:powerswitch", {
meta:set_string("infotext", S("TA Power Switch").." "..number)
local node = minetest.get_node(pos)
switch_on(pos, node, placer, "techage:powerswitch_on")
sign_in(pos, node)
end,
on_rightclick = function(pos, node, clicker)
switch_on(pos, node, clicker, "techage:powerswitch_on")
end,
after_dig_node = sign_off,
on_rotate = screwdriver.disallow,
paramtype = "light",
use_texture_alpha = techage.CLIP,
@ -129,6 +142,7 @@ minetest.register_node("techage:powerswitch_on", {
switch_off(pos, node, clicker, "techage:powerswitch")
end,
after_dig_node = sign_off,
drop = "techage:powerswitch",
on_rotate = screwdriver.disallow,
paramtype = "light",
@ -164,12 +178,14 @@ minetest.register_node("techage:powerswitchsmall", {
meta:set_string("infotext", S("TA Power Switch Small").." "..number)
local node = minetest.get_node(pos)
switch_on(pos, node, placer, "techage:powerswitchsmall_on")
sign_in(pos, node)
end,
on_rightclick = function(pos, node, clicker)
switch_on(pos, node, clicker, "techage:powerswitchsmall_on")
end,
after_dig_node = sign_off,
on_rotate = screwdriver.disallow,
paramtype = "light",
use_texture_alpha = techage.CLIP,
@ -201,6 +217,7 @@ minetest.register_node("techage:powerswitchsmall_on", {
switch_off(pos, node, clicker, "techage:powerswitchsmall")
end,
after_dig_node = sign_off,
drop = "techage:powerswitchsmall",
on_rotate = screwdriver.disallow,
paramtype = "light",

View File

@ -77,11 +77,13 @@ minetest.register_node("techage:powerswitch_box_on", {
end,
on_rightclick = function(pos, node, clicker)
techage.legacy_switches(pos)
if power.turn_switch_off(pos, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on") then
minetest.sound_play("doors_glass_door_open", {
pos = pos,
gain = 1,
max_hear_distance = 5})
if M(pos):get_int("switch_sign_in") ~= 1 then
if power.turn_switch_off(pos, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on") then
minetest.sound_play("doors_glass_door_open", {
pos = pos,
gain = 1,
max_hear_distance = 5})
end
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
@ -112,11 +114,13 @@ minetest.register_node("techage:powerswitch_box_off", {
},
on_rightclick = function(pos, node, clicker)
techage.legacy_switches(pos)
if power.turn_switch_on(pos, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on") then
minetest.sound_play("doors_glass_door_open", {
pos = pos,
gain = 1,
max_hear_distance = 5})
if M(pos):get_int("switch_sign_in") ~= 1 then
if power.turn_switch_on(pos, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on") then
minetest.sound_play("doors_glass_door_open", {
pos = pos,
gain = 1,
max_hear_distance = 5})
end
end
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)

View File

@ -30,7 +30,7 @@ local COUNTDOWN_TICKS = 1
local function determine_power(pos, nvm)
-- determine DC node position
local outdir = M(pos):get_int("leftdir")
local netw = networks.get_network_table(pos, Solar, outdir) or {}
local netw = networks.get_network_table(pos, Solar, outdir, true) or {}
local num_inv = #(netw.con or {})
local max_power = 0
for _, power in ipairs(control.request(pos, Solar, outdir, "junc", "power")) do
@ -124,7 +124,7 @@ local function node_timer(pos, elapsed)
stop_node(pos, nvm, State)
elseif not running and has_power then
State:start(pos, nvm)
-- start_node() is called implicit
-- start_node() is called implicit
elseif running then
local meta = M(pos)
local outdir = meta:get_int("outdir")