Mods not working in 0.10.24 builds

Discuss modding questions and implementation details.
Post Reply
User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Mods not working in 0.10.24 builds

Post by Ralzar »

Interkarma wrote: Sun Jul 05, 2020 8:31 am Good luck Ralzar! Don't hesitate to reach out if any help needed.
Thanks. I think I'm a bit out of my depth here. Now, I would never ask anyone to look at my Climates & Calories code because that's a deformed monster waiting for me to write the whole thing over again.

Races Redone though, is a pretty straightforward mod so is Torch Taker.

Torch Taker works except this bit:

Code: Select all

                PlayerEnterExit.OnTransitionDungeonInterior += RemoveVanillaLightSources;
                PlayerEnterExit.OnTransitionDungeonInterior += AddVanillaLightToLightSources;
https://github.com/Ralzar81/Torch-Taker ... ker.cs#L95

It either does not get registered or the methods do not manage to execute correctly. The code is intended to strip out the vanilla torch lights, then find all torches and attach a similar light object to the torches. So when you take a torch, the light is also removed.

But this no longer happens. If you enter a dungeon, the vanilla lights are not removed and new lights are not attached to the torches. Which becomes obvious when you attempt to take a torch and the torch light stays there without the torch sprite.



Edit: Removed the Races Redone example. It appear to still be working. I think I got a bit stressed and tested the wrong attribute.

User avatar
Interkarma
Posts: 7247
Joined: Sun Mar 22, 2015 1:51 am

Re: Daggerfall Unity 0.10.24

Post by Interkarma »

Does TorchTaker also work in editor but not in a build? Or does it just not seem to work at all?

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Daggerfall Unity 0.10.24

Post by Ralzar »

Interkarma wrote: Sun Jul 05, 2020 9:23 am Does TorchTaker also work in editor but not in a build? Or does it just not seem to work at all?
It works exactly as before in editor. It's only in live there's a difference.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Daggerfall Unity 0.10.24

Post by Ralzar »

Ok, I added

DaggerfallUI.AddHUDText("RemoveVanillaLightSources");

and

DaggerfallUI.AddHUDText("AddVanillaLightToLightSources");

to the two methods so I could be sure if the methods ran at all or not.

I built the mod and ran it in live: the text pops up. Which means the methods are being run, but the actual gameObject manipulation is failing.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Daggerfall Unity 0.10.24

Post by Ralzar »

Added a counter to RemoveVanillaLightSources.

In both editor and live this returns 310 lights sources removed. However, in live the light sources are apparently still there.

Code: Select all

static int lightNumbers = 0;

        private static void RemoveVanillaLightSources(PlayerEnterExit.TransitionEventArgs args)
        {
            DungeonLightHandler[] dfLights = (DungeonLightHandler[])FindObjectsOfType(typeof(DungeonLightHandler)); //Get all dungeon lights in the scene
            for (int i = 0; i < dfLights.Length; i++)
            {
                if (dfLights[i].gameObject.name == "DaggerfallLight [Dungeon]")
                    Destroy(dfLights[i].gameObject);
                lightNumbers++;
            }
            DaggerfallUI.AddHUDText("RemovedLightSSourch lightNumbers = " + lightNumbers.ToString());
        }

User avatar
Interkarma
Posts: 7247
Joined: Sun Mar 22, 2015 1:51 am

Re: Mods not working in 0.10.24 builds

Post by Interkarma »

I note that you're registering two different tasks to the same delegate event.

Code: Select all

PlayerEnterExit.OnTransitionDungeonInterior += RemoveVanillaLightSources;
PlayerEnterExit.OnTransitionDungeonInterior += AddVanillaLightToLightSources;
Will these always run in the order they're registered in, or is it possible for one to be executed before the other and not have the intended outcome? What happens if AddVanillaLightToLightSources() call is triggered before RemoveVanillaLightSources()?

If these are only intended to execute when transitioning into a dungeon, I'd collapse them into a single event.

Something I'd note is that Destroy() doesn't happen right away and can be problematic with nested objects. Maybe just try disabling the unwanted light object component rather than destroying whole game object.

Let me know how you go. :)

Edit: BTW, I'll split this into its own topic so discussion does not derail news topic.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Mods not working in 0.10.24 builds

Post by Ralzar »

Interkarma wrote: Sun Jul 05, 2020 9:44 am Edit: BTW, I'll split this into its own topic so discussion does not derail this one.
Good idea :D


Thing is, that lighting code was taken from Improved Interior Lighting mod. And that mod still works in live. Even though the code is pretty much identical to mine.
I'm currently comparing them to figure out what could make the difference.

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Mods not working in 0.10.24 builds

Post by Ralzar »

BINGO!


I do:

Code: Select all

[Invoke(StateManager.StateTypes.Start, 0)]

IIL mod does:

Code: Select all

[Invoke(StateManager.StateTypes.Game, 0)]

User avatar
Interkarma
Posts: 7247
Joined: Sun Mar 22, 2015 1:51 am

Re: Mods not working in 0.10.24 builds

Post by Interkarma »

Fixed? Well done! :D

Sorry I wasn't much help. Sometimes it's good just to bounce stuff around with someone else at least. :)

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: Mods not working in 0.10.24 builds

Post by Ralzar »

Dammit. It did not completely solve it. It works if you have Interior Lighting Mod. Because then that mod does the code my mod for some reason can't manage to do now.

Improved Imperior Lighting does this:

Code: Select all

        private void RemoveVanillaLightSources(PlayerEnterExit.TransitionEventArgs args) 
        {
            DungeonLightHandler[] dfLights = (DungeonLightHandler[])FindObjectsOfType(typeof(DungeonLightHandler)); //Get all dungeon lights in the scene
            for (int i = 0; i < dfLights.Length; i++)
            {
                Destroy(dfLights[i].gameObject);
            }
        }

Torch Taker does this:

Code: Select all

        private static void RemoveVanillaLightSources(PlayerEnterExit.TransitionEventArgs args)
        {
            DungeonLightHandler[] dfLights = (DungeonLightHandler[])FindObjectsOfType(typeof(DungeonLightHandler)); //Get all dungeon lights in the scene
            for (int i = 0; i < dfLights.Length; i++)
            {
                if (dfLights[i].gameObject.name == "DaggerfallLight [Dungeon]")
                    Destroy(dfLights[i].gameObject);
            }
        }

Now, the only difference in the method is "if (dfLights.gameObject.name == "DaggerfallLight [Dungeon]")" so this might be causing the problem.

Post Reply