Best way to hide core game objects/items?

Started by FauxGrim, August 23, 2017, 08:11:37 AM

Previous topic - Next topic

FauxGrim

I'm trying to get into modding for the first time and wanted to rework a lot some of the basic items in the game like the default beds, default sleeping spots, default campfire +++.

In doing so I'm making new items within my mod but I would like to hide the default items so they are not visible / available to use from the get go (as they are today in the base game).

I managed to 'hide' them by creating a new empty def within my mod using the same <defName>, ParentName and <label> as the old default items and this successfully hides them from the game without critical Errors. However, the log reports the following errors: "Config error in Bed: Bed has null thingClass."

While I suspect I can solve some of it by adding a thingClass to the new empty def(at work, haven't tried yet), I am curious if there isn't a much better/proper way to disable/hide those items that I am overlooking?

Any help would be appreciated, thanks!

kaptain_kavern

If you want to hide some items while replacing some others, why not "just" named your new items exactly like the vanilla one? So yours overwrites vanilla.

To hide something you could also make that item required a tech that is impossible to research maybe

FauxGrim

Quotewhy not "just" named your new items exactly like the vanilla one?

For the sake of consistency and clarification I would prefer all my new items having names like <MyMod_ItemName> and rather have a separate file containing names and code for the default items that I have hidden. This will keep them separate and allow greater control. That is the idea, anyhow.

If I take an example:
I would like to add more granularity when it comes to beds. I think the following would be confusing:
#pseudocode
<beds>
MyMod_PrimitiveBed -> DefaultBed -> MyMod_SomethingMoreElaborateBed -> RoyalBed
</beds>


and would prefer something like this, if possible:

#pseudocode
<beds>
MyMod_PrimitiveBed -> MyMod_BasicBed -> MyMod_SomethingMoreElaborateBed -> MyMod_VeryElaborateBed
</beds>
<hidden>
DefaultBed
RoyalBed
</hidden>

CannibarRechter

If it were me, given the constraints you describe, I would follow kaptain_kavern's suggestion: I would look ever the tech dependency tree, define a new tech, and then use the patch operation Add command to add that new tech to the core item.  Try it with one of them, see if it works. I think it may.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

FauxGrim

Yes, adding a 'unreachable' tech requirement seems to be the current best solution though there's still the research object visible from the game. I've tested and it works. However I am still interested in any alternative methods if anyone would have more insight on this topic.

skullywag

umm patch it out using the remove operation....look up patching, plenty of info around the forum.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

CannibarRechter

That's totally funny. I mean, I'm using remove myself in other contexts, I just didn't think about it for removing an entire Def. Hmm. Yeah, if that works, that's absolutely the best way (tm).
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

FauxGrim

Quote from: skullywag on August 23, 2017, 05:30:53 PM
umm patch it out using the remove operation....look up patching, plenty of info around the forum.

It works and is probably the best way to do it when it comes to compatibility and future-proofing the mod itself, but it's not a completely clean solution. In this example I tried Patch-removing the default Bed and SleepingSpot:



While they are now successfully removed from the game, I'm getting the following errors:



I am not yet experienced enough to know if these errors are something that is going to come back and haunt me or something the game can live with. Will continue developing and see how it goes.

jamaicancastle

The InstructionDef those errors are referring to is one of the tutorial instructions that plays, well, during the tutorial. It should be a harmless error if you're not playing the tutorial (although it might or might not be serious if you are), but if you want to get rid of it, find the InstructionDef in Defs/Tutor/Instructions.xml and either remove that instruction entirely, or change the ThingDef entry to refer to your bed replacement.

Ykara

Hello!
Sorry for necroing the thread, but I wondered if there is really no other option to hide a research project without removing it and thus getting red errors?

LWM

You can also search for all <li> elements whose text is the research's defName

Xpath should look something like <xpath>li[text()='defNameOfReserach']</xpath>

I think that's the only way research defs appear in the xml?

Then brutally nuke the InstructionDefs - they should be easier, you can see exactly what they are and no one else is likely to make them.