Fix bugs
This commit is contained in:
parent
0b34edb5de
commit
10120979cd
@ -44,7 +44,7 @@ end
|
|||||||
local function formspec1(pos, data)
|
local function formspec1(pos, data)
|
||||||
local mem = techage.get_mem(pos)
|
local mem = techage.get_mem(pos)
|
||||||
local outdir = M(pos):get_int("outdir")
|
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)
|
data = data or power.get_network_data(pos, Cable, outdir)
|
||||||
|
|
||||||
mem.star = ((mem.star or 0) + 1) % 2
|
mem.star = ((mem.star or 0) + 1) % 2
|
||||||
|
@ -29,6 +29,18 @@ local Param2ToDir = {
|
|||||||
[5] = 3,
|
[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)
|
local function switch_on(pos, node, clicker, name)
|
||||||
if clicker and minetest.is_protected(pos, clicker:get_player_name()) then
|
if clicker and minetest.is_protected(pos, clicker:get_player_name()) then
|
||||||
return
|
return
|
||||||
@ -64,7 +76,6 @@ local function switch_off(pos, node, clicker, name)
|
|||||||
|
|
||||||
techage.legacy_switches(pos2)
|
techage.legacy_switches(pos2)
|
||||||
power.turn_switch_off(pos2, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on")
|
power.turn_switch_off(pos2, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -92,12 +103,14 @@ minetest.register_node("techage:powerswitch", {
|
|||||||
meta:set_string("infotext", S("TA Power Switch").." "..number)
|
meta:set_string("infotext", S("TA Power Switch").." "..number)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
switch_on(pos, node, placer, "techage:powerswitch_on")
|
switch_on(pos, node, placer, "techage:powerswitch_on")
|
||||||
|
sign_in(pos, node)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
switch_on(pos, node, clicker, "techage:powerswitch_on")
|
switch_on(pos, node, clicker, "techage:powerswitch_on")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
after_dig_node = sign_off,
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
use_texture_alpha = techage.CLIP,
|
use_texture_alpha = techage.CLIP,
|
||||||
@ -129,6 +142,7 @@ minetest.register_node("techage:powerswitch_on", {
|
|||||||
switch_off(pos, node, clicker, "techage:powerswitch")
|
switch_off(pos, node, clicker, "techage:powerswitch")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
after_dig_node = sign_off,
|
||||||
drop = "techage:powerswitch",
|
drop = "techage:powerswitch",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -164,12 +178,14 @@ minetest.register_node("techage:powerswitchsmall", {
|
|||||||
meta:set_string("infotext", S("TA Power Switch Small").." "..number)
|
meta:set_string("infotext", S("TA Power Switch Small").." "..number)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
switch_on(pos, node, placer, "techage:powerswitchsmall_on")
|
switch_on(pos, node, placer, "techage:powerswitchsmall_on")
|
||||||
|
sign_in(pos, node)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
switch_on(pos, node, clicker, "techage:powerswitchsmall_on")
|
switch_on(pos, node, clicker, "techage:powerswitchsmall_on")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
after_dig_node = sign_off,
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
use_texture_alpha = techage.CLIP,
|
use_texture_alpha = techage.CLIP,
|
||||||
@ -201,6 +217,7 @@ minetest.register_node("techage:powerswitchsmall_on", {
|
|||||||
switch_off(pos, node, clicker, "techage:powerswitchsmall")
|
switch_off(pos, node, clicker, "techage:powerswitchsmall")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
after_dig_node = sign_off,
|
||||||
drop = "techage:powerswitchsmall",
|
drop = "techage:powerswitchsmall",
|
||||||
on_rotate = screwdriver.disallow,
|
on_rotate = screwdriver.disallow,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
@ -77,12 +77,14 @@ minetest.register_node("techage:powerswitch_box_on", {
|
|||||||
end,
|
end,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
techage.legacy_switches(pos)
|
techage.legacy_switches(pos)
|
||||||
|
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
|
if power.turn_switch_off(pos, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on") then
|
||||||
minetest.sound_play("doors_glass_door_open", {
|
minetest.sound_play("doors_glass_door_open", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 1,
|
gain = 1,
|
||||||
max_hear_distance = 5})
|
max_hear_distance = 5})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
Cable:after_dig_tube(pos, oldnode, oldmetadata)
|
||||||
@ -112,12 +114,14 @@ minetest.register_node("techage:powerswitch_box_off", {
|
|||||||
},
|
},
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker)
|
||||||
techage.legacy_switches(pos)
|
techage.legacy_switches(pos)
|
||||||
|
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
|
if power.turn_switch_on(pos, Cable, "techage:powerswitch_box_off", "techage:powerswitch_box_on") then
|
||||||
minetest.sound_play("doors_glass_door_open", {
|
minetest.sound_play("doors_glass_door_open", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 1,
|
gain = 1,
|
||||||
max_hear_distance = 5})
|
max_hear_distance = 5})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
Cable:after_dig_node(pos)
|
Cable:after_dig_node(pos)
|
||||||
|
@ -30,7 +30,7 @@ local COUNTDOWN_TICKS = 1
|
|||||||
local function determine_power(pos, nvm)
|
local function determine_power(pos, nvm)
|
||||||
-- determine DC node position
|
-- determine DC node position
|
||||||
local outdir = M(pos):get_int("leftdir")
|
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 num_inv = #(netw.con or {})
|
||||||
local max_power = 0
|
local max_power = 0
|
||||||
for _, power in ipairs(control.request(pos, Solar, outdir, "junc", "power")) do
|
for _, power in ipairs(control.request(pos, Solar, outdir, "junc", "power")) do
|
||||||
|
Loading…
Reference in New Issue
Block a user