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

Bugs that are actually features.
Post Reply
User avatar
Muppet9010
Filter Inserter
Filter Inserter
Posts: 278
Joined: Sat Dec 09, 2017 6:01 pm
Contact:

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

Post 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.
Attachments
unit speed test.zip
mod
(1.23 MiB) Downloaded 25 times
unit_test_1.0.0.zip
save as seen in video
(537 Bytes) Downloaded 27 times
factorio_aMVacJ9YiT.mp4
demo video
(3.36 MiB) Downloaded 29 times

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

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

Post 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

Post Reply

Return to “Not a bug”