[2.0.11] LuaItemStack.set_stack lacks quality adjustment

Things that already exist in the current mod API
sensenmann
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Feb 28, 2017 5:04 pm
Contact:

[2.0.11] LuaItemStack.set_stack lacks quality adjustment

Post by sensenmann »

In my mod i want to do this:

Code: Select all

local stacksize = entity.cursor_stack.count --record amount
local old_quality = entity.cursor_stack.quality --record quality
entity.cursor_stack.clear() --clear the slot
entity.cursor_stack.set_stack({ name = "alien-hyper-module-" .. math.min(storage.currentmodulelevel[forceName], 100), count = stacksize, quality = old_quality })
But the parameter quality has no effect, i guess since https://lua-api.factorio.com/2.0.8/clas ... ml#quality is readonly.
But how do i create a new stack of items with the desired quality? At the moment i see no way.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3940
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [2.0.11] LuaItemStack.set_stack lacks quality adjustment

Post by boskid »

Dunno, i did a quick test with following command:

Code: Select all

/c
local entity = game.player.character
local stacksize = entity.cursor_stack.count
local old_quality = entity.cursor_stack.quality
entity.cursor_stack.clear()
entity.cursor_stack.set_stack({ name = "iron-plate", count = stacksize, quality = old_quality })
and 100 copper plates of rare quality turned into 100 iron plates of rare quality.
sensenmann
Burner Inserter
Burner Inserter
Posts: 13
Joined: Tue Feb 28, 2017 5:04 pm
Contact:

Re: [2.0.11] LuaItemStack.set_stack lacks quality adjustment

Post by sensenmann »

Sorry i missed that i had 2 loops for different usecases, now it works, thanks!
10-27-2024, 20-45-24.png
10-27-2024, 20-45-24.png (217.35 KiB) Viewed 556 times
Post Reply

Return to “Already exists”