Using a Core mod to add subgroups

Place to get help with not working mods / modding interface.
Post Reply
User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Using a Core mod to add subgroups

Post by sporefreak »

Im trying to put together an optional mod that I can base all my mods on, IE Adding a subgroup for all my personal items, however when i create a new item group (New tab) and subgroups I am unable to set the items to those subgroups. on launch i get "Subgroup does not exist" errors.
Is there something im missing? How would one correctly cross mod subgroup items together?


Both work fine until i set super_press to use the coals subgroup
Core
Other mod
I dont usually throw spore into everything im just trying to get something to work and sort how I want it to.

User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Using a Core mod to add subgroups

Post by Arch666Angel »

You probably have to add a dependency for the groups mod to your other mods, so the group mod loads first. This can be done in the info.json you have in your mods folder.

User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Re: Using a Core mod to add subgroups

Post by sporefreak »

Arch666Angel wrote:You probably have to add a dependency for the groups mod to your other mods, so the group mod loads first. This can be done in the info.json you have in your mods folder.
Either its not working or im doing it wrong, Still get the same error

"dependencies": ["base >= 0.12.00", "Spcore >= 0.0.1"]

User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Re: Using a Core mod to add subgroups

Post by sporefreak »

I found the problem. I forgot to add a data.lua to the core mod so it was never actually loading the groups... Derp.. Thanks for the help though you did save me a lot of trouble on trying to find out how to make mods load in order.
Do you happen to know of anything I could look at to learn how to write mods to change based on other installed mods? (Basically make them allow optional mods instead of not working without the "Config" mod)
I know how to make a dependency optional

User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Using a Core mod to add subgroups

Post by Arch666Angel »

sporefreak wrote:I found the problem. I forgot to add a data.lua to the core mod so it was never actually loading the groups... Derp.. Thanks for the help though you did save me a lot of trouble on trying to find out how to make mods load in order.
Do you happen to know of anything I could look at to learn how to write mods to change based on other installed mods? (Basically make them allow optional mods instead of not working without the "Config" mod)
I know how to make a dependency optional
You could look at bobmods, but he used it very extensively and its hard to learn from it if you have no clue what you are looking at. Basically it's is simple coding, with using if...then logic:

You add the dependency for the other mod (mod "a") to your mod and then find something mod "a" does add to the game that can be found in the data.raw tables. (Bobmods for example create empty tables to indentify themselves with other mod.) And then you put that into the if...then loop:

Example
In the uranium power mod there is an ore that is unique to this mod and which gets created in the data.lua stage: Uraninite

Code: Select all

if data.raw.item["uraninite"]then
put whatever you want to load or change in here
end
So you check for the existence of the item with the name Uraninite, if its there then everything between the "then" and "end" will be executed, if not nothing will happen.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Using a Core mod to add subgroups

Post by bobingabout »

Also a note on that, there are 2 options for checking if something exists in a previous mod or not.

option 1. Make is an optional dependency:
"dependencies": ["base >= 0.12.0", "? bobslibrary"]
This line of dependancies would basically say "If the library exists, load it first", the ? on the front denotes optional.

However, adding this for every mod gets messy, and in the case of some of my mods, they might also want to look at stuff you add, you can't have a mod that depends on another mod, if that other mod depends on yours.

Option 2. Do it in the data-updates phase.
Assuming the mod you're checking adds everything relevant in the data phase, it doesn't matter which one loads first, the content from both your mod and theirs will exist by the time your data-updates.lua loads. so do all those if then checks in data-updates.

I think arch666angel covered everything else relevant.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Re: Using a Core mod to add subgroups

Post by sporefreak »

bobingabout wrote:Also a note on that, there are 2 options for checking if something exists in a previous mod or not.

option 1. Make is an optional dependency:
"dependencies": ["base >= 0.12.0", "? bobslibrary"]
This line of dependancies would basically say "If the library exists, load it first", the ? on the front denotes optional.

However, adding this for every mod gets messy, and in the case of some of my mods, they might also want to look at stuff you add, you can't have a mod that depends on another mod, if that other mod depends on yours.

Option 2. Do it in the data-updates phase.
Assuming the mod you're checking adds everything relevant in the data phase, it doesn't matter which one loads first, the content from both your mod and theirs will exist by the time your data-updates.lua loads. so do all those if then checks in data-updates.

I think arch666angel covered everything else relevant.
Thanks a ton, you both helped a lot.
But now i encountered another problem. I'm trying to make a mod that organizes the crafting inventory without changing the other mods files at all.


Currently i have data.lua check to see if the mods exist. then i have data-updates changing. that didnt work so i tried final fixes but that didnt work either, im assuming its the wrong place to call
This stuff
Basically I want my organizing mod to overwrite the side inserters crafting menu locations.
Last edited by sporefreak on Tue Jun 21, 2016 6:42 pm, edited 2 times in total.

User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Using a Core mod to add subgroups

Post by Arch666Angel »

There are two separate menus: The one you open with "e" only contains recipes, so you have to change the order/groups of the recipes. And then there is the item menu which can be opened with a middlemouse click on your toolbar. But these are two separate things. Order and subgroup for the item and the corresponding recipe can be different from each other, they are set independently.

User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Re: Using a Core mod to add subgroups

Post by sporefreak »

Neither are organized how i want them to be. i think they are getting overwritten by the mods default order, it works fine for the fishing pole mod.
I do know that the mod calls the same commands i am in the item.lua

User avatar
Arch666Angel
Smart Inserter
Smart Inserter
Posts: 1636
Joined: Sun Oct 18, 2015 11:52 am
Contact:

Re: Using a Core mod to add subgroups

Post by Arch666Angel »

sporefreak wrote:Neither are organized how i want them to be. i think they are getting overwritten by the mods default order, it works fine for the fishing pole mod.
I do know that the mod calls the same commands i am in the item.lua
Another issue might be if your item-group has the same order string as another item-group which is in the base game or another mod. This will also break the sorting. But with the changes you made it should display each item in a new row.

edit: btw there is an error in the code you posted, there is an "end" instead of a "data" in the second last row

User avatar
sporefreak
Fast Inserter
Fast Inserter
Posts: 181
Joined: Sun Apr 17, 2016 12:55 am
Contact:

Re: Using a Core mod to add subgroups

Post by sporefreak »

Arch666Angel wrote:
sporefreak wrote:Neither are organized how i want them to be. i think they are getting overwritten by the mods default order, it works fine for the fishing pole mod.
I do know that the mod calls the same commands i am in the item.lua
Another issue might be if your item-group has the same order string as another item-group which is in the base game or another mod. This will also break the sorting. But with the changes you made it should display each item in a new row.

edit: btw there is an error in the code you posted, there is an "end" instead of a "data" in the second last row
Order string? they are all in a new tab,
Thats actually a copy/paste error i misplaced the curser, its not there in the code.

Post Reply

Return to “Modding help”