Page 1 of 1

[Genhis] [1.1.57] Setting item_requests on item request proxy with multiple items seems broken

Posted: Mon Apr 04, 2022 7:01 am
by SWeini
Hello guys,

I was playing around with nanobots and some other mods.
I copy&pasted an entity with 2 prod, 1 speed and 1 eff module, had no modules in inventory
then I grabbed a bunch of prod modules and nanobots filled all 4 module slots with prod modules

I drilled down a bit and to me it looks like setting the item_requests on an item request proxy is broken.

it comes down to this call sequence:

Code: Select all

local proxy = <some-item-request-proxy>
local requests = proxy.item_requests
-- requests is now {["effectivity-module"] = 1, ["productivity-module"] = 2, ["speed-module"] = 1}
-- the 2 prod modules were inserted into the entity by nanobots and should be removed from the request
requests["productivity-module"] = requests["productivity-module"] - 2
-- removing 0 values
requests["productivity-module"] = nil
-- requests is now {["effectivity-module"] = 1, ["speed-module"] = 1}
-- save to entity
proxy.item_requests = requests
local wrong_requests = proxy.item_requests
-- wrong_requests is now {["effectivity-module"] = 1, ["productivity-module"] = 2}
I can share more info if needed, just ask.

Re: [1.1.57] Setting item_requests on item request proxy with multiple items seems broken

Posted: Mon Apr 04, 2022 11:17 am
by Loewchen
Post a simple save and steps that produce the issue please.

Re: [1.1.57] Setting item_requests on item request proxy with multiple items seems broken

Posted: Mon Apr 04, 2022 5:35 pm
by SWeini
this is what you should see when you open the save (sorry for the huge modpack, but looks like I need at least 4 module slots for reproducing):
step0.png
step0.png (284.38 KiB) Viewed 3371 times
then you grab the production modules (and only those) from the box. the nanobots will do their work.

after supplying the two production modules it looks like this:
step1.png
step1.png (33.09 KiB) Viewed 3371 times
due to the bug they try to supply another two production modules, will look like this:
step2.png
step2.png (17.38 KiB) Viewed 3371 times
or the total situation:
final.png
final.png (229.93 KiB) Viewed 3371 times
if you add logging statements into "Nanobots_3.2.17\scripts\nanobots.lua" as shown here
log_code.png
log_code.png (34.9 KiB) Viewed 3371 times
you are going to see the behavior clearly
log_output.png
log_output.png (119.27 KiB) Viewed 3371 times

Re: [1.1.57] Setting item_requests on item request proxy with multiple items seems broken

Posted: Mon Apr 04, 2022 7:26 pm
by SWeini
I might have not played vanilla for too long - the assembling machine 3 has 4 module slots as well :)

I've attached another savegame with only nanobots mod, same bug, grab the production modules and see the nanobots fail

Re: [Genhis] [1.1.57] Setting item_requests on item request proxy with multiple items seems broken

Posted: Tue Apr 05, 2022 7:50 am
by Genhis
Thanks for the report and for the attached save, it made testing a lot easier. :) The issue is fixed for the next release.

Re: [Genhis] [1.1.57] Setting item_requests on item request proxy with multiple items seems broken

Posted: Tue Apr 05, 2022 11:00 am
by SWeini
Thanks a lot for the quick fix. You guys are the best.

P.S.: I'm a software dev myself, so I know the benefits of a good repro case. :D