scripts not loading from .dfmod after updating mod code

Discuss modding questions and implementation details.
Post Reply
User avatar
numidium3rd
Posts: 187
Joined: Sun Mar 25, 2018 12:34 am
Location: United States

scripts not loading from .dfmod after updating mod code

Post by numidium3rd »

I've been working on an inventory menu mod that I've previously uploaded on to the forums. The .dfmod package was working just fine before but my latest changes are preventing the scripts from loading. I added a few new things including overrides of methods that weren't possible before I submitted this PR. I'm at a loss as to why the scripts aren't loading from the .dfmod because everything works in debug mode with my master branch synced to the latest commit.

I'm testing the .dfmod with the Alpha 0.10.21 64-bit Windows build. My texture assets load but not the scripts. Could there be a quirk to the modding system causing this or did I do something wrong (most likely)?

This is the code for my mod:
https://github.com/numidium/dfu-modernm ... ModernMenu

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

Re: scripts not loading from .dfmod after updating mod code

Post by Ralzar »

I had something similar going on with Meaner Monsters where after being compiled into a .dfmod file the script did nothing.

Hazelnut investigated and came back saying "you cannot use object initialisation with a struct using mcs compiler". Not sure if that is related to what you are having probems with, but it shows that what the mod scripts can handle in editor does not 100% match what it can compile into a dfmod file.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: scripts not loading from .dfmod after updating mod code

Post by Hazelnut »

It's likely an MCS compiler issue, you're already aware of this as you have swapped enums for int constants. It also doesn't like generics or struct initialisers. What message do you see in console when you run?

Also, I hope the copied code from ForumulaHelper is only temporary.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
numidium3rd
Posts: 187
Joined: Sun Mar 25, 2018 12:34 am
Location: United States

Re: scripts not loading from .dfmod after updating mod code

Post by numidium3rd »

Ralzar wrote: Wed Mar 11, 2020 7:17 am Hazelnut investigated and came back saying "you cannot use object initialisation with a struct using mcs compiler".
This might be the problem. Thanks, I'll check into that.
Hazelnut wrote: Wed Mar 11, 2020 9:26 am What message do you see in console when you run?
The console is blank for me on startup.
Hazelnut wrote: Wed Mar 11, 2020 9:26 am Also, I hope the copied code from ForumulaHelper is only temporary.
The code determining attack/damage rating is currently coupled with the code for making attack rolls. That's why I used the snippets to get the formulas. I agree that getting the values strictly by making calls to FormulaHelper methods would be preferable if that's what you're getting at. I'll make a PR for that in the near future.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: scripts not loading from .dfmod after updating mod code

Post by Hazelnut »

You may want to hold off as I already have a PR submitted refactoring the combat formula. Although the sub-formula are marked private so mods can override either parts or the whole thing, but not both. That may cause you issues - maybe you could take a look?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
numidium3rd
Posts: 187
Joined: Sun Mar 25, 2018 12:34 am
Location: United States

Re: scripts not loading from .dfmod after updating mod code

Post by numidium3rd »

Hmm, yes I'm afraid the methods being private will prevent me from being able to use them. I don't need to override, just need to get the values so I can display an overall attack rating and min/max damage when players equip a weapon. I hate to throw a wrench in your PR but being able to access those calculations from other classes would be useful (in my case, at least).

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: scripts not loading from .dfmod after updating mod code

Post by Hazelnut »

Okay, I cannot think of a way round it so i will make them public then. Should mean your windows will adjust depending on how the formula are modded.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
numidium3rd
Posts: 187
Joined: Sun Mar 25, 2018 12:34 am
Location: United States

Re: scripts not loading from .dfmod after updating mod code

Post by numidium3rd »

Thanks! :D

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: scripts not loading from .dfmod after updating mod code

Post by Hazelnut »

Right done that now, please check you have access to everything you need.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
numidium3rd
Posts: 187
Joined: Sun Mar 25, 2018 12:34 am
Location: United States

Re: scripts not loading from .dfmod after updating mod code

Post by numidium3rd »

Hazelnut wrote: Wed Mar 11, 2020 8:47 pm Right done that now, please check you have access to everything you need.
Your PR Looks good to me.

Also... It took me a couple of hours but I figured out why my scripts aren't loading! It was a single line of code where I was instantiating a MultiFormatTextLabel. I was attempting to set the Position but the setter for that is internal. Therefore, it is protected from my attempts to change it outside of a debugging context. Hopefully future modders can learn from my mistake and not spend an evening tracking down a line of code like I did. :?

Post Reply