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?