Page 1 of 1

[Dominik] [0.15.32] Big recipes not completing

Posted: Sun Aug 06, 2017 3:44 pm
by EmperorZelos
We have seen the thing about inputs getting huge past stack sizes in them, which when uncapped is bad but it is good when recipes are fairly big and consumes a lot of resources.

However on the output side it should allow any amount that is outputted, it does it for fluids. But for items I found that if it surpasses the stack size, it won't finish the recipe ever.

Re: [0.15.32] Big recipes not completing

Posted: Sun Aug 06, 2017 9:40 pm
by Klonan
Could you provide some further clarification?

A screenshot/video of the issue, a mod with this problem, and a save game with a setup already built demonstrating it would be really helpful

Re: [0.15.32] Big recipes not completing

Posted: Mon Aug 07, 2017 4:20 am
by EmperorZelos

Re: [0.15.32] Big recipes not completing

Posted: Mon Aug 07, 2017 12:15 pm
by Arch666Angel
You have to split the result to stack sizes by hand there, for results with more than one stack, just add another line in results with the same item, it will be put into an additional output slot then.

Re: [0.15.32] Big recipes not completing

Posted: Mon Aug 07, 2017 1:56 pm
by EmperorZelos
That's a nice solution, should be fixed though :P

Re: [Dominik] [0.15.32] Big recipes not completing

Posted: Wed Sep 06, 2017 2:40 pm
by Dominik
Hi,
this is not a problem we would normally encounter in the game, but yes, the possibility of creating more than a stack size should be there and will be from 0.16.
Keep modding, just don't get too crazy :D

Re: [Dominik] [0.15.32] Big recipes not completing

Posted: Sun Nov 26, 2017 6:54 am
by Optera
Here's the fix I wrote for ReStack. It works on all recipes producing 1 stack per item.
As I'm not playing with any mod producing multiple stacks of the same item I have not (yet) handled that possibility. Easiest way to handle that would be to aggregate those stacks into a single stack before splitting it into new stacks.

Code: Select all

-- fix recipes with result_count or results.amounts > item.stack_size
for _, recipe in pairs(data.raw.recipe) do
  if recipe.result and recipe.result_count then -- if result_count == nil factorio will output 1 item
    local item = data.raw.item[recipe.result]
    if item and recipe.result_count > item.stack_size then
      log("[RS] Fixing recipe "..tostring(recipe.name)..", result "..tostring(item.name).." result_count: "..tostring(recipe.result_count).."/"..tostring(item.stack_size))
      -- split into multiple results
      recipe.icon = item.icon
      recipe.localised_name = {"item-name."..item.name}
      recipe.subgroup = item.subgroup
      recipe.results = {}
      local remaining_size = recipe.result_count
      for i=1, math.ceil(recipe.result_count/item.stack_size) do
        table.insert(recipe.results, { type = "item", name = item.name, amount = math.min(item.stack_size, remaining_size) })
        remaining_size = remaining_size - item.stack_size
      end
      recipe.result = nil
      recipe.result_count = nil
    end
  elseif recipe.results then
    for index=#recipe.results, 1, -1 do
      local result = recipe.results[index]
      if result.type == "item" then
        local item = data.raw.item[result.name]
        if item and result.amount and result.amount > item.stack_size then -- skip over recipes with result.amount_min and result.amount_max
          log("[RS] Fixing recipe "..tostring(recipe.name)..", result["..index.."] "..tostring(item.name).." amount: "..tostring(result.amount).."/"..tostring(item.stack_size))
          -- replace single result with multiple
          local probability = result.probability
          local total_amount = result.amount
          local remaining_size = total_amount
          table.remove(recipe.results, index)
          for i=1, math.ceil(total_amount/item.stack_size) do
            table.insert(recipe.results, { type = "item", name = item.name, amount = math.min(item.stack_size, remaining_size), probability = probability })
            remaining_size = remaining_size - item.stack_size
          end

        end
      end
    end
  end
end

Re: [Dominik] [0.15.32] Big recipes not completing

Posted: Sun Nov 26, 2017 11:04 pm
by mrvn
Would it be possible to get this workaround into the 0.15 base mod till it gets fixed for real in 0.16?

Re: [Dominik] [0.15.32] Big recipes not completing

Posted: Fri Dec 01, 2017 3:26 pm
by Dominik
mrvn wrote:Would it be possible to get this workaround into the 0.15 base mod till it gets fixed for real in 0.16?
Just hang tight. As far as I know we do not plan any other 0.15 releases before 0.16.