Modding Tutorials

Discuss modding questions and implementation details.
Post Reply
Narf the Mouse
Posts: 837
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.

BadLuckBurt
Posts: 160
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!

Narf the Mouse
Posts: 837
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?

Post Reply