Getting entity prototype max_speed of locomotive

Place to get help with not working mods / modding interface.
FuryoftheStars
Smart Inserter
Smart Inserter
Posts: 2767
Joined: Tue Apr 25, 2017 2:01 pm
Contact:

Getting entity prototype max_speed of locomotive

Post by FuryoftheStars »

I'm not so good with the control.lua stuff, yet. I'm working on a mod that modifies the max_speed values (among other things) of various locomotive entities of both vanilla and mod added. In one of these mods that adds locomotives, I noticed as a part of a gui display, they have hard coded their locomotive's max speed in a calculation. I wanted to see if currently there's a way to pull it dynamically (entity.prototype.max_speed appears to be for projectiles only) that I could use to fix my copy of their mod and, provided it works, suggest the fix to them.

Note that this is just the locomotive entity itself, not the "train".
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Getting entity prototype max_speed of locomotive

Post by eradicator »

Now sure why you can't use LuaEntity.train.max_forward_speed, which includes fuel bonusses...
API Doc wrote: LuaEntityPrototype
speed :: double [R] The default speed of this flying robot, rolling stock, unit or nil.
Not the most intuitive name, but this does give the same value as specified in the data stage prototype max_speed value. I.e. this does NOT include fuel bonuses. (Protip: Control-stage names are different from data-stage names more often than not...)
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
Post Reply

Return to “Modding help”