Justify Text Block Text "LEFT"

Hello! I am wondering how I can justify the text in the text_block I created (see code below) to the left or right. I’ve been trying to figure it out all day but I am feeling dumber by the hour :joy::joy: All jokes aside, I greatly appreciate anyone who can help me out!

var ZombieHUDMessage : text_block = text_block{DefaultTextColor := color{R:= 255.0, G:= 255.0, B:=255.0}}
ZombieMessage<localizes>(ZombieText : int) : message="Zombies Elims: {ZombieText}"
ZombieUI<private>(Fort: fort_character) : void=
    if(PlayerUI := GetPlayerUI[Player]):
        ZombieHUDMessage.SetText(ZombieMessage(0))
        MyCanvas : canvas = canvas:
            Slots := array:
                canvas_slot:
                    Anchors := anchors{ Minimum := vector2{X := 0.0, Y := 0.5}, Maximum := vector2{X := 0.0, Y := 0.5}}
                    Offsets := margin{Top := 250.0, Left := 125.0, Right := 50.0, Bottom := 50.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := ZombieHUDMessage
                    ZOrder := 0
        PlayerUI.AddWidget(MyCanvas)

Just to be clear, I am not talking about justifying the whole widget using anchors, I am talking about justifying the text only. This is so if I have multiple text_blocks on the same anchor they will all line up regardless of the character count.

As mentioned in the discord channel, you have to change the X of alignment. Try this:

var ZombieHUDMessage : text_block = text_block{DefaultTextColor := color{R:= 255.0, G:= 255.0, B:=255.0}}
    var ZombieHUDMessage2 : text_block = text_block{DefaultTextColor := color{R:= 255.0, G:= 255.0, B:=255.0}}
    var ZombieHUDMessage3 : text_block = text_block{DefaultTextColor := color{R:= 255.0, G:= 255.0, B:=255.0}}
    ZombieMessage<localizes>(ZombieText : int) : message="Zombies Elims:"
    
    ZombieUI<private>(Fort: fort_character) : void=
        if(Agent:=Fort.GetAgent[]):
            if (Player := player[Agent]):
                if(PlayerUI := GetPlayerUI[Player]):
                    ZombieHUDMessage.SetText(ZombieMessage(0))
                    ZombieHUDMessage2.SetText(ZombieMessage(0))
                    ZombieHUDMessage3.SetText(ZombieMessage(0))
                    MyCanvas : canvas = canvas:
                        Slots := array:
                            canvas_slot:
                                Anchors := anchors{ Minimum := vector2{X := 0.0, Y := 0.5}, Maximum := vector2{X := 0.0, Y := 0.5}}
                                Offsets := margin{Top := 50.0, Left := 125.0, Right := 50.0, Bottom := 50.0}
                                Alignment := vector2{X := 1.0, Y := 0.5}
                                SizeToContent := true
                                Widget := ZombieHUDMessage
                            canvas_slot:
                                Anchors := anchors{ Minimum := vector2{X := 0.0, Y := 0.5}, Maximum := vector2{X := 0.0, Y := 0.5}}
                                Offsets := margin{Top := 150.0, Left := 125.0, Right := 50.0, Bottom := 50.0}
                                Alignment := vector2{X := 0.0, Y := 0.5}
                                SizeToContent := true
                                Widget := ZombieHUDMessage2
                            canvas_slot:
                                Anchors := anchors{ Minimum := vector2{X := 0.0, Y := 0.5}, Maximum := vector2{X := 0.0, Y := 0.5}}
                                Offsets := margin{Top := 250.0, Left := 125.0, Right := 50.0, Bottom := 50.0}
                                Alignment := vector2{X := 0.5, Y := 0.5}
                                SizeToContent := true
                                Widget := ZombieHUDMessage3
                    PlayerUI.AddWidget(MyCanvas)

and you’ll see where the text gets placed

1 Like

Oh I see what you are saying now! I was getting confused because the way I originally had everything set up, the X alignment would shift the whole “widget” or whatever you call it, not the text itself, but now I see what I was doing wrong

I appreciate the help, thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.