Jump to content

Need help on forcing UI update for a mod


darkgametrain

Recommended Posts

I'm working on a mod that changes the way the player's inventory weight is calculated. My problem is actually getting the new weight to display in the pipboy. Whenever the script runs like when opening the pipboy or when the player makes a change to their inventory the displayed weight in the inventory tab becomes 0, and the player must switch tabs in order to get the actual new weight to appear. I figure that I could force the inventory weight UI element to update while it's on screen using something like Set/GetUIFloat, but I'm really clueless on how to actually use those functions and when I open the games xml files to look for the value I want to edit I have no idea what I'm looking at. I want to make it clear that I'm talking about inventory weight here and NOT carry weight like most mods that edit weight values, and also that this is about the UI display of inventory weight as I already figured how to change the actual inventoryweight value and the mod works just fine. Any help I can get on this would be appreciated.

 

 

I have one other question. It's about getting my script to run in both game and menu mode without having to use separate blocks if possible. It's not a huge deal, but it does cause the script to run unnecessarily whenever the player switches between modes since I basically have 2 identical blocks. Plus it also leaves me with double the script to navigate and edit which is not fun.

Edited by darkgametrain
Link to comment
Share on other sites

It's a bit more complicated than using SetUIFloat. The value is not displayed in numerical format, but as a string containing both the inventory weight and the carry weight. For example: "46/70". So you'll have to construct a string with both values, separated by a slash, and use SetUIString or SetUIStringEx instead.

The XML is organized in a tree-like child/parent relationship structure, somewhat like folders on your harddrive. Pay good attention to how the code is indented when you read it, as it helps you understand what level you're on. Using a more advanced text editor than the standard notepad with syntax highlighting also helps a lot. As for making sense of the actual properties and their values, that is going to take some practice, as there's not a lot in the way of documentation for the game's XML schema. This page explains some of it (it's for TESIV, but it uses the same system for menus.) If you're completely new to XML, you can also search the internet for some generic XML tutorials. It's a versatile language with many uses.

The path to the element in the XML is "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_HeadlineRect/IM_Headline_PlayerWGInfo/_Value".

So you use SetUIString like this:

SetUIString "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_HeadlineRect/IM_Headline_PlayerWGInfo/_Value" yourStringVar

Or with SetUIStringEx

SetUIStringEx "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_HeadlineRect/IM_Headline_PlayerWGInfo/_Value" "%.0f/%.0f" inventoryWeight carryWeight

As for avoiding identical code blocks, you can use NVSE user defined functions to avoid that. It allows you to define your own functions in self-contained object scripts and call them with the Call function. Study this and related pages on the GECK wiki. There's a link at the bottom of the page to an external site with a more user friendly tutorial.

What's great about UDFs is that you can separate all those small code snippets that you use in multiple places and make them into their own function and use them anywhere. So you could make a CalculateWeight function for your mod and have it return your modified inventory weight:

let inventoryWeight := call CalculateWeight

Hope this helps—best of luck with your mod. :smile:

Edited by Ladez
Link to comment
Share on other sites

It's a bit more complicated than using SetUIFloat. The value is not displayed in numerical format, but as a string containing both the inventory weight and the carry weight. For example: "46/70". So you'll have to construct a string with both values, separated by a slash, and use SetUIString or SetUIStringEx instead.

 

The XML is organized in a tree-like child/parent relationship structure, somewhat like folders on your harddrive. Pay good attention to how the code is indented when you read it, as it helps you understand what level you're on. Using a more advanced text editor than the standard notepad with syntax highlighting also helps a lot. As for making sense of the actual properties and their values, that is going to take some practice, as there's not a lot in the way of documentation for the game's XML schema. This page explains some of it (it's for TESIV, but it uses the same system for menus.) If you're completely new to XML, you can also search the internet for some generic XML tutorials. It's a versatile language with many uses.

 

The path to the element in the XML is "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_HeadlineRect/IM_Headline_PlayerWGInfo/_Value".

 

So you use SetUIString like this:

SetUIString "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_HeadlineRect/IM_Headline_PlayerWGInfo/_Value" yourStringVar

Or with SetUIStringEx

SetUIStringEx "InventoryMenu/GLOW_BRANCH/IM_MainRect/IM_HeadlineRect/IM_Headline_PlayerWGInfo/_Value" "%.0f/%.0f" inventoryWeight carryWeight

As for avoiding identical code blocks, you can use NVSE user defined functions to avoid that. It allows you to define your own functions in self-contained object scripts and call them with the Call function. Study this and related pages on the GECK wiki. There's a link at the bottom of the page to an external site with a more user friendly tutorial.

 

What's great about UDFs is that you can separate all those small code snippets that you use in multiple places and make them into their own function and use them anywhere. So you could make a CalculateWeight function for your mod and have it return your modified inventory weight:

let inventoryWeight := call CalculateWeight

Hope this helps—best of luck with your mod. :smile:

Thanks Ladez. That really helps a lot. I had no idea that inventoryweight wouldn't be represented with just a numeric value in the UI, but SetUIStringEX should work out very well for my purposes. I have used UDFs before, but obviously don't have a great understanding of them. I'll study up on them and see what I can make happen.

Link to comment
Share on other sites

The Pip-Boy updates when an item is removed from the player inventory, so all you must do is add and then remove an item.

Thanks for the reply, but that doesn't really work for my purposes. Adding/Removing items causes the game to recalculate the weight and display it, but since I'm overwriting the game's weight calculation with my own it leads to the displayed weight being different from the actual weight. That's why I need to force just the UI to update once my changes to the actual weight have taken effect. Anyway Ladez advice about using SetUiStringEX worked perfectly, and now I'm just toying with some adjustments to action point cost and regen calculation before I release the mod.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...