Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - bitbyte1

#1
Help / How to modify def in game
August 20, 2021, 06:45:21 AM
I have this FactionDef which I would like to edit ingame. I have created a settings menu with HugsLib with a simple bool toggle, and if it's checked, the FactionDef's techLevel should be set to spacer, else industrial. The current defauls is industrial, and this is how I've tried to solve it:

This is my factiondef

<Defs>
    <FactionDef ParentName="PlayerFactionBase">
        <defName>EarlySpacerColonists</defName>
        <label>Early Spacer Colonists</label>
        <description>A colony of recently-arrived spacer colonists.</description>
        <isPlayer>true</isPlayer>
        <techLevel>Industrial</techLevel>
        <!-- And a bunch of other settings -->
    </FactionDef>
</Defs>


And this is my HugsLib C# settings menu:


        private SettingHandle<bool> shouldHaveSpacerTechLevel;

        public override void DefsLoaded()
        {
            if (ModIsActive)
            {
                shouldHaveSpacerTechLevel = Settings.GetHandle(
                    "shouldHaveSpacerTechLevel",
                    "shouldHaveSpacerTechLevel_title".Translate(),
                    "shouldHaveSpacerTechLevel_desc".Translate(),
                    false
                );
                ApplySettings();
            }
        }

        public override void SettingsChanged()
        {
            ApplySettings();
            base.SettingsChanged();
        }

        public void ApplySettings()
        {
            if (shouldHaveSpacerTechLevel)
            {
                DefDatabase<FactionDef>.GetNamed("EarlySpacerColonists").techLevel = TechLevel.Spacer;
                Logger.Message("Set the default techlevel to Spacer");
            }
            else
            {
                DefDatabase<FactionDef>.GetNamed("EarlySpacerColonists").techLevel = TechLevel.Industrial;
                Logger.Message("Set the default techlevel to Industrial");
            }
        }


This is my first mod, so it's probably something obvious. But this sometimes work, and sometimes it doesn't. What have I done wrong?

Edit: nvm I think it's working, but my tech level isn't modifying my research speed?
#2
1. What the circumstances were.
Made an ideology with blind people in a mountainous region

2. What happened.
Started mining and the miner complained about being in the dark, even though he is blind.

3. What you expected to happen.
I expected the miner to not get a mood penalty for the dark.

4. Steps we can follow to make the bug appear on our machine.
Start a colony with a blind colonist, and put him in a dark room. He will complain about the dark.

5 and 6
I feel like a savegame and a log isn't required since this isn't a bug but just a stupid thing that needs to be fixed.