How do you dynamically create <localizes> message?

I’d like to pass dynamic values to UI elements such as numbers that increment. I only seem to be able to define static values though such as
TestMessage<localizes> : message = "test"

Is there any way to create these messages and pass in data such as

TestMessage<localizes> : message = "test-{Value}"

EDIT: Found a solution in-case anyone needs.

GenericMessage<localizes>(value: string) : message = "{value}"

Trying to work out this same issue

Attempting to have a UI element that displays player currency but even when initialising the message the way you have it I get the error “This variable expects to be initialized with a value of type message, but this initializer is an incompatible value of type []char->message.(3509)”

var playerCurrency : int = 0
GenericMessage(value: int) : message = “{playerCurrency}”

Widget := button_loud{DefaultText := GenericMessage}

You’ll need to do a bit of setup:

var Currency : int = 0
CurrencyText<localizes>(CurrentCurrency: int) : message = "{CurrentCurrency}"
CurrencyWidget: text_block = text_block{DefaultTextColor := NamedColors.White}

I’ll assume you already have your UI setup, so will skip over that part.

Whenever you update the currency variable, you’ll want to make sure you also update the UI:

CurrencyWidget.SetText(CurrencyText(Currency))
2 Likes

This is failing because you’re doing DefaultText := GenericMessage but GenericMessage is a function, so it should be DefaultText := GenericMessage("Your text here!")