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

Re: Mods not working in 0.10.24 builds

Post by Ralzar »

Interkarma wrote: Tue Jul 07, 2020 11:45 am It's getting late here. Will pick up again when I can tomorrow after work. :)
Cool. And thanks a lot man. Even if this turns out to be my own inexperience (which is very, very likely) it's great to at least have the moral support :D

User avatar
jefetienne
Posts: 170
Joined: Thu Jan 16, 2020 8:14 pm
Location: Gallomont, Wayrest
Contact:

Re: Mods not working in 0.10.24 builds

Post by jefetienne »

I know this may sound like a lot of work, but if you want to test at which point your mods stop working, you can git checkout any commit in the master's commit history.

For example, this commit is right before my mod conflict feature.

If you have git installed via terminal/command line, you can simply say

Code: Select all

git checkout e5132e42e6a6f59ad69f5282b20d5d2059540892
and it will load up the project at that time. You can find the commit hash in the URL or on the page, and you can go back by saying "git checkout master".

It may also be helpful to periodically check the status of the project with two branches - one that is the stable 0.10.24 to work mods off of, and the other is the "nightly" master branch on GitHub. Definitely beneficial for both modders and developers so any incompatibilities can be detected and squashed right before release.
El jefe, Etienne
Nexus Mods | GitHub

User avatar
jefetienne
Posts: 170
Joined: Thu Jan 16, 2020 8:14 pm
Location: Gallomont, Wayrest
Contact:

Re: Mods not working in 0.10.24 builds

Post by jefetienne »

Anecdote: I had to do exactly this recently when I found out a different PR broke closing the Automap and Status menus when it was bound to a joystick axis button :)
El jefe, Etienne
Nexus Mods | GitHub

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 »

Ok, I've been doing some testing back and forth to try to nail down what's happening here, but there's not a lot of info to go on. Since I get no error messages to indicate what is happening here.

It all to some degree boils down to when I use Invoke.

[Invoke(StateManager.StateTypes.Start, 0)]
Editor: OK
Live 0.10.24: Mod not running.
Live 0.10.23: OK
This is what I was using until the mod stopped working in 0.10.24

[Invoke(StateManager.StateTypes.Game, 0)]
Editor: No error. Food does not work after RestoreSaveData.
Live 0.10.24: Mod runs. Food does not work after RestoreSaveData
Live 0.10.23: Mod runs. Food does not work after RestoreSaveData

And it's not really just the food items. They're just the easiest to test. The same happens with clickable sprites. In any version where food items have problems, these do not work either:
PlayerActivate.RegisterCustomActivation(mod, 101, 0, Camping.RestOrPackFire);

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 »

I realize now that I might have been going at this from the wrong angle.

Instead trying to find some way to use

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

without a bunch of bugs popping up.


What I should be doing is starting out with

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

This is what mods usually use to register the mod.
Which works flawlessly in all scenarios except in 0.10.14 where it suddenly does not run in Live at all.
Question is, why does the mod not run?

Is there some way for me to check this in live? In editor it's all ok.

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 »

Ralzar wrote: Tue Jul 07, 2020 10:28 pm This is what mods usually use to register the mod.
Which works flawlessly in all scenarios except in 0.10.14 where it suddenly does not run in Live at all.
Question is, why does the mod not run?
I'll start here as well when I resume later. I don't know why this wouldn't work in 0.10.24. The StateManager class itself hasn't received any code changes since 2016, so must be something else in the mix.

Just to confirm, does the built version on Nexus use StateTypes.Game or StateTypes.Start? Keep in mind I also experienced the food saving issue in May's 0.10.23 build and the current Nexus version of C&C.

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'm still not sure what the difference here could be. I put together a test mod that doesn't use custom activations or custom items, but does add a custom spell effect. I'm using the following pattern in my bootstrap behaviour.

Code: Select all

using UnityEngine;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop;

namespace MyMod
{
    public class MyMod : MonoBehaviour
    {
        static Mod mod;

