need help with for .... in pairs
Posted: Sun Jun 13, 2021 12:11 am
Hi Guys! Sorry, I'm bad in English.
I'm trying to change the stack size for some items. I have this code:
but nothing change... It seems to me that in "e" is not an item structure and in "i" is not an index of items array. Or is the problem something else?
UPD: I understand that problem is not with "e" and "i". If I use item internal name in condition operator then stack size is already changes. Why it doesn't works with finding a substring?
I'm trying to change the stack size for some items. I have this code:
Code: Select all
--data-final-fixes.lua
local items = data.raw.item
function get_stack_size(str)
-- if the specified name has such a substring, then return the specified stack size
if str:find("transport-belt") ~= nil then return settings.startup["Ket-transport-belt-stack-size"].value end
return nil
end
local size = nil
for i, e in pairs(items) do
size = get_stack_size(e.name)
if size ~= nil then
e.stack_size = size
size = nil
end
end
UPD: I understand that problem is not with "e" and "i". If I use item internal name in condition operator then stack size is already changes. Why it doesn't works with finding a substring?