Modding Tutorials

Discuss modding questions and implementation details.
Narf the Mouse
Posts: 839
Joined: Mon Nov 30, 2015 6:32 pm

Re: Modding Tutorials

Post by Narf the Mouse » Sat Nov 09, 2019 2:24 pm

I think I found (part of) the culprit.

The constructors for ModSettings are internal, which means they do not throw an error when you're writing code, but do when the .dfmod gets loaded.

It's not the full culprit because it's not crashing the editor.
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

User avatar
BadLuckBurt
Posts: 557
Joined: Sun Nov 05, 2017 8:30 pm

Re: Modding Tutorials

Post by BadLuckBurt » Sat Nov 09, 2019 2:29 pm

Narf the Mouse wrote:
Sat Nov 09, 2019 1:54 pm
Thanks for all your help. However, I did "git checkout ." to fix it. It really seemed borked, and I decided to just give up. ;)

Edit: I should clarify. I haven't given up on the mod. :)
No worries, sometimes a reset is the best course of action. And that's the spirit, good luck!
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

Narf the Mouse
Posts: 839
Joined: Mon Nov 30, 2015 6:32 pm

Re: Modding Tutorials

Post by Narf the Mouse » Sat Nov 09, 2019 2:30 pm

BadLuckBurt wrote:
Sat Nov 09, 2019 2:29 pm
Narf the Mouse wrote:
Sat Nov 09, 2019 1:54 pm
Thanks for all your help. However, I did "git checkout ." to fix it. It really seemed borked, and I decided to just give up. ;)

Edit: I should clarify. I haven't given up on the mod. :)
No worries, sometimes a reset is the best course of action. And that's the spirit, good luck!
Thanks. It's mostly finished; just needs final polish and an actual settings menu.

Edit: It's mod.GetSettings() now. Also the tutorial needs to be updated. :)
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

IAmTheClayman
Posts: 9
Joined: Fri Dec 07, 2018 7:31 am

Re: Modding Tutorials

Post by IAmTheClayman » Sun Nov 10, 2019 9:01 am

TheLacus wrote:
Sat Nov 09, 2019 1:08 pm
IAmTheClayman wrote:
Fri Nov 08, 2019 12:44 am
How would you go about making changes to an existing script in DFU? For example, right now HUDVitals.cs has the following code:

Code: Select all

