Page 1 of 1

Getting entity prototype max_speed of locomotive

Posted: Thu Jul 25, 2019 6:38 pm
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".

Re: Getting entity prototype max_speed of locomotive

Posted: Mon Aug 05, 2019 2:17 pm
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...)