How do I check if a mod is being used? If it is checkForMod variable is true.

Started by arkyte, May 25, 2021, 12:35:29 PM

Previous topic - Next topic

arkyte

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?

RawCode

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.


arkyte

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.

RawCode


arkyte

Sorry.

if (pawn.RaceProps.Humanlike && !pawn.health.hediffSet.HasHediff(Celestials.CelestialsDefOf.O21_CelestialHediff))
{
     float startGrayingHair = pawn.RaceProps.lifeExpectancy / 2;
}

RawCode

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.