Trouble with auto_barrel [SOLVED]

Place to get help with not working mods / modding interface.
Post Reply
Tomarse
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Jan 09, 2024 7:28 am
Contact:

Trouble with auto_barrel [SOLVED]

Post 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!
Last edited by Tomarse on Fri Jan 12, 2024 7:36 am, edited 1 time in total.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Trouble with auto_barrel

Post 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.
Image

Tomarse
Manual Inserter
Manual Inserter
Posts: 2
Joined: Tue Jan 09, 2024 7:28 am
Contact:

Re: Trouble with auto_barrel

Post 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.

Post Reply

Return to “Modding help”