how to get reference to thingdef of building in dll?

Started by kahlzun, October 04, 2020, 07:37:07 AM

Previous topic - Next topic

kahlzun

Hi all,

I'm mucking around with expanding the function of this mod from 1.0 (https://ludeon.com/forums/index.php?topic=46378.30), adding a cheaper 'short range' pod to allow for travel within the same map.

Similar to the issue that Sandy reported in the final post, trying to add another pod using the same Classes as the "Building_Helicopter" causes the pod to morph upon launch to the mods original "Building_Helicopter" and land in this new configuration.

I dont have much coding experience (any really) but i can see that J.Bear made several hard-coded references in the dll to ensure that the launched vehicle is always "Building_Helicopter":

          Thing thing = ThingMaker.MakeThing(ThingDef.Named("Building_Helicopter"), (ThingDef) null);

What i want to do is to add a reference where it checks for the thingdef name of the pod being launched and replace this hardcoded reference with a generic reference, allowing more flexibility. As i mentioned, this coding is well outside of my experience (i dont even know where to begin looking, or even if im asking the question wrong) and so any help to find the information needed would be helpful.

For the moment, i am still trying to keep everything 1.0 friendly before complicating anything further.

Thanks much for any help,
Sam
Look for me on the KSP forums!
Rimworld. The game where getting a cannibal psychopath with bloodlust is a good thing.

RawCode

and you will have "generic" name hardcoded after that...

you can't reference thingdef in code without name.

ever if you go "component route" you will need component name instead.