Page 1 of 1

Unit entities created on an old mod prototype version have "cached" movement_speed

Posted: Wed Oct 18, 2023 11:36 pm
by Muppet9010
It seems that if a unit is created in a map and the game saved. Then the unit prototype's speed is changed in the mod. When the game is loaded the existing units keep the old prototype speed, with any newly placed units getting the new prototype speed.
See demo video, save and sample mod attached.

In this demo you can see I have ended up with 3 different speed versions of my single custom unit prototype. I hit this when adjusting my unit's speed to try and find a good balance for a new unit and had saved the test map to make this iterative process quicker.
  • Have mod with custom unit. (as per atatched)
  • Load game and pause game speed in the editor.
  • Place unit in map with an enemy target near by. So the unit will path towards the turret.
  • Save map and close game.
  • Edit mod to change movement_speed of prototype. (https://lua-api.factorio.com/latest/pro ... ment_speed)
  • Load game and load save.
  • Place another instance of the unit in the map by the first one.
  • Unpause the game speed.
  • Notice that the 2 instances of the same custom unit prototype move at different speeds. They also list different speeds on the entity details panel on the right hand side. But both show the current speed in the prototype explorer, confirming they are the same prototype.

Re: Unit entities created on an old mod prototype version have "cached" movement_speed

Posted: Thu Oct 19, 2023 5:36 am
by Klonan
The speed of the unit is runtime read/write, you can set it to anything at runtime, the prototype just acts as the 'default max speed'
https://lua-api.factorio.com/latest/cla ... html#speed

You can write the speed in a migration to fix it up yourself if you want,
In short this isn't a bug