Page 1 of 1

[Rseding91] Inactive entities from 0.18 can't be made active in 1.1

Posted: Mon Dec 07, 2020 4:55 pm
by Pi-C
TLDR: It seems that entities which have not been active when a game was saved in 0.18 can't be set to active once the game has been loaded into Factorio 1.1.x.

I've struggled with some strange behavior while trying to upgrade one of my mods for Factorio 1.1. The mod allows to "lock" an entity by setting the properties active, minable, and operable to false. I've tried to load an old save from 0.18 where two entities were locked and on was unlocked.

To change the lock status, I use this code:

Code: Select all

    local v_data = v_id and global.GCKI_vehicles[v_id]
    local v = v_data and v_data.entity

    if v and v.valid then
      -- Unlock vehicle on account of locker
      if v_data.locker and v_data.locker == player then
log("Unlocking")
        v.active = true
        v.operable = true
        -- If setting from Unminable Vehicles is enabled, no vehicle may be mined
        v.minable = true

        remove_vehicle_locker(v_id, player)
      -- Don't unlock a vehicle that has been locked by somebody else!
      elseif v_data.locker and v_data.locker ~= player then

      -- Lock vehicle on account of player
      else
log("Locking")
        v.active = false
        v.operable = false
        v.minable = false
        add_vehicle_locker(v_id, player)
      end
After importing the save, when I try to unlock one of the locked vehicles, "Unlocking" is logged, and v.minable and v.operable are set to true, but v.active remains at false. When I try to lock the unlocked vehicle, all properties (including active) are set to false, and when I then unlock that vehicle, all values are set to true again. The screenshots show the results for unlocking/locking the originally locked car:
The car already was locked in 0.18. "locker" is set, so all properties should be "false".
The car already was locked in 0.18. "locker" is set, so all properties should be "false".
locked.png (3.23 MiB) Viewed 2375 times
After unlocking the car in 1.1, "locker" isn't set, so all properties should be "true". However, "active" still is "false".
After unlocking the car in 1.1, "locker" isn't set, so all properties should be "true". However, "active" still is "false".
unlocked.png (3.08 MiB) Viewed 2375 times
I've suspected that perhaps something would be wrong with the saved game, so I started a new game in 0.18 where I reproduced the issue. The attachment contains the WIP version of my mod and the saved game from 0.18. (If Alt-mode is on, locked vehicles will be marked with an icon and can't be entered. Use the keys from the quickbar with the tank to unlock it. You now will be able to open its inventory and enter it, but you can't drive. Enter "/gvv" on the chat console if you want to get the GUI of "Global variable viewer".)

Re: Inactive entities from 0.18 can't be made active in 1.1

Posted: Mon Dec 07, 2020 7:28 pm
by Rseding91
Thanks for the report. It's now fixed for the next release.

Re: [Rseding91] Inactive entities from 0.18 can't be made active in 1.1

Posted: Tue Dec 08, 2020 8:19 am
by Pi-C
Great -- thanks for the quick fix! :-)