Page 1 of 1
Technology modifying entity values directly
Posted: Thu May 12, 2016 1:48 pm
by theonlyCozzy
okay so there are modifiers for when a technology is researched to change entities, but is there a way to change values in the entity? So I want to create a way to make robots more efficient in how much energy they store and how much they use on a movement. this values are set in the entity but the only modifiers for robots are carrying capacity and movement speed.
logistic-robot-speed
logistic-robot-storage
the values in the entity i want to try and change on a completed research in the logistics robot entity are:
max_energy
energy_per_move
I have dug around in the API for a bit and I cannot find a way to access a value of an entity directly.
The end goal is to add two more researches for Robot Stamina or battery capacity, and Robot Efficiency or less energy per move. I may be overlooking this completely. I have moderate experience with Lua to make this possible i may have to write a custom script or handler of some kind. IDK my brain is fried for trying the past 8 hours.
Please help and make any suggestions to make this possible
~ theonlyCozzy
Re: Technology modifying entity values directly
Posted: Thu May 12, 2016 3:17 pm
by ArderBlackard
AFAIK most of the entities' properties which are read-only in Lua are also read-only in C++ code and thus cannot be changed during the game process.
Re: Technology modifying entity values directly
Posted: Thu May 12, 2016 5:46 pm
by theonlyCozzy
i had feared that be the case. so if i were to achieve this i would have to have created more entities for robots with upgraded skills to be unlocked when a technology is researched
Thanks for the Reply!
Re: Technology modifying entity values directly
Posted: Thu May 12, 2016 7:14 pm
by Rseding91
ArderBlackard wrote:AFAIK most of the entities' properties which are read-only in Lua are also read-only in C++ code and thus cannot be changed during the game process.
Correct. For an explanation why: prototype data is immutable runtime. Because of that, we don't need to save out those properties to the save file since all users will always have that same version of the prototype data no matter what map they've got loaded. They are set on startup and the mod CRC system ensures everyone playing has the same version of the prototype files.
In order for something to be adjustable runtime we also have to include it in the save file (since it might be different than the default value). Having a large portion of entity properties come from the prototypes lets us use less RAM, save space in the save file, and gives better performance runtime from better cache hits.
Re: Technology modifying entity values directly
Posted: Fri May 13, 2016 8:09 am
by ratchetfreak
Rseding91 wrote:ArderBlackard wrote:AFAIK most of the entities' properties which are read-only in Lua are also read-only in C++ code and thus cannot be changed during the game process.
Correct. For an explanation why: prototype data is immutable runtime. Because of that, we don't need to save out those properties to the save file since all users will always have that same version of the prototype data no matter what map they've got loaded. They are set on startup and the mod CRC system ensures everyone playing has the same version of the prototype files.
In order for something to be adjustable runtime we also have to include it in the save file (since it might be different than the default value). Having a large portion of entity properties come from the prototypes lets us use less RAM, save space in the save file, and gives better performance runtime from better cache hits.
But that limits what you can upgrade through modded research. If there are instead upgradable prototype values it would be the best of both worlds.
You only need to keep the prototype values per force for upgradable force-owned entities. The number of forces will never reach ludicrous levels anyway.