I am using UnrealEngine and Rider for the C++ side.
Morning all, Hope I can ask this here.
I am following a instructor for a course but cannot get this resolved because its not part of the course.
So here is his original code.
void FInv_LabelNumberFragment::Assimilate(UInv_CompositeBase* Composite) const
{
FInv_InventoryItemFragment::Assimilate(Composite);
if (!MatchesWidgetTag(Composite)) return;
UInv_Leaf_LabeledValue* LabelValue = Cast<UInv_Leaf_LabeledValue>(Composite);
if (!IsValid(LabelValue)) return;
LabelValue->SetText_Label(Text_Label, bCollapseLabel);
FNumberFormattingOptions Options;
Options.MinimumFractionalDigits = MinFractionalDigits;
Options.MaximumFractionalDigits = MaxFractionalDigits;
LabelValue->SetText_Value(FText::AsNumber(Value, &Options), bCollapseValue);
}
it displays a float value called Value in a item description widget. It works no problem.
Now I want to display a 2d6 +3 type of value.
NumberOfDice d TypeOfDice + ExtraDamage.
So this is my code, but cannot figure out to properly write the code.
void FInv_DamageNumberFragment::Assimilate(UInv_CompositeBase* Composite) const
{
FInv_InventoryItemFragment::Assimilate(Composite);
if (!MatchesWidgetTag(Composite)) return;
UInv_Leaf_LabeledValue* LabelValue = Cast<UInv_Leaf_LabeledValue>(Composite);
if (!IsValid(LabelValue)) return;
LabelValue->SetText_Label(Text_Label, bCollapseLabel);
FNumberFormattingOptions Options;
*//LabelValue->SetText_Value(FText::AsNumber(Value, &Options), bCollapseValue);
*
LabelValue->SetText_Value(FText::FromString( FString::Printf(TEXT(“%i d %i + %i”), GetNumberOfDice() , GetTypeOfDice(), GetExtraDamage(), &Options), bCollapseValue));
}
this is the line to fix.
LabelValue->SetText_Value(FText::FromString( FString::Printf(TEXT(“%i d %i + %i”), GetNumberOfDice() , GetTypeOfDice(), GetExtraDamage(), &Options), bCollapseValue));
any help would be great. Been at this for days.
