Ludeon Forums

RimWorld => Mods => Help => Topic started by: arkyte on May 25, 2021, 12:35:29 PM

Title: How do I check if a mod is being used? If it is checkForMod variable is true.
Post by: arkyte on May 25, 2021, 12:35:29 PM
I want to make a check of a DefOf during my code, but only if such DefOf exists. How do I check if such mod is present?
Title: Re: How do I check if a mod is being used? If it is checkForMod variable is true.
Post by: RawCode on May 26, 2021, 05:00:09 AM
defof is not part of database and not present at runtime

you should check for thingdef that will be created after parsing specific defof

also your implementation is just wrong, you do not need to check both mod and def, if mod is not present, it's defs obviously not present and additional check is not required.

Title: Re: How do I check if a mod is being used? If it is checkForMod variable is true.
Post by: arkyte on May 26, 2021, 11:53:08 AM
But how would I check if a defof is present without throwing red errors that it does not exist?

How do I check if Celestials.CelestialsDefOf.O21_CelestialHediff exists?

If I check directly if the pawn has the hediff it throws the error that it does not exist.
Title: Re: How do I check if a mod is being used? If it is checkForMod variable is true.
Post by: RawCode on May 27, 2021, 08:22:34 AM
post your "check directly" code
Title: Re: How do I check if a mod is being used? If it is checkForMod variable is true.
Post by: arkyte on May 27, 2021, 04:46:33 PM
Sorry.

if (pawn.RaceProps.Humanlike && !pawn.health.hediffSet.HasHediff(Celestials.CelestialsDefOf.O21_CelestialHediff))
{
     float startGrayingHair = pawn.RaceProps.lifeExpectancy / 2;
}
Title: Re: How do I check if a mod is being used? If it is checkForMod variable is true.
Post by: RawCode on May 28, 2021, 04:48:31 PM
do you understand that you access static variable from other mod and it may be called ever "godlike script" and this is absolutely unrelated to anything in base game?

open that class and check how variable is initialized and use defname directly, without additional hard references.