bugfixes for solar inverter and energy storage
power distribution changed solar inverter in two nodes divided manuals revised
This commit is contained in:
parent
564707c4a6
commit
0c60d3f08f
@ -55,6 +55,23 @@ local function on_rightclick(pos, node, clicker)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Modul shows the usage of the power2 alternative function set
|
||||||
|
--
|
||||||
|
local function after_place_node(pos)
|
||||||
|
local mem = tubelib2.init_mem(pos)
|
||||||
|
M(pos):set_string("infotext", "off")
|
||||||
|
techage.power.after_place_node(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function after_dig_node(pos, oldnode)
|
||||||
|
techage.power.after_dig_node(pos, oldnode)
|
||||||
|
tubelib2.del_mem(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
techage.power.after_tube_update2(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("techage:sink", {
|
minetest.register_node("techage:sink", {
|
||||||
description = "Sink",
|
description = "Sink",
|
||||||
@ -62,6 +79,9 @@ minetest.register_node("techage:sink", {
|
|||||||
|
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
|
after_place_node = after_place_node,
|
||||||
|
after_dig_node = after_dig_node,
|
||||||
|
after_tube_update = after_tube_update,
|
||||||
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 0,
|
light_source = 0,
|
||||||
@ -75,8 +95,12 @@ minetest.register_node("techage:sink", {
|
|||||||
minetest.register_node("techage:sink_on", {
|
minetest.register_node("techage:sink_on", {
|
||||||
description = "Sink",
|
description = "Sink",
|
||||||
tiles = {'techage_electric_button.png'},
|
tiles = {'techage_electric_button.png'},
|
||||||
|
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
on_rightclick = on_rightclick,
|
on_rightclick = on_rightclick,
|
||||||
|
after_place_node = after_place_node,
|
||||||
|
after_dig_node = after_dig_node,
|
||||||
|
after_tube_update = after_tube_update,
|
||||||
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = minetest.LIGHT_MAX,
|
light_source = minetest.LIGHT_MAX,
|
||||||
@ -89,13 +113,9 @@ minetest.register_node("techage:sink_on", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
})
|
})
|
||||||
|
|
||||||
techage.power.register_node({"techage:sink", "techage:sink_on"}, {
|
-- Alternative registration function
|
||||||
power_network = Cable,
|
techage.power.enrich_node({"techage:sink", "techage:sink_on"}, {
|
||||||
|
power_network = Cable,
|
||||||
on_power = on_power,
|
on_power = on_power,
|
||||||
on_nopower = on_nopower,
|
on_nopower = on_nopower,
|
||||||
after_place_node = function(pos)
|
|
||||||
local mem = tubelib2.init_mem(pos)
|
|
||||||
M(pos):set_string("infotext", "off")
|
|
||||||
end,
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
@ -295,7 +295,7 @@ techage.power.register_node(names, {
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
Durch die Registrierung des Nodes die obigen "after"-Funktionen einen Wrapper (Code nur symbolhaft):
|
Durch die Registrierung des Nodes werden die Knoten-eigenen `after_...` Funktionen überschrieben. Optional können deshalb eigene Funktionen bei `register_node` übergeben werden.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- after_place_node decorator
|
-- after_place_node decorator
|
||||||
@ -331,6 +331,17 @@ Und es erfolgt eine Registrierung bei Tube:
|
|||||||
|
|
||||||
**Soll aber der Knoten außer Power auch Kommandos empfangen oder senden können, oder am Tubing teilnehmen, so müssen die `command` bezogenen Funktionen zusätzlich beachtet werden.**
|
**Soll aber der Knoten außer Power auch Kommandos empfangen oder senden können, oder am Tubing teilnehmen, so müssen die `command` bezogenen Funktionen zusätzlich beachtet werden.**
|
||||||
|
|
||||||
|
### Alternative API
|
||||||
|
|
||||||
|
Sollen die Knoten-eigenen `after_...` Funktionen nicht überschrieben, so bietet sich folgende, alternative API an:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
techage.power.enrich_node(names, pwr_def)
|
||||||
|
techage.power.after_place_node(pos)
|
||||||
|
techage.power.after_dig_node(pos, oldnode)
|
||||||
|
techage.power.after_tube_update2(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
```
|
||||||
|
|
||||||
### `power`/`power2` API
|
### `power`/`power2` API
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
@ -359,10 +370,11 @@ techage.power.secondary_start(pos, mem, available, needed)
|
|||||||
techage.power.secondary_stop(pos, mem)
|
techage.power.secondary_stop(pos, mem)
|
||||||
techage.power.secondary_alive(pos, mem, capa_curr, capa_max)
|
techage.power.secondary_alive(pos, mem, capa_curr, capa_max)
|
||||||
|
|
||||||
techage.power.power_accounting(pos, mem) --> {network data...} (used by terminal)
|
techage.power.power_accounting(pos, mem) --> {network data...} (used by info tool)
|
||||||
techage.power.get_power(start_pos) --> sum (used by solar cells)
|
techage.power.get_power(start_pos) --> sum (used by solar cells)
|
||||||
techage.power.power_network_available(start_pos) --> bool (used by TES generator)
|
techage.power.power_network_available(start_pos) --> bool (used by TES generator)
|
||||||
techage.power.mark_nodes(name, start_pos) -- used by debugging tool
|
techage.power.mark_nodes(name, start_pos) -- used by debugging tool
|
||||||
|
techage.power.limited_connection_walk(pos, clbk) --> num_nodes (used by terminal)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Klasse `NodeStates`
|
## Klasse `NodeStates`
|
||||||
|
@ -154,6 +154,46 @@ function techage.power.register_node(names, pwr_def)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- API function set for nodes, which don't (what to) call techage.power.register_node()
|
||||||
|
--
|
||||||
|
function techage.power.enrich_node(names, pwr_def)
|
||||||
|
for _,name in ipairs(names) do
|
||||||
|
minetest.override_item(name, {
|
||||||
|
power = {
|
||||||
|
conn_sides = pwr_def.conn_sides or {"L", "R", "U", "D", "F", "B"},
|
||||||
|
on_power = pwr_def.on_power,
|
||||||
|
on_nopower = pwr_def.on_nopower,
|
||||||
|
on_getpower = pwr_def.on_getpower,
|
||||||
|
power_network = pwr_def.power_network,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
pwr_def.power_network:add_secondary_node_names({name})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.power.after_place_node(pos)
|
||||||
|
local pwr = PWR(pos)
|
||||||
|
set_conn_dirs(pos, pwr.conn_sides)
|
||||||
|
pwr.power_network:after_place_node(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.power.after_dig_node(pos, oldnode)
|
||||||
|
local pwr = PWRN(oldnode)
|
||||||
|
pwr.power_network:after_dig_node(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
function techage.power.after_tube_update2(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
local pwr = PWR(pos)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
add_connection(mem, pos, out_dir, peer_pos, peer_in_dir, pwr)
|
||||||
|
end
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Further helper functions
|
||||||
|
--
|
||||||
|
|
||||||
-- Called from tubelib2 via Cable:register_on_tube_update()
|
-- Called from tubelib2 via Cable:register_on_tube_update()
|
||||||
-- For all kind of nodes, used as cable filler/grout
|
-- For all kind of nodes, used as cable filler/grout
|
||||||
function techage.power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir, power)
|
function techage.power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir, power)
|
||||||
|
Loading…
Reference in New Issue
Block a user