Page 1 of 1

equipment.get_energy_from_accumulator(name, energy)

Posted: Wed Oct 23, 2019 10:24 am
by darkfrei
viewtopic.php?f=33&t=76866
https://mods.factorio.com/mod/Vehicle_R ... 000b76068b

Can you please make this

Code: Select all

local bool_sucess = equipment.get_energy_from_accumulator(accumulator_name, energy)
This code searches the equipment accumulator with exactly name, checks if here is at least the energy as was asked and if true, removes this amount of energy and returns true.
If here is no accumulator with this name or the accumulator has less than this amount of energy then it returns false.

It can be very useful for mods with lua control, where the energy will be checked for several entities per tick and if there is enough energy then the code will be run.

Re: equipment.get_energy_from_accumulator(name, energy)

Posted: Wed Oct 23, 2019 3:30 pm
by Rseding91
I could add a function to do that... the name part seems weird to me though since none of the normal equipment logic cares about battery names.

What I wonder though is if specific equipment would be better. For example: radar equipment. I could easily replicate the radar entity functionality in equipment form.

Would that be useful? And if so, I wonder what part(s) of the radar would actually be useful. The near-scanning or the far scanning or both. For the player both parts already exist. For cars neither part exists.

Posila also had an idea for an equipment piece that would have a trigger effect definition that would allow mods to define any number of nested triggers that some equipment could fire at some regular interval/energy consumed. I'm not 100% sure how this would work but it sounds like it would be very useful as well.

Re: equipment.get_energy_from_accumulator(name, energy)

Posted: Wed Oct 23, 2019 5:11 pm
by darkfrei
Rseding91 wrote: Wed Oct 23, 2019 3:30 pm Posila also had an idea for an equipment piece that would have a trigger effect definition that would allow mods to define any number of nested triggers that some equipment could fire at some regular interval/energy consumed. I'm not 100% sure how this would work but it sounds like it would be very useful as well.
I would be great!
I've suggested just small piece how to check if the modded equipment is in the equipment slots and it has energy for something, what can't be used without energy. Like scanning radar or jetpack or headlamp or whatever.

Re: equipment.get_energy_from_accumulator(name, energy)

Posted: Wed Oct 23, 2019 6:46 pm
by Optera
Rseding91 wrote: Wed Oct 23, 2019 3:30 pm Would that be useful? And if so, I wonder what part(s) of the radar would actually be useful. The near-scanning or the far scanning or both. For the player both parts already exist. For cars neither part exists.
To me near scanning would be most useful to keep track of my trains.
If you implemented Radar equipment it would effectively make my Vehicle radar mod obsolete. I'm all for having my mods features available in base. :mrgreen:

Re: equipment.get_energy_from_accumulator(name, energy)

Posted: Wed Oct 23, 2019 7:00 pm
by darkfrei
Optera wrote: Wed Oct 23, 2019 6:46 pm To me near scanning would be most useful to keep track of my trains.
If you implemented Radar equipment it would effectively make my Vehicle radar mod obsolete. I'm all for having my mods features available in base. :mrgreen:
It's not a base, but you can enable it as loaders, fuel leech and another well-done optimized mods.

Re: equipment.get_energy_from_accumulator(name, energy)

Posted: Thu Oct 24, 2019 6:12 am
by Optera
darkfrei wrote: Wed Oct 23, 2019 7:00 pm
Optera wrote: Wed Oct 23, 2019 6:46 pm To me near scanning would be most useful to keep track of my trains.
If you implemented Radar equipment it would effectively make my Vehicle radar mod obsolete. I'm all for having my mods features available in base. :mrgreen:
It's not a base, but you can enable it as loaders, fuel leech and another well-done optimized mods.
Loaders are in base, only hidden.

Re: equipment.get_energy_from_accumulator(name, energy)

Posted: Thu Oct 24, 2019 7:15 am
by darkfrei
Optera wrote: Thu Oct 24, 2019 6:12 am Loaders are in base, only hidden.
They are in the base only on 99%, but you need the mod to enable them.

Burner Leech is also 99% base: https://mods.factorio.com/mod/Burner-Leech/changelog

And if your mod will be done in the game engine, but disabled, you are need the mod for enabling too.