I wanted to make a simple mod that would add glass, and then another mod that would add beakers, so that beakers would be used in science packs. I'm making it just so I can kind of get used to making mods.
I decided I would use the silicone and oxygen items from the Bob's Intermediates mod so it would be a bit more interesting making it instead of just adding sand to the game. However, I don't know how to go about requiring (or using, for that matter) those items for my mod.
What I want to do is have 2 Oxygen + 1 Silicon plate = 5 Glass plates, and then 5 Glass plates = 1 Beaker. It would replace the original science pack recipes, the items would mostly be the same, but a beaker would be added to all of them. Of course, this means an item would have to be removed from the science pack 3 recipe.
Does anyone know how to do this? I can give more info if needed.
Requiring items/fluid from another mod?
-
- Burner Inserter
- Posts: 16
- Joined: Mon Jan 02, 2017 12:09 pm
- Contact:
Re: Requiring items/fluid from another mod?
Bob"s has glas already implemented.
-
- Burner Inserter
- Posts: 16
- Joined: Mon Jan 02, 2017 12:09 pm
- Contact:
Re: Requiring items/fluid from another mod?
Even so, I want still to make beakers, so I'd still like to know if there's a way to use items from other mods.steinio wrote:Bob"s has glas already implemented.
Re: Requiring items/fluid from another mod?
In info.json add the line
After that you can refer to any item in the mod as if it was in base mod.
Code: Select all
"dependencies": ["RequiredMod >= 1.2.3"]
My Mods: mods.factorio.com
-
- Burner Inserter
- Posts: 16
- Joined: Mon Jan 02, 2017 12:09 pm
- Contact:
Re: Requiring items/fluid from another mod?
I've put this in the info.json, so it looks like this now:Optera wrote:In info.json add the lineAfter that you can refer to any item in the mod as if it was in base mod.Code: Select all
"dependencies": ["RequiredMod >= 1.2.3"]
Code: Select all
{
"name": "BeakerMod",
"version": "0.1.0",
"factorio_version" : "0.14",
"title": "Beaker Mod",
"author": "Alphys_Hedge",
"contact": "",
"homepage": "",
"description": "Simply adds a beaker to factorio, which is used in science packs. Also removes advanced circuits from Science Pack 3 production."
"dependencies": ["bobplates >= 0.14.0"]
}
I'm not sure what could be causing this, since I pasted exactly what you said (with RequiredMod replaced with bobplates, of course). Do you know what could be causing this?
EDIT: Turns out it was just a comma after the description. Thank you for helping me, by the way!
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: Requiring items/fluid from another mod?
Yeah. A dependancy will not only require the mod to be installed, but force it to load first so you can access things defined in that mod's data files.
if you put a ? in front of the name, it means it's optional, it isn't needed, but if it's there it loads before your mod.
You can then do checks to see if an item exists, and do a thing if it does, for example:
if glass exists, add it as an ingredient to beaker, otherwise add plasic bar instead.
I use this sort of thing quite a lot in my mods, to make them modular, except I do it a bit differently now. I add the "else" stage first, then if the checked item exists, replace the old item with the new one. However, it's a lot harder to actually do, so if you're just learning, this is a good place to start.
Also, this is all off the top of my head without looking anything up, so, if it doesn't work, blame me for that.
if you put a ? in front of the name, it means it's optional, it isn't needed, but if it's there it loads before your mod.
You can then do checks to see if an item exists, and do a thing if it does, for example:
Code: Select all
if data.raw.item["glass"] then
table.insert(data.raw.recipe["beaker"].ingredient, {"glass", 1})
else
table.insert(data.raw.recipe["beaker"].ingredient, {"plastic-bar", 1})
end
I use this sort of thing quite a lot in my mods, to make them modular, except I do it a bit differently now. I add the "else" stage first, then if the checked item exists, replace the old item with the new one. However, it's a lot harder to actually do, so if you're just learning, this is a good place to start.
Also, this is all off the top of my head without looking anything up, so, if it doesn't work, blame me for that.