public HUDVitals()
            :base()
{
	playerEntity = GameManager.Instance.PlayerEntity;
	LoadAssets();

	BackgroundColor = Color.clear;
	HorizontalAlignment = HorizontalAlignment.Left;
	VerticalAlignment = VerticalAlignment.Bottom;
	SetMargins(Margins.All, borderSize);
	...
I want to, as a test, have the vitals display horizontally centered. Would the way to do this as a distributable mod be to make the edits directly to HUDVitals.cs and include it in the list under Files in the Mod Builder window?
This is not possible (because C# is a compiled language) and also not ideal because two mods that change the same file would be incompatible. See the tutorials on the first page of this topic for some examples of how to make a mod. ;)
I spent some time looking over the examples and digging in the scene hierarchy, but I still can't figure out how to manipulate an existing UI element. It seems that the gameObject DaggerfallUI has a script of the same name, but I can't seem to actually effect a HUD element. For example, I tried the following code this evening:

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DaggerfallWorkshop.Game.Utility.ModSupport;
using DaggerfallWorkshop;
using DaggerfallWorkshop.Game.UserInterface;
using DaggerfallWorkshop.Game;
using DaggerfallWorkshop.Game.UserInterfaceWindows;

namespace ModernVitals
{
    public class ModernHUDVitals : MonoBehaviour
    {
        Mod mod;
        HUDVitals vitals;

        // Use this for initialization
        void Start()
        {
            mod = ModLoader.mod;
            vitals = GameObject.Find("DaggerfallUI").GetComponent<DaggerfallUI>().DaggerfallHUD.HUDVitals;
            vitals.Enabled = false;
            Debug.Log("[[ModernHUDVitals]] Start log hit at " + Time.realtimeSinceStartup);
        }

        // Update is called once per frame
        void Update()
        {

        }
    }
}
However, the vitals are still rendered in-game because the function returns them as a copy rather than a reference. I know the code is at least being because the Debug.Log is printing. But because the methods DaggerfallUI.DaggerfallHUD and DaggerfallHUD.HUDVitals have getters only and no setters I can't see any way to alter the way the HUDVitals are displayed, not unless I decativate the standard UI script and write a custom replacement for DaggerfallUI. Is there something obvious I'm missing here that would allow for a simpler solution?

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

Re: Modding Tutorials

Post by Hazelnut » Thu Feb 27, 2020 7:34 pm

LypyL wrote:
Sat Jun 18, 2016 7:52 am
Known Issues

enums - scripts with enum types defined will fail to compile. You can still use any of the enum types already in the project. This is an issue with the mcs compiler.

generic functions / classes - similar to the above, due to an issue with the compiler scripts that try to define generic functions will not compile.

Unity Versions - mods created in newer versions of unity might not be compatible with older versions of unity. This is noticeable if the mod is in the mod directory, but doesn't show up in the list of mods.
I think I've found another restriction of the mcs compiler, as code works in editor but not when packed in a .dfmod and this was the issue that Meaner Monsters mod ran into. It seems that you cannot use c# object initialisation with structs, works fine with classes though.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

l3lessed
Posts: 458
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Modding Tutorials

Post by l3lessed » Tue May 05, 2020 9:18 pm

Yes, the documentation for setting up mod settings needs updated badly. It is completely misleading. The forum post is outdated, the web page isn't complete in its documentation.

I'm using the build in mod setting creator, opening it up and saving it within the same folder as the mod script file, and I am then loading mod.GetSettings(); with awake, start, and Init. Still, no settings are showing up in the mod.

I also added the json file as an asset within the mod builder to ensure it compiles with the mod. I'm trying to track down mods to back engineer to see how it is done, but can someone provide updated documentation on this area?
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

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

Re: Modding Tutorials

Post by Ralzar » Tue May 05, 2020 9:36 pm

Like, the mod settings that you can adjust in the mod list? All you need is to list the "modsettings.json" in the *.dfmod.json file.

Take a look at my Level UpAdjuster. It uses a LOT of mod settings,

LevelUp Adjuster
My released mods

"I feel like Ralzar specifically wrote those mods for me and then said "Use them". Just so he could watch me die more."
-FuzzyBeanPlays

l3lessed
Posts: 458
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Modding Tutorials

Post by l3lessed » Tue May 05, 2020 9:59 pm

I got it. It was something small like I thought, but it should still be listed on the webpage.

I did not realize the modsettings was a separate namespace from the modsupport namespace. I would think it would be part of the general modsupport namespace, as it would logically seem to be part of mod support. Bad assumption.

Also, you can just add the settings file as an asset to the mod builder window to get it into the mod json without having to manually go into and add it yourself using a text editor.

These two documentation additions would take five minutes to add to the top of the mod settings documentation page, so future modders know right upfront modsettings is its own namespace. I know, rookie mistake, but that is what good documentation is supposed to be for.

Thanks, as always everyone, for sharing your work, so I can trouble shoot these things.
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
TheLacus
Posts: 1196
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Modding Tutorials

Post by TheLacus » Tue May 05, 2020 10:08 pm

The documentation on the website looks complete to me, what would you suggest to add?

I'm going to edit the forum post with obsolete tutorial so it won't confuse anymore in the future. ;)
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

l3lessed
Posts: 458
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Modding Tutorials

Post by l3lessed » Tue May 05, 2020 10:37 pm

It's a small nitpick thing, but I don't see any reference to using the differing namespace to access the modsettings. I thought it was built into the modsupport name space. Maybe I overlooked this somewhere? If not, it would of helped for me to see the modsettings namespace setup. Specifically, this below.

using DaggerfallWorkshop.Game.Utility.ModSupport.ModSettings;

Did I overlook it, or is this such a basic part of Object Orientated coding that no one feels it is needed clearly stated. It was a pretty rookie overlook.
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

Post Reply