equipment.get_energy_from_accumulator(name, energy)

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

equipment.get_energy_from_accumulator(name, energy)

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15035
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: equipment.get_energy_from_accumulator(name, energy)

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: equipment.get_energy_from_accumulator(name, energy)

Post 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.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: equipment.get_energy_from_accumulator(name, energy)

Post 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:
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: equipment.get_energy_from_accumulator(name, energy)

Post 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.
User avatar
Optera
Smart Inserter
Smart Inserter
Posts: 2920
Joined: Sat Jun 11, 2016 6:41 am
Contact:

Re: equipment.get_energy_from_accumulator(name, energy)

Post 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.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: equipment.get_energy_from_accumulator(name, energy)

Post 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.
Post Reply

Return to “Modding interface requests”