Jump to content

config.json file is not created as intended


Recommended Posts

My code is based on the BiggerCappacity mod code, but it seems my code is not generating a config.json file as intended.

Everyone please help me review and see where i went wrong so i can correct it. Thanks!

the mod is in the mods/local because i haven't posted it to the workshop yet.

public virtual void OnLoad(Harmony harmony)
        {
            try
            {
                string settingsDir = Path.Combine(Manager.GetDirectory(), "settings", nameof(CustomGenerator));
                Debug.Log($"[CustomGenerator] Settings directory: {settingsDir}");

                if (!Directory.Exists(settingsDir))
                {
                    Debug.Log("[CustomGenerator] Directory does not exist. Creating...");
                    Directory.CreateDirectory(settingsDir);
                }

                CustomGenerator.GeneratorConfig.filepath = Path.Combine(settingsDir, "config.json");

                Debug.Log($"[CustomGenerator] Config file path: {filepath}");

                Console.WriteLine($"[CustomGenerator] Config file path: {filepath}");

                LoadConfig();
                harmony.PatchAll();
            }
            catch (Exception ex)
            {
                Debug.LogError($"[CustomGenerator] Failed to initialize: {ex.Message}");
            }
        }

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...