Page 1 of 1

Help Porting Mod to 2.0

Posted: Sun May 18, 2025 5:38 pm
by TheSAguy
Hi,
I've been away for some time and am trying to get back into Factorio.
I'm trying to port my mod over the Factorio 2. (Not Space Age currently)

I'm getting the following crash that I'm hoping someone could help me with.
It's on the "control.lua" portion, when reading from a Library mod. Not sure what has changed in Factorio 2 to cause this.

I've attached the Crash message, the Control file by itself, the full mod and library.
Thanks,

Re: Help Porting Mod to 2.0

Posted: Sun May 18, 2025 6:51 pm
by Silari
Not familiar with metatables myself, but there is no global anymore. It was renamed storage in 2.0, so you'll need to change any references to the new name.

Re: Help Porting Mod to 2.0

Posted: Sun May 18, 2025 7:51 pm
by TheSAguy
Thanks Silari,
Okay got past that, now got something new.

It's been a long time since I've coded and will need some help. Not sure what's causing this issue.

Re: Help Porting Mod to 2.0

Posted: Sun May 18, 2025 9:17 pm
by Silari
You're going to need to go over all the breaking changes mentioned in viewtopic.php?t=70603 and look through the API pages https://lua-api.factorio.com/latest/index-runtime.html as you find issues. Prototypes have their own global object now, they're not under game anymore.

Re: Help Porting Mod to 2.0

Posted: Mon May 19, 2025 7:10 pm
by TheSAguy
Thanks Silari, this put me on the right track!

Re: Help Porting Mod to 2.0

Posted: Tue May 20, 2025 12:38 am
by TheSAguy
Okay, I got the mod loaded.
Now, for some reason, most, if not all the items the mod adds to the game show up from the start of the game. Even though the research has not been done and the "recipe" is enabled = false till researched.

I can craft them from the start, but no items appear once crafted.
What should I update now?

Code: Select all

  --- Bio Farm (ENTITY)
  {
    type = "recipe",
    name = "bi-bio-farm",
    localised_name = {"entity-name.bi-bio-farm"},
    localised_description = {"entity-description.bi-bio-farm"},
    icon = ICONPATH .. "Bio_Farm_Icon.png",
    icon_size = 64,
    icons = {
      {
        icon = ICONPATH .. "Bio_Farm_Icon.png",
        icon_size = 64,
      }
    },
    normal = {
      enabled = false,
      energy_required = 5,
      ingredients = {
        {"bi-bio-greenhouse", 4},
        {"stone-crushed", 10},
        {"copper-cable", 10},
      },
      results = {{type = "item", name = "bi-bio-farm", amount = 1}},
      main_product = "",
      allow_as_intermediate = false,    -- Added for 0.18.34/1.1.4
      always_show_made_in = false,      -- Added for 0.18.34/1.1.4
      allow_decomposition = true,       -- Added for 0.18.34/1.1.4
    },
    expensive = {
      enabled = false,
      energy_required = 7.5,
      ingredients = {
        {"bi-bio-greenhouse", 8},
        {"stone-crushed", 20},
        {"copper-cable", 20},
      },
      results = {{type = "item", name = "bi-bio-farm", amount = 1}},
      main_product = "",
      allow_as_intermediate = false,    -- Added for 0.18.34/1.1.4
      always_show_made_in = false,      -- Added for 0.18.34/1.1.4
      allow_decomposition = true,       -- Added for 0.18.34/1.1.4
    },
    subgroup = "bio-bio-farm-fluid-entity",
    order = "b[bi]",
    allow_as_intermediate = false,      -- Added for 0.18.34/1.1.4
    always_show_made_in = false,        -- Changed for 0.18.34/1.1.4
    allow_decomposition = true,         -- Changed for 0.18.34/1.1.4
  },

Thanks.

Re: Help Porting Mod to 2.0

Posted: Tue May 20, 2025 2:46 am
by Silari
There is no normal and expensive modes anymore, so the game is ignoring everything in those sections. Instead those properties are just in the root of the recipe.

Its one of the changes mentioned in the thread.
Removed normal and expensive properties from TechnologyPrototype and RecipePrototype.