Page 1 of 1

Trouble with auto_barrel [SOLVED]

Posted: Tue Jan 09, 2024 7:33 am
by Tomarse
Hello, I am currently working on a mod. I have a fluid which I have created. The following is in a file required by my data.lua:

Code: Select all

local liquid_pyrolysis_oil ={{
  type = "fluid",
  name = "liquid-pyrolysis-oil",
  default_temperature = 25,
  heat_capacity = "0.1KJ",
  base_color = {r=0.8,g=0.8,b=0.8},
  flow_color = {r=0.8,g=0.8,b=0.8},
  icon = "__toms-byproducts__/graphics/icons/liquid-pyrolysis-oil.png",
  icon_size = 64, icon_mipmaps = 4,
  order = "a[fluid]-z[liquid_pyrolysis_oil]",
  auto_barrel = true
}}
data:extend(liquid_pyrolysis_oil)
The fluid appears in the game, and works perfectly, except that there are no barrels for it in the crafting menu. The auto_barrel function is not working for me, and I'm not sure what I'm doing wrong. Since this script is called by data.lua, it should execute in time to be picked up by the auto barrel function, right? And yet it does not work.

If someone could please point out to me what I'm doing wrong, it would be greatly appreciated!

Re: Trouble with auto_barrel

Posted: Tue Jan 09, 2024 5:14 pm
by Deadlock989
Tomarse wrote:
Tue Jan 09, 2024 7:33 am
works perfectly, except that there are no barrels for it in the crafting menu
Do the barrels appear in the barrelling technology tooltip? If so, but they don't appear in the crafting menu, then autobarrel is working but the recipe is simply not unlocked - most likely because the tech is already researched, in which case you will need to add a migration. If the barrels don't appear in the tech unlocks then something else is going on, hard to say what without access to the mod.

Re: Trouble with auto_barrel

Posted: Wed Jan 10, 2024 9:51 am
by Tomarse
For anyone coming here with a similar problem, here is my solution:

I made a script in my migrations folder called "barreling.lua", which checks to see if the barreling technologies are unlocked, and if they are, it enables the recipes.

Code: Select all

for index, force in pairs(game.forces) do
  if force.technologies["oil-processing"].researched then -- When the oil processing is already researched, we need to enable the the recipes it unlocks
    force.recipes["fill-tbp-liquid-pyrolysis-oil-barrel"].enabled = true
    force.recipes["empty-tbp-liquid-pyrolysis-oil-barrel"].enabled = true
  end
end
This code is only necessary if you load a save that did not previously have the mod, but otherwise you might not have access to barreling of your fluid.