Page 1 of 1

scripts not loading from .dfmod after updating mod code

Posted: Wed Mar 11, 2020 4:43 am
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

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

Posted: Wed Mar 11, 2020 7:17 am
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.

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

Posted: Wed Mar 11, 2020 9:26 am
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.

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

Posted: Wed Mar 11, 2020 3:53 pm
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.

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

Posted: Wed Mar 11, 2020 5:28 pm
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?

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

Posted: Wed Mar 11, 2020 7:38 pm
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).

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

Posted: Wed Mar 11, 2020 7:56 pm
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.

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

Posted: Wed Mar 11, 2020 8:08 pm
by numidium3rd
Thanks! :D

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

Posted: Wed Mar 11, 2020 8:47 pm
by Hazelnut
Right done that now, please check you have access to everything you need.

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

Posted: Thu Mar 12, 2020 12:37 am
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. :?