        [Invoke(StateManager.StateTypes.Start, 0)]
        public static void Init(InitParams initParams)
        {
            mod = initParams.Mod;
            var go = new GameObject(mod.Title);
            go.AddComponent<MyMod>();

            DaggerfallUnity.LogMessage("MyMod Init()", true);
        }

        private void Awake()
        {
            // Do required stuff on Awake

            DaggerfallUnity.LogMessage("MyMod Awake()", true);
        }
    }
}
Everything works fine in both 0.10.23 and 0.10.24 editor and builds.

I'll work in some custom activations and see if I can break it in a way similar to what you're experiencing.

Edit: Added some custom activations (to play a sound when clicking torches) and still working OK in 0.10.23/24 editor and builds. I'll keep adding more complex behaviours to it.

Code: Select all

using UnityEngine;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop;

namespace MyMod
{
    public class MyMod : MonoBehaviour
    {
        static Mod mod;

        [Invoke(StateManager.StateTypes.Start, 0)]
        public static void Init(InitParams initParams)
        {
            mod = initParams.Mod;
            var go = new GameObject(mod.Title);
            go.AddComponent<MyMod>();

            DaggerfallUnity.LogMessage("MyMod Init()", true);

            PlayerActivate.RegisterCustomActivation(mod, 210, 16, TorchSound);
            PlayerActivate.RegisterCustomActivation(mod, 210, 17, TorchSound);
            PlayerActivate.RegisterCustomActivation(mod, 210, 18, TorchSound);
        }

        private void Awake()
        {
            // Do required stuff on Awake

            DaggerfallUnity.LogMessage("MyMod Awake()", true);
        }

        private static void TorchSound(RaycastHit hit)
        {
            DaggerfallUI.Instance.PlayOneShot(SoundClips.ActivateGears);
        }
    }
}

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: Tue Jul 07, 2020 11:02 pm Just to confirm, does the built version on Nexus use StateTypes.Game or StateTypes.Start? Keep in mind I also experienced the food saving issue in May's 0.10.23 build and the current Nexus version of C&C.
The version out on Nexus and on my github is StateType.Game.

This is because up until 0.10.24 I had been using StateType.Start, but when I switched to 0.10.24, the mod did not run at all in Live. So I tried out changing this to StateType.Game and the mod then worked.

Then it took a bit of time to discover that despite no errors in editor, the loading of savegames was breaking food items and campfire resting.

Now, the food items, it's possible to see why has stopped working, since the className is blank instead of referring to my mods data.
However, the clicking on fireplaces? That should not be saving anything should it?


The problem I also have testing here, is that if I set the mod to use StateType.Start, the mod simply doesn't run. So it's impossible to say if both food and campfire activation gets broken by switching to StateType.Game, or if they're broken in both scenarios, but using StateType.Game lets you at least see that they're not working.

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 »

What are your thoughts on my sample mod above that uses StateType.Start, with custom activations, and works in 0.10.23/24 both editor and builds?

At this time, I haven't reproduced what you're experiencing with StateType.Start. Perhaps you could work on a bare minimum repro mod for me that triggers the problem on your end?

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: Wed Jul 08, 2020 6:07 am What are your thoughts on my sample mod above that uses StateType.Start, with custom activations, and works in 0.10.23/24 both editor and builds?

At this time, I haven't reproduced what you're experiencing with StateType.Start. Perhaps you could work on a bare minimum repro mod for me that triggers the problem on your end?
I was thinking of trying to build a mod from scratch as well to try to isolate just when the bug appears.

I'll take a look at your code in a bit, after I've done some "official" work that puts food on the table :D


I suspect the problem appears here:

[Invoke(StateManager.StateTypes.Start, 0)]
public static void Init(InitParams initParams)
{
mod = initParams.Mod;
var go = new GameObject(mod.Title);
go.AddComponent<ClimateCalories>();
instance = go.AddComponent<ClimateCalories>();
mod.SaveDataInterface = instance;

Since nothing of the mod runs in live, I'm thinking something just crashes in the Init method. Becuase the mod does so many different things that it has to be failing at some crucial point for nothing to run.

Post Reply