Overriding someone else's mod

Place to get help with not working mods / modding interface.
CMH
Fast Inserter
Fast Inserter
Posts: 152
Joined: Mon May 02, 2016 3:02 am
Contact:

Re: Overriding someone else's mod

Post by CMH »

Thanks. Right now I'm just messing about with your ores, so I'm going to use the shortcut, but that extra info is handy if I ever add compatibility with other mods.

Also, the ore still pops up in the map generator. How do I remove it from that list?
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Overriding someone else's mod

Post by bobingabout »

using bobmods.ores.gold.enabled = false should turn that off if you put it in the data stage (not updates or final fixes).

if it doesn't work for whatever reason, use the other method I mentioned.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Overriding someone else's mod

Post by Arch666Angel »

CMH wrote:@Arch666Angel: I had a look at your mod. I don't really understand how you have programmed the ore generation. Would appreciate a bit of explanation to what you have done :D

Also, wondering how to remove an ore from bobsores (say I'd like to remove gold ore fields from being generated).

I'm thinking the easiest way would be for me to totally remove the ores I don't need, and re-write the ores>plates to the ones I want. There's no real need for me to generate new ores if I can just take over the ones already generated, although it does mean I'll need to remove the ones I don't want.

p.s. I will post my mod here when I think I've got enough for a release

viewtopic.php?f=97&t=26024
Depends really on what you want to achieve. For simply disabling the ores bob provided a number of ways to do it.

Important is that you have set the dependency to bobores, so they will load BEFORE your own mod and than it's also best to place your override in the data-updates.lua.

What I do in my mods happens in two places, there is the ore disabling in angelsinfiniteores/prototypes/angels-override:

Code: Select all

if bobmods.ores then
data.raw.resource["bauxite-ore"] = nil
data.raw["autoplace-control"]["bauxite-ore"] = nil

data.raw.resource["cobalt-ore"] = nil
data.raw["autoplace-control"]["cobalt-ore"] = nil

data.raw.resource["gem-ore"] = nil
data.raw["autoplace-control"]["gem-ore"] = nil

data.raw.resource["gold-ore"] = nil
data.raw["autoplace-control"]["gold-ore"] = nil

data.raw.resource["lead-ore"] = nil
data.raw["autoplace-control"]["lead-ore"] = nil

data.raw.resource["nickel-ore"] = nil
data.raw["autoplace-control"]["nickel-ore"] = nil

data.raw.resource["quartz"] = nil
data.raw["autoplace-control"]["quartz"] = nil

data.raw.resource["rutile-ore"] = nil
data.raw["autoplace-control"]["rutile-ore"] = nil

data.raw.resource["silver-ore"] = nil
data.raw["autoplace-control"]["silver-ore"] = nil

data.raw.resource["sulfur"] = nil
data.raw["autoplace-control"]["sulfur"] = nil

data.raw.resource["tin-ore"] = nil
data.raw["autoplace-control"]["tin-ore"] = nil

data.raw.resource["tungsten-ore"] = nil
data.raw["autoplace-control"]["tungsten-ore"] = nil

data.raw.resource["zinc-ore"] = nil
data.raw["autoplace-control"]["zinc-ore"] = nil
end
I dont bother with disabling the noise layers, but bob has a point there to do it, although if nothing uses them they should really draw any cpu. If you want to do a real clean job, check for each entity before disabling it.
Another way is to delete the autoplace-control, the noise-layer and the autoplace from the resource entity, but keeping the rest of the resource entity for mod which are dependend on that, I ran into an issue for example with landfill when I disabled the stone resource entity.
CMH
Fast Inserter
Fast Inserter
Posts: 152
Joined: Mon May 02, 2016 3:02 am
Contact:

Re: Overriding someone else's mod

Post by CMH »

@bobingabout: ah, it works now. I did put it in data-updates, that was the problem! Thanks.

@Arch66Angel: Ok, that makes sense. Problem with looking at someone else's mod is that there's so many files, and the codes refer everywhere I wasn't sure exactly what I should be looking at.
User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Overriding someone else's mod

Post by Arch666Angel »

CMH wrote:@bobingabout: ah, it works now. I did put it in data-updates, that was the problem! Thanks.

@Arch66Angel: Ok, that makes sense. Problem with looking at someone else's mod is that there's so many files, and the codes refer everywhere I wasn't sure exactly what I should be looking at.
I also did start with trying to understand what other people did, specially bob. And the real magic is in using functions and doing stuff with scripts. Most of what I do with my mods is pure modifying other and writing new entity definitions...and graphics of course.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Overriding someone else's mod

Post by bobingabout »

Arch666Angel wrote:I also did start with trying to understand what other people did, specially bob. And the real magic is in using functions and doing stuff with scripts. Most of what I do with my mods is pure modifying other and writing new entity definitions...and graphics of course.
That's how I started.
Then you realise that there's cases where you do the same thing over and over.
and then you do the same thing in 2 mods, so it happens twice, and causes a crash, so you need to do a check before you do it.
before you know it, you have this huge sprawling if block doing endless checks, repeated several times, so you make it a function to reduce the size of your code, and repeatings.
then you end up using the same function in multiple mods that were doing the same, or similar things.
so you remove the repeating functions from each mod, and put them in a common mod, and then you end up with a library.
And then you find the library is so useful, you start to shift away from edited blocks of copied code, to using mostly functions to build it for you.

And that's how my mods ended up as they are now.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
CMH
Fast Inserter
Fast Inserter
Posts: 152
Joined: Mon May 02, 2016 3:02 am
Contact:

Re: Overriding someone else's mod

Post by CMH »

Doubt mine will come anywhere close to the complexity of either of your mods guys.

Anyway, a new hurdle: adding my own technology.

I've put this into a technology.lua file, but it gives me a "Error while loading technology prototype "aluminium-titanium" (technology): No such node (type)" error.

Code: Select all

data:extend(
{
  {
    type = "technology",
    name = "aluminium-titanium",
    icon = "__CMHMod__/graphics/icons/aluminium-titanium2.png",
    prerequisites =
    { "aluminium-processing", "titanium-processing",   },
    effects =
    { type = "unlock-recipe",
      recipe = "aluminium-titanium",
    },
    unit =
    {
      count = 75,
      ingredients =
      {
        {"science-pack-1", 1},
        {"science-pack-2", 1},
        {"science-pack-3", 1},
        {"science-pack-4", 1},
      },
      time = 30,
    }
  }
}
)
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: Overriding someone else's mod

Post by prg »

effects should be a table of tables.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
CMH
Fast Inserter
Fast Inserter
Posts: 152
Joined: Mon May 02, 2016 3:02 am
Contact:

Re: Overriding someone else's mod

Post by CMH »

Sorry, I'm kinda new to this. What do you mean?

p.s. I figured out what you meant. Thanks :D
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Overriding someone else's mod

Post by bobingabout »

CMH wrote:Sorry, I'm kinda new to this. What do you mean?

p.s. I figured out what you meant. Thanks :D
{} denotes a table. {{}} denotes a table in a table.
Effects requires a table of tables.
This means you want..
effects = {
{unlock 1},
{unlock 2},
etc
},

in this specific instance, you need to replace this

Code: Select all

effects =
    { type = "unlock-recipe",
      recipe = "aluminium-titanium",
    },
with this

Code: Select all

effects = {
      {
        type = "unlock-recipe",
        recipe = "aluminium-titanium"
      }
    },
Linebreaks are optional, If you want it to be a little clearer, you can put each entry on it's own line, like this:

Code: Select all

effects = {
      { type = "unlock-recipe", recipe = "aluminium-titanium" }
    },
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
CMH
Fast Inserter
Fast Inserter
Posts: 152
Joined: Mon May 02, 2016 3:02 am
Contact:

Re: Overriding someone else's mod

Post by CMH »

Thanks for explaining it.

Just for those interested a version of this mod is up.

viewtopic.php?f=97&t=26024
CMH
Fast Inserter
Fast Inserter
Posts: 152
Joined: Mon May 02, 2016 3:02 am
Contact:

Re: Overriding someone else's mod

Post by CMH »

@bobingabout

I've just run into a small issue with boblibrary.

I'm trying to get a recipe to change from alien science to your science 4, but it doesn't seem to want to change.

Here's the coding:

Code: Select all

if data.raw.tool["science-pack-4"] then
  bobmods.lib.replace_science_pack ("aluminium-titanium", "alien-science-pack", "science-pack-4")
end
The game loads up fine, but it still requires alien science instead of science pack 4.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Overriding someone else's mod

Post by bobingabout »

Due to the fact that most of the errors that occur in the library mod basically just point you to the line in the library mod, I took the approach that the library functions will do as many checks as possible to see if the data you are passing it is valid, and if it isn't, just discard it and cancel. Of course this isn't the case everywhere yet, certain functions will still error rather than drop it, but the one in your example is one of the ones that does not error. If there is no error, and you are not seeing the expected results, the issue is most likely that you did something wrong.

The first thing I would check is if your spelling is correct. I would also suggest that if it is in the data.lua phase that you move it to data-updates.lua phase instead, the non-existing item drop-out might be a result of the science-pack-4 item not existing yet if it is in the data phase.


That's about as much information I can think of right now that might be useful.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
CMH
Fast Inserter
Fast Inserter
Posts: 152
Joined: Mon May 02, 2016 3:02 am
Contact:

Re: Overriding someone else's mod

Post by CMH »

Thanks.

I fixed the problem, but it was my coding noobiness that did it.

I didn't think that the order of the "requires" in data.lua mattered (it definitely does!).
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Overriding someone else's mod

Post by bobingabout »

Glad to hear you figured it out.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”