Why am I getting this error?

image-1

You’ll need to post the OrderCanvas() function as well in order to see the issue.

    OrderCanvas() : canvas =
        MyCanvas : canvas = canvas:
            Slots := array:
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.4}, Maximum := vector2{X := 1.0, Y := 0.4}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget1
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.5}, Maximum := vector2{X := 1.0, Y := 0.5}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget2
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.6}, Maximum := vector2{X := 1.0, Y := 0.6}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget3
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.7}, Maximum := vector2{X := 1.0, Y := 0.7}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget4
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.8}, Maximum := vector2{X := 1.0, Y := 0.8}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget5

        PlayerUI.AddWidget(MyCanvas)

Also, that PlayerUI on the last line also gives an error: Unknown identifier

Hello. You are trying to pass the variable Player to the OrderCanvas() function on line 126, but OrderCanvas() is defined as a function which takes no parameters. To fix this issue, take a look below:

   #Function now takes a player type parameter
   OrderCanvas(Player: player) : canvas =
        MyCanvas : canvas = canvas:
            Slots := array:
#....

Give that a try, and post any other problems you may run into.

@MoSchmo
Seems like I’m not getting errors there anymore but still PlayerUI at the bottom gets the same error

Now that you have passed the player as a parameter, you will need to get the player’s UI before you try adding a widget.

if(PlayerUI := GetPlayerUI[Player]):
   PlayerUI.AddWidget(MyCanvas)   

All be sure to include the appropriate import path if you haven’t already.

using {/UnrealEngine.com/Temporary/UI}

Give that a shot.

I already have that module. I was trying to find out where to put that if(PlayerUI …) snippet but I couldn’t find out where, can you point that out.

    # Order Widgets
    var OrderWidget1 : text_block = text_block{}
    var OrderWidget2 : text_block = text_block{}
    var OrderWidget3 : text_block = text_block{}
    var OrderWidget4 : text_block = text_block{}
    var OrderWidget5 : text_block = text_block{}

    # Order Messages
    Order1UI<localizes>(OrderInfo1:string) : message = "pending 1"
    Order2UI<localizes>(OrderInfo2:string) : message = "pending 2"
    Order3UI<localizes>(OrderInfo3:string) : message = "pending 3"
    Order4UI<localizes>(OrderInfo4:string) : message = "pending 4"
    Order5UI<localizes>(OrderInfo5:string) : message = "pending 5"

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=
        # TODO: Replace this with your code

        var players:[]player = Self.GetPlayspace().GetPlayers()
        if (ValidPlayer := players[0]):
            OrderCanvas(ValidPlayer)
        



    OrderCanvas(Player:player) : canvas =
        MyCanvas : canvas = canvas:
            Slots := array:
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.5}, Maximum := vector2{X := 0.5, Y := 0.5}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget1
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.5}, Maximum := vector2{X := 1.0, Y := 0.5}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget2
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.6}, Maximum := vector2{X := 1.0, Y := 0.6}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget3
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.7}, Maximum := vector2{X := 1.0, Y := 0.7}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget4
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.8}, Maximum := vector2{X := 1.0, Y := 0.8}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget5
        return MyCanvas

I would add it in the OrderCanvas() function. Indentation is also important, so make sure that is done properly.

    OnBegin<override>()<suspends>:void=
        # TODO: Replace this with your code

        var players:[]player = Self.GetPlayspace().GetPlayers()
        if (ValidPlayer := players[0]):
            OrderCanvas(ValidPlayer)
        



    OrderCanvas(Player:player) : canvas =
        MyCanvas : canvas = canvas:
            Slots := array:
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 0.5, Y := 0.5}, Maximum := vector2{X := 0.5, Y := 0.5}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget1
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.5}, Maximum := vector2{X := 1.0, Y := 0.5}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget2
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.6}, Maximum := vector2{X := 1.0, Y := 0.6}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget3
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.7}, Maximum := vector2{X := 1.0, Y := 0.7}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget4
                canvas_slot:
                    Anchors := anchors{Minimum := vector2{X := 1.0, Y := 0.8}, Maximum := vector2{X := 1.0, Y := 0.8}}
                    Offsets := margin{Top := 0.0, Left := 0.0, Right := 0.0, Bottom := 0.0}
                    Alignment := vector2{X := 0.5, Y := 0.5}
                    SizeToContent := true
                    Widget := OrderWidget5 
        #Add here
        if(PlayerUI := GetPlayerUI[Player]):
            PlayerUI.AddWidget(MyCanvas) 
        return MyCanvas

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