Page 1 of 1

migration of items by json?

Posted: Sun Nov 10, 2019 4:40 pm
by Cobaltur
I want to migrate my items(chests and inventories) and entities (placed on map)
I have already a migration script for the placed entities because json migration can not handle the additional manipulation to my global values.

So items are left to migrate.
I think this might be the rigth way ( [old, new] tuple)

Code: Select all

		[ "rand-combinator","math-allInOne"],
		[ "max-combinator","math-allInOne"],
		[ "min-combinator","math-allInOne"],
		[ "avg-combinator","math-allInOne"],
		[ "med-combinator","math-allInOne"],
		[ "sum-combinator","math-allInOne"],
		[ "cnt-combinator","math-allInOne"],
		[ "dif-combinator","math-allInOne"],
		[ "int-combinator","math-allInOne"]
and I can see in the log that this file has been used

Code: Select all

Info PrototypeMigrationList.cpp:61: Activating migration MathCoProcessor/0_17_7.json
but the items in chests and inventories are not touched.
Maybe it is that obvious that I cannot see the problem or I have defintly the wrong idea :D

A code snippet for on_configuration_changed would be also acceptable. Or at least if I can destroy them so the can no longer be used for buildings.

Bonus: What about blueprints? Fine for the moment if I cannot update them. I had to keep the old recipes anyway so I would be ok for me to see ghosts of old deleted entities so the player can manually add the new entity.

Re: migration of items by json?

Posted: Sun Nov 10, 2019 6:33 pm
by Bilka
From my experience, the old item prototypes have to be removed for the migration to do anything.

Re: migration of items by json?

Posted: Sun Nov 10, 2019 9:52 pm
by Cobaltur
Hello Bilka,
JSON migrations are applied as a map is loaded. Multiple such migrations can be applied at once.
All JSON migrations are applied before any Lua migration is applied.
hmm what means removing? Just no longer adding them or what is the correct event to remove them? It seems JSON migration is the first thing that runs (see 3)

1) If I do not add them in my item.lua any longer

Code: Select all

local names = {"max-combinator","min-combinator","rand-combinator","avg-combinator","med-combinator", "sum-combinator","cnt-combinator" }
local names2 = {"dif-combinator", "int-combinator" }

-- for i, name in ipairs(names) do
-- 	local item = table.deepcopy(data.raw.item["constant-combinator"])
-- = name
-- 	item.place_result= name
-- 	item.order = "b[combinators]-m[""]"
-- 	data:extend({item})
-- end

I will end in

Code: Select all

   0.803 Checksum of MathCoProcessor: 1263696112
   0.938 Error ModManager.cpp:1323: Error in assignID, item with name 'max-combinator' does not exist.
2) Removing the reference in the technology is the only thing that does not crash the loading but is not enought.

3) If I delete enties, items and recipe then the entities are no longer "valid" in on_configuration_changed event. Therefore I can not run my "replace enties"-migration script.

Code: Select all

  12.442 Checksum for script C:/Users/BigOne/AppData/Roaming/Factorio/temp/currently-playing/control.lua: 2297339679
  12.443 Checksum for script __MathCoProcessor__/control.lua: 1640031078
  12.477 Script @__MathCoProcessor__/migrate.lua:17: v0_17_7
  12.646 Error AppManagerStates.cpp:1443: The mod Math coprocessors caused a non-recoverable error.
Please report this error to the mod author.

Error while running event MathCoProcessor::on_configuration_changed
LuaEntity API call when LuaEntity was invalid.
stack traceback:
	__MathCoProcessor__/migrate.lua:33: in function 'v0_17_7'
	__MathCoProcessor__/migrate.lua:10: in function 'migrations'
	__MathCoProcessor__/control.lua:495: in function <__MathCoProcessor__/control.lua:494>
Even I cannot substitute the deprecated items with the new generic one (which will get their later behavior by settings on the entity) I want to get rid of the items in chests and inventories.