Technology modifying entity values directly

Place to get help with not working mods / modding interface.
Post Reply
theonlyCozzy
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu May 12, 2016 1:36 pm
Contact:

Technology modifying entity values directly

Post 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

User avatar
ArderBlackard
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Thu May 05, 2016 12:41 pm
Contact:

Re: Technology modifying entity values directly

Post 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.
Gib dich hin bis du Glück bist

theonlyCozzy
Manual Inserter
Manual Inserter
Posts: 3
Joined: Thu May 12, 2016 1:36 pm
Contact:

Re: Technology modifying entity values directly

Post 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!

Rseding91
Factorio Staff
Factorio Staff
Posts: 13235
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Technology modifying entity values directly

Post 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.
If you want to get ahold of me I'm almost always on Discord.

ratchetfreak
Filter Inserter
Filter Inserter
Posts: 952
Joined: Sat May 23, 2015 12:10 pm
Contact:

Re: Technology modifying entity values directly

Post 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.

Post Reply

Return to “Modding help”