[SOLVED] Research requirement for a RECIPE

Started by Noobshock, October 21, 2014, 07:48:13 AM

Previous topic - Next topic

Noobshock

I would like to have a specific recipe (not a workbench) that unlocks with a certain tech

Can that be done atm? It's obvious enough how to make buildings dependent on research, but not recipes.

JuliaEllie

#1
Its fairly easy.

<researchMods>
<li>
<specialAction>[Namespace.Class.Method]</specialAction>
</li>
</researchMods>

calls the method once the research project is complete. Your method only has to add the recipe to the worktable you want it to be.

Noobshock

So that requires a dll mod then. mmmmmmmkay.

Rikiki

I have workbenches with custom class to add the recipe dynamically in Mining & Co. mods (electronic, mining and security workbenches).

However, this solution seems quite elegant. I will try it for next release.

Noobshock

#4
Quote from: JuliaEllie on October 21, 2014, 07:55:18 AM
Your method only has to add the recipe to the worktable you want it to be.

I'm clueless when it comes to DLL mods (only have very partial remnants of distant C classes) and the best I can do at this point is look at someone else's work to understand how they got there. Could you point me to any example of a method being used to inject item properties? If not no big deal.

Rikiki

Answer in the previous post ;)
Go check in the Mining & Co. Common mod, there is only one class so you cannot miss it!

Noobshock

#6
Yeah, the thing I don't quite get with your approach is how the "recipe container" works. I guess I'll have to play with the mod and see in game.

Edit: Rikiki, when I try to play your mod the recipes are all available when I build a security workbench, I haven't even researched the laser rifle and they are all available to me. :/

Rikiki

Is it because you have activated the magic "Finish all researches" button? ::)

The recipe container is what its name means: this is a fake workbench that cannot be built but contains all the recipes that I want to add to other workbenches once the required research is complete.

Noobshock

#8
Yeah, I tried to imitate your mod, don't get any errors, but finishing the research doesn't add the recipes -_-. Not sure what I'm doing wrong.

Oh and yours works fine, not sure why it didn't the first time I tried it, maybe conflict with other mods.

It's basically a carbon copy of what you're doing except instead of adding 1 recipe for each research, there's one research that should unlock 4 recipes at once.

Edit: nevermind I keep finding little mistakes here and there, just gonna hammer at it a bit I'm sure I'll get it to work eventually.

Minus

Quote from: JuliaEllie on October 21, 2014, 07:55:18 AM
Its fairly easy.

<researchMods>
<li>
<specialAction>[Namespace.Class.Method]</specialAction>
</li>
</researchMods>

calls the method once the research project is complete. Your method only has to add the recipe to the worktable you want it to be.
This isn't that helpful as you've not said where this coding is meant to go. The bits you want me to fill in also leave me clueless. Do you have an example of this? I'm trying to make a piece of research to enable brain surgery. As it's only a single simple thing, I'd prefer to use this thing over a fake workbench, but can't yet figure it out.

Our cybernetic hearts mean we care more!
Mods: Extended Surgery and Bionics, Brain Surgery, Medical XP Balance

JuliaEllie

Ok Im sorry for any confusion I might have caused. The <researchMods> part goes into your ResearchProjectDef and your method might want to look something like this:

public static void Method()
{
DefDatabase<ThingDef>.getNamed("YourWorkbench").recipes.Add(DefDatabase<RecipeDef>.getNamed("YourRecipe"));
}

Thats the whole magic :)


Noobshock

Wow, I was struggling to get Rikiki's recipe container to work right (gotta admit it was a creative idea though), this worked instantly. Thanks very much.

Rikiki

Yep, I will change my mods to use it instead. This is so much easier :)
I struggled with it yesterday without the example. I think I just forgot the "static" keyword... >:(

Minus

Still utterly confused. But more importantly, I have no idea what to add to the workbench bit. I don't HAVE a workbench for this recipe. It's simply something a colonist can do, installing a brain.

Our cybernetic hearts mean we care more!
Mods: Extended Surgery and Bionics, Brain Surgery, Medical XP Balance

Rikiki

I think you must add the medical recipe to Pawn.def.recipes.
I don't know exactly how... I did not played with pawns for now. :(