Help Porting Mod to 2.0

Place to get help with not working mods / modding interface.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1454
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Help Porting Mod to 2.0

Post 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,
Attachments
stdlib2_2.0.1.zip
(223.41 KiB) Downloaded 21 times
control.lua
(42.12 KiB) Downloaded 18 times
Bio_Industries_1.2.00.zip
(12.57 MiB) Downloaded 19 times
Crash.png
Crash.png (80.84 KiB) Viewed 436 times
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 577
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Help Porting Mod to 2.0

Post 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.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1454
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Porting Mod to 2.0

Post 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.
Attachments
Crash2.png
Crash2.png (65.12 KiB) Viewed 399 times
Bio_Industries_1.2.00.zip
(12.57 MiB) Downloaded 28 times
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 577
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Help Porting Mod to 2.0

Post 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.
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1454
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Porting Mod to 2.0

Post by TheSAguy »

Thanks Silari, this put me on the right track!
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1454
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Help Porting Mod to 2.0

Post 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.
Attachments
Tech.jpg
Tech.jpg (307.54 KiB) Viewed 307 times
Stuff.jpg
Stuff.jpg (101.88 KiB) Viewed 307 times
Bio_Industries_1.2.00.zip
(12.53 MiB) Downloaded 21 times
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 577
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Help Porting Mod to 2.0

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

Return to “Modding help”