• If you have a mod, tool or prefab, please use the Resources section. Click Mods at the top of the forums.

Displaying CVAR values in XUi

Numberz

New member
Hi,

Looking for some help in trying to find a way to display some custom cvar values in one of the UI windows.

I haven't been able to find any way to reference custom cvars in the Windows.xml file.

However, I did (briefly) find a workaround by using the localization.txt as a source.

As a very simple example, I added a line such as the following into one of the windows in Windows.XML:

<label depth="10" name="cvartest" text_key="cvartest"/>




And added an entry like this one into the localization.txt file:

cvartest,progression,Skills,,,My Cvar: {cvar($mycustomcvar)},,,,,,,,,,,,,,




The infuriating thing is that this was working and displaying my cvar value properly when I first tried it.

After making some very minor changes, this has, of course, stopped working for me.

Fast forward hours later and I just can't get it to work again.  All I get now is the text from the localization: My Cvar: {cvar($mycustomcvar)}

Any thoughts?  Any help would be appreciated.

TIA

 
Only thing i can think off would be try using a cvar without the $... The notes say the $ indicates the cvar is not networked and can only be used for local / math operations. Maybe something is getting between the UI reading what cvar is attached to the player cuz of it.

 
In fact, i can't tell you anything specific right now, but, look for an example using

text="${valuecontent}"

in "player_stats_entry", maybe this will give you a new way.

(i used it before, but now i don't remember anything...)

 
Only thing i can think off would be try using a cvar without the $... The notes say the $ indicates the cvar is not networked and can only be used for local / math operations. Maybe something is getting between the UI reading what cvar is attached to the player cuz of it.


Thanks for the suggestion.  Unfortunately, tried that and no dice.  I'm not sure what "networked" means in this context but my cvars appear to increment and save properly both with or without the $. 

In fact, i can't tell you anything specific right now, but, look for an example using

text="${valuecontent}"

in "player_stats_entry", maybe this will give you a new way.

(i used it before, but now i don't remember anything...)


I was thinking of this exact array this afternoon.  I wonder if it might be possible to hijack one of these variables or variable arrays and use an existing controller.  Will try to look into it and find out.  Thanks for the suggestion.

 
Last edited by a moderator:
Well, after some additional trial and error, I've stumbled back onto my original solution.  😀

It turns out that the controllers for the Attributes and Perks will allow you to pull in cvars via the localization file.   Haven't gone too deeply into this to see how far you can go with this but at the very least, you can add custom cvars into the localization (as part of a perk description for instance) and they will translate properly onto the screen in the Attributes and Perks windows.

Example:

myPerkDesc,progression,perk Int,,,"Some text here.\nMy Custom Cvar: {cvar($mycvar1)}"




I had lost the solution because I had created a new window instead of staying within the Skills set of windows.

 
Networked cvars are available between entities, non networked are only able to be used by the entity that owns it. I think.

 
Back
Top