Ludeon Forums

RimWorld => Mods => Help => Topic started by: sefin_88 on August 07, 2016, 05:39:16 AM

Title: Recipe available only after research
Post by: sefin_88 on August 07, 2016, 05:39:16 AM
If I wanted to make a repair recipe available only after the required research was done for the item.  Where would I put the script?

<researchPrerequisite>RESEARCHnameHERE</researchPrerequisite>

does it matter where this line goes or does it have to be in a certain place in the recipe def?
Title: Re: Recipe available only after research
Post by: sefin_88 on August 07, 2016, 06:05:57 AM
I worked it out.  I put the above line in the script after this line:
<soundWorking>Recipe_Machining</soundWorking>

and everthing works perfectly now.
Title: Re: Recipe available only after research
Post by: 1000101 on August 07, 2016, 06:16:36 AM
It doesn't matter where in an xml block a tag is as per the xml standard.
Title: Re: Recipe available only after research
Post by: sefin_88 on August 07, 2016, 07:16:59 AM
Quote from: 1000101 on August 07, 2016, 06:16:36 AM
It doesn't matter where in an xml block a tag is as per the xml standard.

Cool thanks for that.  I don't know much about scripting and such but I'm a quick learner.  Everything I know about xml stuff I have literally learned from here and modding other games within the past year.
Title: Re: Recipe available only after research
Post by: 1000101 on August 07, 2016, 02:35:15 PM
Generally it's best to keep the tags in the same order they appear in the C# class they represent.  However, there is no requirement that they do so.  Sometimes however, related C# fields aren't adjacent in the C# class, in this case it's perfectly fine to move the xml tags around so they are together and make sense.

That being said, there are caveats with lists.  ThingComps can be very strict about the order they appear in.  CCL's CompPowerLowIdleDraw must be after the cores CompPowerTrader, for example.
Title: Re: Recipe available only after research
Post by: Master Bucketsmith on August 12, 2016, 05:23:20 AM
I can't find any other topic or source that addresses this question.
I've got a shell that I make at the machining table, for a custom mortar.
I want the recipe/bill for making the shell to have requirements in research.

If I add:
<researchPrerequisites>
<li>Machining</li>
<li>Firefoam</li>
</researchPrerequisites>

To the Recipes_Production.xml file, I get an error in the debug window when booting up RimWorld.
If I add it to the Items_Resource_Manufactured.xml file, it does nothing.

To which file do I add those lines?
Title: Re: Recipe available only after research
Post by: kaptain_kavern on August 12, 2016, 05:44:56 AM
I've a research and in Core the tag you talking about is only used on buildings item. But read the doc in CCL thread, I'm pretty sure their modified research system will have what you want
Title: Re: Recipe available only after research
Post by: Master Bucketsmith on August 12, 2016, 06:04:37 AM
Quote from: kaptain_kavern on August 12, 2016, 05:44:56 AM
I've a research and in Core the tag you talking about is only used on buildings item. But read the doc in CCL thread, I'm pretty sure their modified research system will have what you want
I just did that. I've tried adding the AdvancedResearchDef folder with file and code like this:
<?xml version="1.0" encoding="utf-8" ?>
<Defs>

    <CommunityCoreLibrary.AdvancedResearchDef>

        <defName>MakeFoamShellsMachiningTable</defName>
        <Priority>0</Priority>

        <researchDefs>
            <li>Machining</li>
<li>Firefoam</li>
        </researchDefs>

        <recipeDefs>
            <li>MakeFoamShell</li>
        </recipeDefs>

        <thingDefs>
            <li>TableMachining</li>
        </thingDefs>

    </CommunityCoreLibrary.AdvancedResearchDef>

</Defs>

But upon booting RimWorld, it errors that it requires ModHelperDef.
If I look into that folder and file, I see nothing that is connected to AdvancedResearch or the artillery shell tweak in their Vanilla Tweaks mod.

Never you mind, I managed to work it out. Made all the needed files and folder structure and it's all working now! :)
Thank you!