Question about mod loading

Started by Nirahiel, January 16, 2015, 06:42:35 AM

Previous topic - Next topic

Nirahiel

Hi.
I'd like to know if there is a way to create a DLL mod that's always loaded, no matter what.
Like, it doesn't even have to appear in the mod list, as it should always be there, much like a core mod.
If you want a concrete example, think minecraft forge. I'm currently implementing something similar, but I have several design choices to make.
Currently, my mod does a few things.
It allows modders to register a "main" class for their mod, that is automagically instantiated when the game loads, using a special attribute system.

[Mod("My super mod")]
public class MySuperMod
{
    ...
}

I developed this because (one of the reason was that) I needed to be able to add recipes to vanilla production buildings like the Machining Table for example.
My custom code (the one from the forge like mod) is loaded only if the mod is enabled in the config.
When it's loaded, it can register all classes using this attribute whenever they are loaded as well, even if the player then disables the other mods (the ones using my tool) the classes stays registered (but I mark them as disabled in my code).
The problem is, what if a player enables my tool, and another mod using it, my tool loads, the other mod as well, my tool then register the other mod's custom recipes, and then the player disables my tool only.

Hoping to get an answer from Tynan directly regarding this, but I started a new thread instead of sending him a PM just to let everyone say something about this :)

Haplo

Just to let you know:
You can add Recipes to tables by adding this to the recipe:

<recipeUsers>
<li>TableMachining</li>
</recipeUsers>


Nirahiel

Seriously ? Instead of specifying the recipe in the machine you specify the machine in the recipe ? :o

Haplo

Yes, that's one of the changes of alpha 8 :)

Rikiki

And if you want do add your recipe dynamically (when a research is finished for example), look into the M&Co. Weapons mod source.

Nirahiel

Well the whole point of my mod was to add recipes dynamically.
But thanks to Haplo i got an easier way to do it.
Now I have another problem, i created a recipe, set it for the cooking bench, the recipe appears in the list, i can even set a new bill. Problem, when i select a pawn and right click it, nothing happens. I can't force it to do the new recipe, and no one will do it themselves ...

mipen

You must also include a workgiver to tell your colonists what to do with the table

Rikiki

Nope, if he added it to the cooking stove, the workgiver already exists.
Make sure the required ingredients are available. ;)

Best way to get it working:

  • copy and rename an existing meal recipe
  • check it works in game
  • proceed to its customisation (ingredients, duration, products, ...)
  • check it still works in game after each modification

Nirahiel

Nah I fixed it, I didn't explicitely allow the items to be used, even though they were in the recipe :)