Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions CustomStackSize/data-final-fixes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,32 @@ for _, category in pairs(stack_list) do
end
end
end

-- LUA doesn't have a built-in way to split strings, so...
-- Source - https://stackoverflow.com/a/7615129
-- Posted by user973713, modified by community. See post 'Timeline' for change history
-- Retrieved 2026-08-20, License - CC BY-SA 4.0
function strsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t = {}
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
table.insert(t, str)
end
return t
end

-- Custom user-added rules
for _, token in pairs(strsplit(settings.startup["stack-size-custom-others"].value, ";")) do
local proto_name, ssize = table.unpack(strsplit(token, "="))
if ssize then
local size = tonumber(ssize)
if size >= 1 and size <= 100000 then
local proto = find_proto(proto_name)
if proto then
proto.stack_size = size
end
end
end
end
2 changes: 2 additions & 0 deletions CustomStackSize/locale/en/settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ stack-size-metallic-asteroid-chunk=Space → Metallic asteroid chunk
stack-size-carbonic-asteroid-chunk=Space → Carbonic asteroid chunk
stack-size-oxide-asteroid-chunk=Space → Oxide asteroid chunk
stack-size-promethium-asteroid-chunk=Space → Promethium asteroid chunk
stack-size-custom-others=Others (custom rules)

[mod-setting-description]
stack-size-brick=Set the stack size for stone bricks. Default is 100. Minimum is 1. Maximum is 100000.
Expand Down Expand Up @@ -171,3 +172,4 @@ stack-size-metallic-asteroid-chunk=Set the stack size for metallic asteroid chun
stack-size-carbonic-asteroid-chunk=Set the stack size for carbonic asteroid chunks. Default is 1. Minimum is 1. Maximum is 100000.
stack-size-oxide-asteroid-chunk=Set the stack size for oxide asteroid chunks. Default is 1. Minimum is 1. Maximum is 100000.
stack-size-promethium-asteroid-chunk=Set the stack size for promethium asteroid chunks. Default is 1. Minimum is 1. Maximum is 100000.
stack-size-custom-others=Set here any custom rules for other/modded item prototypes. Rules are divided by ";" and are in the format "my-item-prototype=<stacksize>". Minimum recognized value is 1. Maximum is 100000.
10 changes: 10 additions & 0 deletions CustomStackSize/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@ for _, category in pairs(stack_list) do
end
end

settings_to_add[#settings_to_add + 1] = {
type = "string-setting",
name = "stack-size-custom-others",
setting_type = "startup",
default_value = "",
allow_blank = true,
-- allow_trim = false,
order = "za",
}

data:extend(settings_to_add)