How to access Vehicle acceleration power?

Place to get help with not working mods / modding interface.
Post Reply
Rafiz
Inserter
Inserter
Posts: 31
Joined: Sun Jan 17, 2021 9:28 am
Contact:

How to access Vehicle acceleration power?

Post by Rafiz »

I cannot get this anywhere. Lua entity, lua entity prototype, burner, burner prototype, nothing gives me ability to get information about what's vehicle acceleration power. I'm already looking for it for 4 hours, is it even possible? I'm losing my mind on how hard is to find such information, so I decided to ask isntead.

*thing* that I mean is Vehicle->Acceleration power in game UI, or data.raw['locomotive']['locomotive'].max_power in.. data.lua .
How do I get that information in control.lua? I cannot reach it.

I only know " game.entity_prototypes[locomotive.name] " this way of getting 'any' information about locomotive, but from my knowledge entity doesn't have anything that matches what I need.
I can't find any game.vehicle_prototypes[](?) or anything simmilar.

game.print(game.entity_prototypes[locomotive.type].max_energy_usage) returns 10'000, no matter what "type" of locomotive I enter. It doesn't have any sense, different locomotives should give different values, so it's for sure not value, that I was looking for.

I see this thing : https://wiki.factorio.com/Prototype/Locomotive in API, but I don't know how to access it from LuaTrain.get_something, or from LuaGameScript.get_something(name)

I found out that locomotive inherits from rolling stock, inheriting from vehicle, inheriting from entity with health inheriting from entity. So now I know a bit more.. Looking in "entity" was absolutely counter productive.


Ahh, I think it might be impossible, I will wait for answers and stop banging my head against wall, trying to find solution that might not exist.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to access Vehicle acceleration power?

Post by DaveMcW »

Code: Select all

/c locomotive = game.player.selected
power = locomotive.prototype.max_energy_usage
bonus = locomotive.burner.currently_burning and locomotive.burner.currently_burning.fuel_acceleration_multiplier or 1
game.print("Acceleration power: " .. util.format_number(60 * power * bonus))

Rafiz
Inserter
Inserter
Posts: 31
Joined: Sun Jan 17, 2021 9:28 am
Contact:

Re: How to access Vehicle acceleration power?

Post by Rafiz »

max_energy usage will work exactly same as my [code]local LuaEntity = surface.get_trains()[...x...].locomotives["..."][1];
LuaEntity.max_energy_usage [/code]. I already tried it, and it didn't worked really. It returned 10'000 for every locomotive type. Doesn't matter what it's power was, but I will try to look in error in my code, if you're sure it should work correctly.


It actually... Just works... For junk train it in fact returns less. So I slipped through that answer yesterday x_x and believed that it doesn't work.

Thanks you a lot!

Post Reply

Return to “Modding help”