minetest-mods / technic

Technic mod for Minetest
Other
145 stars 155 forks source link

Supply converter demands only needed power #577

Closed ZettaScript closed 1 year ago

ZettaScript commented 3 years ago

Partially fixes #576.

Supply converter demands only the needed power to satisfy the demand on the output network. It can still be too much if the output network has other power sources, because supply is not taken in account.

To test it: place a powerful generator at the converter's input and a little machine at it's output. e.g. if the machine consumes 300 EU, the converter will demand 400 EU instead of the maximal power. This enables using the remaining power on the input network.

This is the first time I write Lua, and my first contribution to a Minetest mod so I'm not sure it's ok, but it works on my server.

Edit: it causes a problem: battery boxes are not charged on the output network. To fix that, I think battery boxes should use the same demand/supply system as the other machines. A not fully charged battery box demands a fixed power, and a not empty battery box supplies a fixed power.

ZettaScript commented 3 years ago

I think of a simpler fix to allow supply converters to charge batteries: the supply converter just counts the number of batteries on the output network, then add this number times the battery's power to it's own demand.