Ludeon Forums

Ludeon Forums

  • December 05, 2022, 09:25:26 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How do I check if a mod is being used? If it is checkForMod variable is true.  (Read 717 times)

arkyte

  • Muffalo
  • *
  • Posts: 16
  • Refugee
    • View Profile

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?
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1987
  • Refugee
    • View Profile

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.

Logged

arkyte

  • Muffalo
  • *
  • Posts: 16
  • Refugee
    • View Profile

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.
« Last Edit: May 26, 2021, 12:04:33 PM by arkyte »
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1987
  • Refugee
    • View Profile

post your "check directly" code
Logged

arkyte

  • Muffalo
  • *
  • Posts: 16
  • Refugee
    • View Profile

Sorry.

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

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1987
  • Refugee
    • View Profile

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.
Logged