TES bugfixes
This commit is contained in:
parent
a3935db108
commit
52844aab26
@ -1,85 +0,0 @@
|
|||||||
-- for lazy programmers
|
|
||||||
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
|
|
||||||
local P = minetest.string_to_pos
|
|
||||||
local M = minetest.get_meta
|
|
||||||
|
|
||||||
local CYCLE_TIME = 2
|
|
||||||
local PWR_PERF = 10
|
|
||||||
local PWR_CAPA = 300
|
|
||||||
|
|
||||||
local Cable = techage.ElectricCable
|
|
||||||
local power = techage.power
|
|
||||||
|
|
||||||
local function in_range(val, min, max)
|
|
||||||
if val < min then return min end
|
|
||||||
if val > max then return max end
|
|
||||||
return val
|
|
||||||
end
|
|
||||||
|
|
||||||
local function formspec(pos, mem)
|
|
||||||
return "size[5,3]"..
|
|
||||||
default.gui_bg..
|
|
||||||
default.gui_bg_img..
|
|
||||||
default.gui_slots..
|
|
||||||
"image[0,0.5;1,2;"..techage.power.formspec_power_bar(PWR_CAPA, mem.capa or 0).."]"..
|
|
||||||
"label[0.2,2.5;Load]"..
|
|
||||||
"button[1.1,1;1.8,1;update;Update]"..
|
|
||||||
"image[4,0.5;1,2;"..techage.power.formspec_load_bar(-(mem.delivered or 0), PWR_PERF).."]"..
|
|
||||||
"label[4.2,2.5;Flow]"
|
|
||||||
end
|
|
||||||
|
|
||||||
local function node_timer(pos, elapsed)
|
|
||||||
--print("node_timer akku "..S(pos))
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
if mem.running then
|
|
||||||
mem.delivered = power.secondary_alive(pos, mem, mem.capa, PWR_CAPA)
|
|
||||||
--print("provided", mem.delivered)
|
|
||||||
mem.capa = mem.capa - mem.delivered
|
|
||||||
mem.capa = in_range(mem.capa, 0, PWR_CAPA)
|
|
||||||
end
|
|
||||||
return mem.running
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function on_receive_fields(pos, formname, fields, player)
|
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local mem = tubelib2.get_mem(pos)
|
|
||||||
techage.power.network_changed(pos, mem)
|
|
||||||
|
|
||||||
if fields.update then
|
|
||||||
M(pos):set_string("formspec", formspec(pos, mem))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("techage:akku", {
|
|
||||||
description = "Akku",
|
|
||||||
tiles = {
|
|
||||||
-- up, down, right, left, back, front
|
|
||||||
'techage_electric_button.png^techage_appl_source.png',
|
|
||||||
'techage_electric_button.png^techage_appl_source.png',
|
|
||||||
'techage_electric_button.png^techage_appl_source.png^techage_electric_plug.png',
|
|
||||||
'techage_electric_button.png^techage_appl_source.png',
|
|
||||||
'techage_electric_button.png^techage_appl_source.png',
|
|
||||||
'techage_electric_button.png^techage_appl_source.png',
|
|
||||||
},
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
groups = {cracky=2, crumbly=2, choppy=2},
|
|
||||||
is_ground_content = false,
|
|
||||||
on_receive_fields = on_receive_fields,
|
|
||||||
on_timer = node_timer,
|
|
||||||
})
|
|
||||||
|
|
||||||
techage.power.register_node({"techage:akku"}, {
|
|
||||||
power_network = Cable,
|
|
||||||
after_place_node = function(pos, placer)
|
|
||||||
local mem = tubelib2.init_mem(pos)
|
|
||||||
mem.running = true
|
|
||||||
mem.capa = 0
|
|
||||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
|
||||||
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
|
|
||||||
M(pos):set_string("formspec", formspec(pos, mem))
|
|
||||||
end,
|
|
||||||
})
|
|
@ -66,7 +66,7 @@ local function play_sound(pos)
|
|||||||
if not mem.handle or mem.handle == -1 then
|
if not mem.handle or mem.handle == -1 then
|
||||||
mem.handle = minetest.sound_play("techage_booster", {
|
mem.handle = minetest.sound_play("techage_booster", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 0.2,
|
gain = 0.3,
|
||||||
max_hear_distance = 10,
|
max_hear_distance = 10,
|
||||||
loop = true})
|
loop = true})
|
||||||
if mem.handle == -1 then
|
if mem.handle == -1 then
|
||||||
@ -88,12 +88,9 @@ local function stop_sound(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function on_power(pos)
|
local function on_power(pos)
|
||||||
play_sound(pos)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function on_nopower(pos)
|
local function on_nopower(pos)
|
||||||
nvm.needed = 0
|
|
||||||
stop_sound(pos)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function start_node(pos, nvm)
|
local function start_node(pos, nvm)
|
||||||
@ -164,7 +161,9 @@ local function node_timer(pos, elapsed)
|
|||||||
local taken = 0
|
local taken = 0
|
||||||
local given = 0
|
local given = 0
|
||||||
|
|
||||||
if nvm.capa < (nvm.capa_max * 0.9) then
|
if nvm.capa < (nvm.capa_max * 0.9) and not nvm.charging then
|
||||||
|
taken = power.consumer_alive(pos, Cable, CYCLE_TIME)
|
||||||
|
elseif nvm.capa < nvm.capa_max and nvm.charging then
|
||||||
taken = power.consumer_alive(pos, Cable, CYCLE_TIME)
|
taken = power.consumer_alive(pos, Cable, CYCLE_TIME)
|
||||||
end
|
end
|
||||||
if nvm.capa > 0 then
|
if nvm.capa > 0 then
|
||||||
@ -193,6 +192,8 @@ local net_def = {
|
|||||||
pipe2 = {
|
pipe2 = {
|
||||||
sides = {L = 1, R = 1},
|
sides = {L = 1, R = 1},
|
||||||
ntype = "con1",
|
ntype = "con1",
|
||||||
|
on_power = on_power,
|
||||||
|
on_nopower = on_nopower,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +213,7 @@ minetest.register_node("techage:heatexchanger1", {
|
|||||||
after_place_node = after_place_node,
|
after_place_node = after_place_node,
|
||||||
can_dig = can_dig,
|
can_dig = can_dig,
|
||||||
after_dig_node = after_dig_node,
|
after_dig_node = after_dig_node,
|
||||||
--tubelib2_on_update2 = tubelib2_on_update2,
|
tubelib2_on_update2 = tubelib2_on_update2,
|
||||||
networks = net_def,
|
networks = net_def,
|
||||||
|
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
@ -228,11 +229,10 @@ Cable:add_secondary_node_names({"techage:heatexchanger1"})
|
|||||||
-- command interface
|
-- command interface
|
||||||
techage.register_node({"techage:heatexchanger1"}, {
|
techage.register_node({"techage:heatexchanger1"}, {
|
||||||
on_transfer = function(pos, indir, topic, payload)
|
on_transfer = function(pos, indir, topic, payload)
|
||||||
print("on_transfer")
|
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
-- used by heatexchanger2
|
-- used by heatexchanger2
|
||||||
if topic == "state" then
|
if topic == "state" then
|
||||||
return nvm.capa_max, nvm.capa, PWR_PERF, math.max(nvm.needed, 0)
|
return nvm.capa_max, nvm.capa, PWR_PERF, math.max(nvm.needed or 0, 0)
|
||||||
elseif topic == "integrity" then
|
elseif topic == "integrity" then
|
||||||
return inlet_cmnd(pos, "volume", payload)
|
return inlet_cmnd(pos, "volume", payload)
|
||||||
elseif topic == "state" then
|
elseif topic == "state" then
|
||||||
|
@ -80,7 +80,6 @@ local State = techage.NodeStates:new({
|
|||||||
})
|
})
|
||||||
|
|
||||||
local function node_timer(pos, elapsed)
|
local function node_timer(pos, elapsed)
|
||||||
print("node_timer")
|
|
||||||
local nvm = techage.get_nvm(pos)
|
local nvm = techage.get_nvm(pos)
|
||||||
local res = check_TES_integrity(pos, nvm)
|
local res = check_TES_integrity(pos, nvm)
|
||||||
if res ~= true then
|
if res ~= true then
|
||||||
|
@ -145,18 +145,7 @@ techage.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
|
|||||||
if not transfer_heatexchanger3(pos, topic, payload) then
|
if not transfer_heatexchanger3(pos, topic, payload) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
local power = transfer_generator(pos, topic, payload)
|
return transfer_generator(pos, topic, payload)
|
||||||
if not power or power <= 0 and nvm.running then
|
|
||||||
swap_node(pos, "techage:ta4_turbine")
|
|
||||||
stop_sound(pos)
|
|
||||||
nvm.running = false
|
|
||||||
return 0
|
|
||||||
elseif power and power > 0 and not nvm.running then
|
|
||||||
swap_node(pos, "techage:ta4_turbine_on")
|
|
||||||
play_sound(pos)
|
|
||||||
nvm.running = true
|
|
||||||
end
|
|
||||||
return power
|
|
||||||
elseif topic == "start" then -- used by generator
|
elseif topic == "start" then -- used by generator
|
||||||
swap_node(pos, "techage:ta4_turbine_on")
|
swap_node(pos, "techage:ta4_turbine_on")
|
||||||
play_sound(pos)
|
play_sound(pos)
|
||||||
|
2
init.lua
2
init.lua
@ -177,8 +177,6 @@ else
|
|||||||
dofile(MP.."/recipe_checker.lua")
|
dofile(MP.."/recipe_checker.lua")
|
||||||
dofile(MP.."/.test/sink.lua")
|
dofile(MP.."/.test/sink.lua")
|
||||||
dofile(MP.."/.test/meta_node.lua")
|
dofile(MP.."/.test/meta_node.lua")
|
||||||
--dofile(MP.."/.test/source.lua")
|
|
||||||
--dofile(MP.."/.test/accu.lua")
|
|
||||||
|
|
||||||
-- Solar
|
-- Solar
|
||||||
dofile(MP.."/solar/minicell.lua")
|
dofile(MP.."/solar/minicell.lua")
|
||||||
|
@ -162,13 +162,12 @@ function techage.power.consumer_alive(pos, Cable, cycle_time)
|
|||||||
local rv = (cycle_time / 2) + 1
|
local rv = (cycle_time / 2) + 1
|
||||||
if def["netID"] and def["calive"] and def["calive"] < rv then -- network available
|
if def["netID"] and def["calive"] and def["calive"] < rv then -- network available
|
||||||
def["calive"] = rv
|
def["calive"] = rv
|
||||||
|
return def["taken"] or 0
|
||||||
elseif not def["cstate"] or def["cstate"] == RUNNING then
|
elseif not def["cstate"] or def["cstate"] == RUNNING then
|
||||||
local ndef = net_def(pos, Cable.tube_type)
|
local ndef = net_def(pos, Cable.tube_type)
|
||||||
ndef.on_nopower(pos, Cable.tube_type)
|
ndef.on_nopower(pos, Cable.tube_type)
|
||||||
def["cstate"] = NOPOWER
|
def["cstate"] = NOPOWER
|
||||||
return 0
|
|
||||||
end
|
end
|
||||||
return def["taken"] or 0
|
|
||||||
else
|
else
|
||||||
local ndef = net_def(pos, Cable.tube_type)
|
local ndef = net_def(pos, Cable.tube_type)
|
||||||
ndef.on_nopower(pos, Cable.tube_type)
|
ndef.on_nopower(pos, Cable.tube_type)
|
||||||
|
@ -43,6 +43,11 @@ local function formspec(self, pos, nvm)
|
|||||||
"image[4,1.7;1,2;"..techage.power.formspec_load_bar(needed, PWR_PERF).."]"
|
"image[4,1.7;1,2;"..techage.power.formspec_load_bar(needed, PWR_PERF).."]"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function on_power(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_nopower(pos)
|
||||||
|
end
|
||||||
|
|
||||||
local function start_node(pos, nvm, state)
|
local function start_node(pos, nvm, state)
|
||||||
nvm.running = true
|
nvm.running = true
|
||||||
@ -159,6 +164,8 @@ local net_def = {
|
|||||||
sides = {R = 1},
|
sides = {R = 1},
|
||||||
ntype = {"gen2", "con2"},
|
ntype = {"gen2", "con2"},
|
||||||
nominal = PWR_PERF,
|
nominal = PWR_PERF,
|
||||||
|
on_power = on_power,
|
||||||
|
on_nopower = on_nopower,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user