Not a member yet? Why not Sign up today
Create an account  

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is there a way to get engine power fraction?


I'm trying to write simple automatic electric engines output management. It should lower their output as much as possible to increase effeciency while still providing enough engine power to satisfy demand.

Unfortunately, I'm unable to find any function in Self Awareness module like "GetEnginePowerFraction", although there is "Vehicle Power" input in ACB and even "GetEnergyFraction" function in the Lua API for quering batteries charge level.

Sorry if that is some well-known topic but I couldn't find any information related to it anywhere.

Under components tab you will see

I:Component_GetFloatLogic(type, blockIndex)

This will return the decimal value of the component on the ship.

The Id for the electric engine block is 35.

So it would be I:Component_GetFloatLogic(35, blockIndex) and then the blockIndex would be the specific electric engine on the vessel. There's also a lot of cool detailed functions under the component tab that aren't just get or set functions, but something handy might be I:Component_GetCount(type).

Thanks, but the problem is not accessing the electric engines (as you have mentioned, they have power output float logic which actually can be conveniently controlled with a single call to "I:Component_SetFloatLogicAll(type, float)").

The problem is that I can't find a way to access the engine power stats (the "demand/available" numbers which player usually can see at the right bottom of the screen), so there seems to be no way of getting the amount of power that is currently required by vehicle's systems.

Yea... that sounds like a request for the new lua or you would have to manually do the calculations with iterating through all the blocks that produce power. Weird they don't have it already.

From the recent changelog:
Quote:v2.4.3 [Add] <Lua>: Added GetPowerFraction and GetElectricPowerFraction functions

v2.4.3 [Add] <Lua>: Added PowerFraction and ElectricPowerFraction to FriendlyInfo

So, that gap seems to be filled now. Many thanks to the devs!

Forum Jump:

Users browsing this thread:
1 Guest(s)