Stack Size


Small mod to increase stack size

Content
5 days ago
1.1 - 2.1
24.6K
Logistics

i Also weight? (Didn't plan)

1 year, 4 months ago

The multiplication could also be done in a "reverse" way for the weight of the items, so rockets can also carry gigant ammounts of items :D

1 year, 4 months ago

I didn't consider this option)

a day ago

Hi! I hope you don’t mind—I used an AI tool to make some changes to the code in this mod. I’ve attached the modified code here for you to take a look at. In short: 500 assembling machines (one stack) now weigh 500 * 2 = 1000 kg. You can now fit exactly one stack (500 assembling machines) into a rocket—just as you could previously fit one stack (50 assembling machines).

-- 1. Safely read the setting
local stack_setting = settings.startup["stack_size"]
local new_stack_size = stack_setting and stack_setting.value or 500
new_stack_size = math.max(10, math.floor(new_stack_size))

-- 2. Get the rocket lift weight (usually 1000 kg)
local rocket_lift_weight = 1000 * kg
if data.raw["utility-constants"] and data.raw["utility-constants"]["default"] then
rocket_lift_weight = data.raw["utility-constants"]["default"].rocket_lift_weight or rocket_lift_weight
end

-- 3. Iterate over all prototypes
for , prototypes in pairs(data.raw) do
for
, prototype in pairs(prototypes) do
if prototype.stack_size and prototype.stack_size > 1 then
local old_stack_size = prototype.stack_size

  -- Try to determine the old weight
  local old_weight = prototype.weight

  -- If weight is not set explicitly, assume this is a "simple" item
  -- whose full stack weighed exactly the rocket capacity.
  if not old_weight then
    old_weight = rocket_lift_weight / old_stack_size
  end

  -- 4. Change the stack size
  prototype.stack_size = new_stack_size

  -- 5. Adjust weight proportionally so the total stack weight stays the same
  prototype.weight = old_weight * (old_stack_size / new_stack_size)
end

end
end

-- 6. Handle nuclear-fuel separately and safely
if data.raw.item and data.raw.item["nuclear-fuel"] then
local fuel = data.raw.item["nuclear-fuel"]
local old_stack = fuel.stack_size or 1
local old_weight = fuel.weight or (rocket_lift_weight / old_stack)

fuel.stack_size = new_stack_size
fuel.weight = old_weight * (old_stack / new_stack_size)
end

New response