[boskid][2.0.42] upgrade planner get_mapper() produces invalid output for set_mapper()

This subforum contains all the issues which we already resolved.
User avatar
SunBlade
Burner Inserter
Burner Inserter
Posts: 11
Joined: Mon Jan 15, 2018 8:27 am
Contact:

[boskid][2.0.42] upgrade planner get_mapper() produces invalid output for set_mapper()

Post by SunBlade »

Issue
  • when iterating items of an upgrade planner get_mapper() produces output not acceptable by set_mapper() most of the time.
  • get_mapper() always returns a table, even if the entry is empty.
  • type is always set, even if the entry is empty.
  • module_limit is always set, even on unsupported items and even if the checkmark is unset.
  • module_slots is always set, even on unsupported entities and even if the checkmark is unset.
  • module_slots is not allowed to be an empty table, even when all module slots should be emptied.
  • indices in module_slots do not match the configuration if prior module slots are empty.
  • set_mapper() only accepts entities and modules, failing for everything else like fuels and meta items.
  • set_mapper() for records in a shelf has been overwritten with get_mapper().
How to reproduce
  1. import this upgrade planner. currently affected by viewtopic.php?p=666798#p666798

    Code: Select all

    0eNq9ll1u4yAQx+/CcyzFdpMmftiLVFFFyDhFhYHFQ9Uo8gF6i33YvdieZCFumuaj/ki0fQMG/vPjbzOwZd6uHV/Bo1UcERwrtqwCIonrKrY1txZcaD5sWemMjmO0scAKJgk0GzHkOvagLKWQgGKTaLPyClg9YmS+nq8t7acmlTIUQj89V5I2Ieq4gzDQhB+V1JJYMf4YiPMj0yLkkLiC1xCsR12ErRk9CqO1wTAYGpY7Tia4wf6+/TmAlFJR49G7Jq8q0EsV3Eo0F08SIckvbeRE8jer2915F9jTHmsqWAOuuNucOZS2OZRe4dB/oZy1UWbfQTngv8o7eZwRz0BJ6UF1kKAXCrhrpvbzqpXtrpPNO47S613GRIA6TovGaa5Of88fHbu4pDkAehKhj+QBKfJ8JOBCeO3VDmeQ9PSCH23ih5X3fVaen/X0zKoei/IbK93sOtbsdlawUgxjnV/Hmt/OOuRIbQcWtLipgSs+1+FxD1Mqgni6nqCiL7d1cqn86jStj+iAj5tm9SJ0hMHGxEquMZSTw+24VB6sk0jJ0phn9vkq2snEslLsXyDJ/gUyYoovQ4EsGDWgL+EBIsPNXEym2fxuPp9M0/t8ls3q+h+8VvoJ
  2. place it in the first slot of the game blueprints library.
  3. run this console command.

    Code: Select all

    /c local bp = game.blueprints[1] for n = 1,bp.mapper_count do for _,t in pairs{"from","to"} do bp.set_mapper(n,t,table.deepcopy(bp.get_mapper(n,t))) end end
  • the supplied example save has the full planner already in the right spot.
  • you only need to run the console command.
Expected result
  • no errors.
  • no changes to the planner.
Actual result
  • almost every entry produces an error.
  • module slots configuration for crafting machines get distorted.
Attachments
factorio-current.log
(7.72 KiB) Downloaded 5 times
example.zip
(491.31 KiB) Downloaded 7 times
Live your life, you got only one.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3753
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.42] upgrade planner get_mapper() produces invalid output for set_mapper()

Post by boskid »

Thanks for the report. Due to amount of issues i was not strictly following your list, just fixing until lua stopped complaining and then verified that the upgrade planner looks the same as before lua changed all mappers. This should be now fixed for 2.0.43.
User avatar
SunBlade
Burner Inserter
Burner Inserter
Posts: 11
Joined: Mon Jan 15, 2018 8:27 am
Contact:

Re: [boskid][2.0.42] upgrade planner get_mapper() produces invalid output for set_mapper()

Post by SunBlade »

Thanks for the fast work.
you may want to also test the upgrade planner in the characters inventory using this command:

Code: Select all

/c local bp = game.player.get_main_inventory().find_item_stack{name="upgrade-planner"} for n = 1,bp.mapper_count do for _,t in pairs{"from","to"} do bp.set_mapper(n,t,table.deepcopy(bp.get_mapper(n,t))) end end

while testing import export (127742) i noticed the checkmark for 'Module slots' not working properly after import.
you may want to also check the three assembling machines. especially the last one, where you should be able to move the modules around.


first machine has the checkmark cleared.
am1.png
am1.png (58.56 KiB) Viewed 792 times

second machine has the checkmark set, but no modules.
am2.png
am2.png (51.18 KiB) Viewed 792 times

third machine has the checkmark set, and the modules should be movable to other slots.
am3.png
am3.png (49.01 KiB) Viewed 792 times
Live your life, you got only one.
User avatar
SunBlade
Burner Inserter
Burner Inserter
Posts: 11
Joined: Mon Jan 15, 2018 8:27 am
Contact:

Re: [boskid][2.0.42] upgrade planner get_mapper() produces invalid output for set_mapper()

Post by SunBlade »

sry, i forgot to mention that there is an easy way to view all of the get_mapper() output.


to get a nicely formatted array of all the mappings into the log and console window, you can us this command:

Code: Select all

/c local bp = game.player.get_main_inventory().find_item_stack{name="upgrade-planner"}
local arr = {}
for i = 1,bp.mapper_count do
	arr[i] = {index=i,from=bp.get_mapper(i,"from"),to=bp.get_mapper(i,"to")}
end
log(serpent.block(arr,{comment=false,sortkeys=false,sparse=true,compact=true,indent="\t"}))

and this command gives the same for the shelved record:

Code: Select all

/c local bp = game.blueprints[1]
local arr = {}
for i = 1,bp.mapper_count do
	arr[i] = {index=i,from=bp.get_mapper(i,"from"),to=bp.get_mapper(i,"to")}
end
log(serpent.block(arr,{comment=false,sortkeys=false,sparse=true,compact=true,indent="\t"}))
Live your life, you got only one.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3753
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.42] upgrade planner get_mapper() produces invalid output for set_mapper()

Post by boskid »

More tweaks done for 2.0.43.
Post Reply

Return to “Resolved Problems and Bugs”