How to change other mod's research?

Place to get help with not working mods / modding interface.
Sesame_Slayer
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Aug 10, 2022 10:12 pm
Contact:

How to change other mod's research?

Post by Sesame_Slayer »

I have been developing a mod to modify bob's adjustable inserters mod to make the tier two technologies go after Logistics 2 instead of Logistics 3, as it is more useful then. This is my first time using the Lua language. I made it dependent on bob's inserters to have my code override it, made the data and info files, and made a file where I copied the bob's inserters technology file's tier 2 research, and changed them to only red and green science, and have Logistics 2 instead of 3 as a prerequisite. However, in game, it doesn't do anything. Here's all my (janky) code:


Data:

Code: Select all

require("prototypes.technology")

Info:

Code: Select all

{
  "name": "BobInserters-Early-T2-Research",
  "version": "0.1.3",
  "title": "Bob Inserters Earlier T2 Research",
  "author": "Sesame_Slayer",
  "factorio_version": "1.1",
  "dependencies": ["base >= 1.1", "bobinserters >= 1.1.5"],
  "description": "Makes the long inserters and more inserters tier 2 researches from Bob's Adjustable Inserters line up with Logistics 2 instead of logistics 3, as at logistics 3 it is no longer needed. Report bugs on the mod portal."
}

My technology code:

Code: Select all

if settings.startup["bobmods-inserters-long2"].value == true and not data.raw.technology["long-inserters-2"] then
data:extend(
{
  {
    type = "technology",
    name = "long-inserters-2",
    icon = "__bobinserters__/graphics/icons/technology/long-inserters.png",
    icon_size = 128,
    effects =
    {
    },
    prerequisites =
    {
      "long-inserters-1",
      "logistics-2",
    },
    unit =
    {
      count = 50,
      ingredients =
      {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1},
      },
      time = 10
    },
    order = "a-f-a-2",
  },
}
)
end


if settings.startup["bobmods-inserters-more2"].value == true and not data.raw.technology["more-inserters-2"] then
data:extend(
{
  {
    type = "technology",
    name = "more-inserters-2",
    icon = "__bobinserters__/graphics/icons/technology/more-inserters.png",
    icon_size = 128,
    effects =
    {
    },
    prerequisites =
    {
      "more-inserters-1",
      "logistics-2",
    },
    unit =
    {
      count = 50,
      ingredients =
      {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1},
      },
      time = 10
    },
    order = "a-f-c-2",
  },
}
)
end
the file tree:
zip file
|main file
||prototypes
|||technology
||changelog
||data
||info
||thumbnail

How could I change it to work? am I missing something? I didn't really understand the mod tutorial page on the wiki. I saw something about a control document, but I don't understand it.

the mod portal link:
https://mods.factorio.com/mod/BobInsert ... 2-Research

Source code:
https://github.com/SesameSlayer/Bob-Ins ... ource-code
Last edited by Sesame_Slayer on Thu Aug 11, 2022 7:39 pm, edited 4 times in total.
Koub
Global Moderator
Global Moderator
Posts: 7772
Joined: Fri May 30, 2014 8:54 am
Contact:

Re: How to change other mod's research?

Post by Koub »

[Koub] Moved to modding help
Koub - Please consider English is not my native language.
User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 530
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: How to change other mod's research?

Post by Silari »

If you just want to change the prerequisite why are you trying to redefine the entire technology? On top of that, your code is set up to not do anything at all if the technology already exists, except it's always going to exist because they're in bob's inserters, which your mod requires. I'm guessing you just copied the code wholesale out of the mod, which isn't going to work.

It's far easier to just test if the tech exists, and if it does change the prereqs. This should be all you need in data.lua:

Code: Select all

if data.raw.technology["long-inserters-2"] then
    data.raw.technology["long-inserters-2"].prerequisites =
    {
      "long-inserters-1",
      "logistics-2",
    }
end
if data.raw.technology["more-inserters-2"] then
    data.raw.technology["more-inserters-2"].prerequisites =
    {
      "more-inserters-1",
      "logistics-2",
    }
end
Can't test it, but that should do the job.
Sesame_Slayer
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Aug 10, 2022 10:12 pm
Contact:

Re: How to change other mod's research?

Post by Sesame_Slayer »

thanks! sorry, i've never made a mod before, so i just assumed redefining the technology would overwrite the old one.
Half the time, I'm half asleep.
Sesame_Slayer
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Aug 10, 2022 10:12 pm
Contact:

Re: How to change other mod's research?

Post by Sesame_Slayer »

Just realized, I also need to change science packs, because production and chemical science packs are after logistics 2. can i just add after data.raw.technology["long-inserters-2"].prerequisites, data.raw.technology["long-inserters-2"].ingredients and add the ingredients?

edit: didn't work, but your code did.

code is:

Code: Select all

if data.raw.technology["long-inserters-2"] then
    data.raw.technology["long-inserters-2"].prerequisites =
    {
      "long-inserters-1",
      "logistics-2",
    }
    data.raw.technology["long-inserters-2"].ingredients =
    {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1}
    }
end
if data.raw.technology["more-inserters-2"] then
    data.raw.technology["more-inserters-2"].prerequisites =
    {
      "more-inserters-1",
      "logistics-2",
    }
    data.raw.technology["more-inserters-2"].ingredients =
    {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1}
    }
end
Do I have to make it:

Code: Select all

data.raw.technology["long-inserters-2"].unit =
    {
      count = 50,
      ingredients =
      {
        {"automation-science-pack", 1},
        {"logistic-science-pack", 1},
      },
      time = 15
    },
    order = "a-f-a-2",
  },
}
end
Last edited by Sesame_Slayer on Fri Aug 12, 2022 5:04 pm, edited 1 time in total.
Half the time, I'm half asleep.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3714
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to change other mod's research?

Post by DaveMcW »

There is no ingredients property on the technology prototype.

You need data.raw.technology["long-inserters-2"].unit.ingredients
Sesame_Slayer
Burner Inserter
Burner Inserter
Posts: 14
Joined: Wed Aug 10, 2022 10:12 pm
Contact:

Re: How to change other mod's research?

Post by Sesame_Slayer »

thanks! My mod finally works. I'll credit you in the changelog.
Half the time, I'm half asleep.
Post Reply

Return to “Modding help”