Page 1 of 1
Add connection_distance and double joint_distance to LuaEntityPrototoype
Posted: Sat Jun 13, 2020 10:10 pm
by tubs
Hey, could we get:
Code: Select all
connection_distance :: double
joint_distance :: double
from
https://wiki.factorio.com/Prototype/RollingStock
to be available from LuaEntityPrototype?
Thanks!
Re: Add connection_distance and double joint_distance to LuaEntityPrototoype
Posted: Sun Jun 14, 2020 12:51 am
by Templarfreak
Any particular reason why you need this? Just exposing that data to LuaEntityPrototype is pretty unnecessary, you can actually attach any data you like to any data structure you like arbitrary, its one of the key features of Lua. For instance I do this in a personal mod to add a boolean to certain entities as an exception for whether or not they should be mined faster by hand.
If you're hoping for those to still be functional as you would expect they would be on trains, that is very unlikely to happen.
Re: Add connection_distance and double joint_distance to LuaEntityPrototoype
Posted: Sun Jun 14, 2020 9:19 am
by mrudat
LuaEntityPrototype is the control-stage version of (for example) data.raw.locomotive. If you add a field in the data stage to data.raw.locomotive, eg:
Code: Select all
data.raw.locomotive.locomotive._MyModData = { --[[ Stuff my mod needs to know about locomotives ]] }
That'll work, and you can read the data back later, but it won't be added to the LuaEntityPrototype that you access while the game is actually in progress.
I honestly don't know if you can add a custom field to a LuaEntityPrototype, and I've never been inclined to find out.
It is rather fraught as LuaEntityPrototype is a temporary object created to allow you to access the internal entity_prototype that defines how an entity should behave; if the game configuration changes it's entirely possible that the particular LuaEntityPrototype that you've been hanging on to will become invalid, and when you retrieve a new one, the data you stored earlier will be gone.
In this particular case, these are existing values that are defined in the data phase and used by the game as part of simulating how trains work, they just happen to not be able to be retrieved during the control phase.
Edit: fix thinking misteak.
Re: Add connection_distance and double joint_distance to LuaEntityPrototoype
Posted: Sat Oct 07, 2023 7:28 pm
by Rseding91
Ok, I've added both of these for the next 1.1. release.