Valentin Anger 895d503270 Finish rewrite of the new energy system - Closes #14
Changes:
- A connection between two nodes get updated once per cycle
- Nodes have a type specified in sparktech_energy_conductor as follows
1 for a transfer node like cables
2 for a producer like solarpanels
3 for a storage like capacitors
4 for a consumer like electric furnaces
- Nodes of type 2 balance between each other and push to all other nodes
- Nodes of type 1 and 3 balance between each other
- Nodes of type 4 pull from all other nodes that are not of type 4
- When balancing, the relative charge of a node is concidered
2017-01-04 16:30:52 +01:00

52 lines
1.2 KiB
Lua

minetest.register_node("sparkdebug:energyvoid", {
description = "Energy Void",
tiles = {
"capacitor_top.png",
"capacitor_top.png",
"capacitor_side.png",
"capacitor_side.png",
"capacitor_side.png",
"capacitor_side.png"
},
groups = {
oddly_breakable_by_hand = 1,
sparktech_energy_conductor = 4,
sparkdebug = 1,
sparktech_energy_max = 10000
}
})
minetest.register_node("sparkdebug:energysource", {
description = "Energy Source",
tiles = {
"capacitor_top.png",
"capacitor_top.png",
"capacitor_side.png",
"capacitor_side.png",
"capacitor_side.png",
"capacitor_side.png"
},
groups = {
oddly_breakable_by_hand = 1,
sparktech_energy_conductor = 2,
sparkdebug = 1,
sparktech_energy_max = 10000
}
})
minetest.register_abm({
nodenames = {"group:sparkdebug"},
interval = 1.0,
chance = 1,
catch_up = true,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
if node["name"] == "sparkdebug:energysource" then
meta:set_int("energy", 10000)
end
if node["name"] == "sparkdebug:energyvoid" then
meta:set_int("energy", 0)
end
end
})