removed unneeded code and some bugfixes

This commit is contained in:
Joachim Stolberg 2020-02-28 21:27:52 +01:00
parent 2905a45774
commit a6c7fc3731
14 changed files with 61 additions and 91 deletions

View File

@ -163,7 +163,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
if listname == "src" then
CRD(pos).State:start_if_standby(pos)
return stack:get_count()
elseif not inv:contains_item(listname, {name = stack:get_name()}) then
elseif list[index]:get_count() == 0 then
stack:set_count(1)
inv:set_stack(listname, index, stack)
return 0

View File

@ -25,8 +25,6 @@ local Cable = techage.ElectricCable
local power = techage.power
local networks = techage.networks
local INFO = [[Command 'load' returns the current provided power in ku]]
local function formspec(self, pos, nvm)
return "size[4,4]"..
"box[0,-0.1;3.8,0.5;#c6e8ff]"..
@ -224,9 +222,7 @@ techage.register_node({"techage:generator", "techage:generator_on"}, {
end,
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "info" then
return INFO
elseif topic == "load" then
if topic == "power" then
return math.floor((nvm.provided or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)

View File

@ -25,8 +25,6 @@ local Cable = techage.ElectricCable
local power = techage.power
local networks = techage.networks
local INFO = [[Command 'load' returns the current provided power in ku]]
local function formspec(self, pos, nvm)
return "size[4,4]"..
"box[0,-0.1;3.8,0.5;#c6e8ff]"..
@ -45,7 +43,10 @@ local function transfer_turbine(pos, topic, payload)
end
local function can_start(pos, nvm, state)
return (nvm.heatexchanger_trigger or 0) > 0 -- by means of heatexchanger
if (nvm.heatexchanger_trigger or 0) == 0 then -- by means of heatexchanger
return S("storage empty?")
end
return true
end
local function start_node(pos, nvm, state)
@ -225,9 +226,7 @@ techage.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
end,
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "info" then
return INFO
elseif topic == "load" then
if topic == "power" then
return math.floor((nvm.provided or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)

View File

@ -32,8 +32,6 @@ local Pipe = techage.LiquidPipe
local power = techage.power
local in_range = techage.in_range
local INFO = [[- Command 'load' returns the storage load in percent]]
local function swap_node(pos, name)
local node = techage.get_node_lvm(pos)
if node.name == name then
@ -263,6 +261,8 @@ techage.register_node({"techage:heatexchanger1"}, {
else
return "stopped"
end
elseif topic == "power" then
return math.max(nvm.needed or 0, 0)
elseif topic == "load" then
return techage.power.percent(nvm.capa_max, nvm.capa)
elseif topic == "on" then
@ -271,8 +271,6 @@ techage.register_node({"techage:heatexchanger1"}, {
elseif topic == "off" then
stop_node(pos, techage.get_nvm(pos))
return true
elseif topic == "info" then
return INFO
else
return "unsupported"
end

View File

@ -280,7 +280,18 @@ minetest.register_node("techage:ta4_electrolyzer_on", {
Cable:add_secondary_node_names({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"})
Pipe:add_secondary_node_names({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"})
techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, liquid.recv_message)
techage.register_node({"techage:ta4_electrolyzer", "techage:ta4_electrolyzer_on"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "load" then
return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0)
elseif topic == "power" then
return math.floor((nvm.taken or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)
end
end,
})
minetest.register_craft({
output = "techage:ta4_electrolyzer",

View File

@ -271,7 +271,18 @@ minetest.register_node("techage:ta4_fuelcell_on", {
Cable:add_secondary_node_names({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"})
Pipe:add_secondary_node_names({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"})
techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, liquid.recv_message)
techage.register_node({"techage:ta4_fuelcell", "techage:ta4_fuelcell_on"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "load" then
return techage.power.percent(CAPACITY, (nvm.liquid and nvm.liquid.amount) or 0)
elseif topic == "power" then
return math.floor((nvm.given or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)
end
end,
})
minetest.register_craft({
output = "techage:ta4_fuelcell",

View File

@ -287,29 +287,13 @@ minetest.register_node("techage:t4_pump_on", {
techage.register_node({"techage:t3_pump", "techage:t3_pump_on"}, {
on_recv_message = function(pos, src, topic, payload)
local resp = State3:on_receive_message(pos, topic, payload)
if resp then
return resp
else
return "unsupported"
end
end,
on_node_load = function(pos)
State3:on_node_load(pos)
return State3:on_receive_message(pos, topic, payload)
end,
})
techage.register_node({"techage:t4_pump", "techage:t4_pump_on"}, {
on_recv_message = function(pos, src, topic, payload)
local resp = State4:on_receive_message(pos, topic, payload)
if resp then
return resp
else
return "unsupported"
end
end,
on_node_load = function(pos)
State4:on_node_load(pos)
return State4:on_receive_message(pos, topic, payload)
end,
})

View File

@ -245,12 +245,7 @@ local tubing = {
end
end,
on_recv_message = function(pos, src, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
return "unsupported"
end
return CRD(pos).State:on_receive_message(pos, topic, payload)
end,
on_node_load = function(pos, node)
CRD(pos).State:on_node_load(pos)

View File

@ -173,12 +173,7 @@ tiles.act = {
local tubing = {
on_recv_message = function(pos, src, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
return "unsupported"
end
return CRD(pos).State:on_receive_message(pos, topic, payload)
end,
on_node_load = function(pos, node)
CRD(pos).State:on_node_load(pos)

View File

@ -195,48 +195,17 @@ minetest.register_node("techage:ta4_solar_inverter", {
}
})
--minetest.register_node("techage:ta4_solar_inverterDC", {
-- description = S("TA4 Solar Inverter DC"),
-- tiles = {
-- -- up, down, right, left, back, front
-- "techage_filling_ta4.png^techage_frame_ta4_top.png",
-- "techage_filling_ta4.png^techage_frame_ta4.png",
-- "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_open.png",
-- "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_ta4_cable.png",
-- "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverterDC.png",
-- "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_inverterDC.png",
-- },
-- after_place_node = function(pos)
-- Solar:after_place_node(pos)
-- end,
-- after_dig_node = function(pos, oldnode)
-- Solar:after_dig_node(pos)
-- end,
-- tubelib2_on_update2 = tubelib2_on_update2,
-- paramtype2 = "facedir",
-- groups = {cracky=2, crumbly=2, choppy=2},
-- on_rotate = screwdriver.disallow,
-- is_ground_content = false,
-- networks = {
-- ele2 = {
-- sides = {L = 1},
-- ntype = "con1",
-- },
-- }
--})
Cable:add_secondary_node_names({"techage:ta4_solar_inverter"})
Solar:add_secondary_node_names({"techage:ta4_solar_inverter"})
techage.register_node({"techage:ta4_solar_inverter"}, {
on_recv_message = function(pos, src, topic, payload)
return State:on_receive_message(pos, topic, payload)
end,
on_node_load = function(pos)
State:on_node_load(pos)
local nvm = techage.get_nvm(pos)
if topic == "power" then
return math.floor((nvm.delivered or 0) + 0.5)
else
return State:on_receive_message(pos, topic, payload)
end
end,
})

View File

@ -205,8 +205,8 @@ techage.register_node({"techage:ta3_akku"}, {
local nvm = techage.get_nvm(pos)
if topic == "load" then
return techage.power.percent(PWR_CAPA, nvm.capa)
elseif topic == "size" then
return PWR_CAPA
elseif topic == "power" then
return nvm.needed or 0
else
return State:on_receive_message(pos, topic, payload)
end

View File

@ -283,8 +283,10 @@ Cable:add_secondary_node_names({"techage:tiny_generator", "techage:tiny_generato
techage.register_node({"techage:tiny_generator", "techage:tiny_generator_on"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
if topic == "load" then
return power.percent(PWR_CAPA, nvm.provided)
if topic == "power" then
return nvm.provided or 0
elseif topic == "fuel" then
return techage.fuel.get_fuel_amount(nvm)
else
return State:on_receive_message(pos, topic, payload)
end

View File

@ -178,13 +178,16 @@ end
local function network_check(start_pos, Cable, player_name)
local ndef = techage.networks.net_def(start_pos, Cable.tube_type)
local outdir = nil
local num = 0
if ndef and ndef.ntype ~= "junc" then
outdir = M(start_pos):get_int("outdir")
end
networks.connection_walk(start_pos, outdir, Cable, function(pos, indir, node)
local distance = vector.distance(start_pos, pos)
if distance < 50 then
techage.mark_position(player_name, pos, "check", "#ff0000", 6)
num = num + 1
if distance < 50 and num < 100 then
local state = techage.power.power_available(pos, Cable) and "power" or "no power"
techage.mark_position(player_name, pos, state, "#ff0000", 6)
end
end)
end
@ -239,6 +242,11 @@ local function read_state(itemstack, user, pointed_thing)
load = dump(load)
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ")
end
local power = techage.send_single("0", number, "power", nil)
if power and power ~= "" and power ~= "unsupported" then
power = dump(power)
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": power = "..power.." ku ")
end
local owner = M(pos):get_string("owner") or ""
if owner ~= "" then
minetest.chat_send_player(user:get_player_name(), S("Node owner")..": "..owner.." ")

View File

@ -261,6 +261,8 @@ techage.register_node({"techage:ta4_wind_turbine"}, {
else
return "stopped"
end
elseif topic == "power" then
return nvm.delivered or 0
elseif topic == "on" then
nvm.running = true
elseif topic == "off" then