Access var from a class array

Hey! I’m creating a custom dialog device, in which you can choose between 2 responses and depending on which one you choose the next dialog will show. I made this using a class called dialog and adding it to an array in the device class, as you can see in the code below.

My problem is that I can’t figure out how to access the “Binding1” and “Binding 2” from the main device class. Also if someone has any suggestions on how to make this device better or if I made any mistake please tell me, I’m a verse beginner and I usually don’t know what I’m doing :slight_smile:


using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }

dialog := class<concrete>():
    @editable OnShownEvent : []trigger_device = array{}
    @editable var Body : string = "..."
    @editable var Response1 : string = "..."
    @editable var Binding1 : int = -1
    @editable var Response2 : string = "..."
    @editable var Binding2 : int = -1
    @editable PPDialogDevice : popup_dialog_device = popup_dialog_device{}

    ShowDialog():void=
        PPDialogDevice.SetDescriptionText(StringToMessage("{Body}"))
        PPDialogDevice.SetButtonText(StringToMessage("{Response1}"), 0)
        PPDialogDevice.SetButtonText(StringToMessage("{Response2}"), 1)
        PPDialogDevice.Show()

    HideDialog():void=
        PPDialogDevice.Hide()

    Shown():void=
        Print("Message Shown")
        for(Trigger:OnShownEvent):
            Trigger.Trigger()

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

dialog_device := class(creative_device):

    @editable ShowEventTrigger : trigger_device = trigger_device{}
    @editable Response1 : trigger_device = trigger_device{}
    @editable Response2 : trigger_device = trigger_device{}
    @editable DialogTree : []dialog = array{}

    OnBegin<override>()<suspends>:void=
        ShowEventTrigger.TriggeredEvent.Subscribe(ShowFirst)
        Response1.TriggeredEvent.Subscribe(ShowDir1)
        Response2.TriggeredEvent.Subscribe(ShowDir2)

    ShowFirst(Agent:?agent):void=
        set CurrentDialog = 0
        if(Popup := Dialog[0]):
            Popup.ShowDialog()
        ShowDialog := dialog{}
            ShowDialog.Shown()

    ShowDir1(Agent:?agent):void=
        #Here goes the code to enable the next dialog if response was 1, the info to choose wich dialog from the array to choose is in the variable 'Binding1' in the dialog class.

    ShowDir2(Agent:?agent):void=
        #Here goes the code to enable the next dialog if response was 2, the info to choose wich dialog from the array to choose is in the variable 'Binding2' in the dialog class.
1 Like

I don’t know if you mean this, but this is a way to access values from an external class.


    ShowFirst(Agent:?agent):void=
        set CurrentDialog = 0
        if(Popup := Dialog[0]):
            Popup.ShowDialog()
            GetResponse1:= Popup.Binding1 # this way you can get into them
            GetResponse2:= Popup.Binding2
        ShowDialog := dialog{}
            ShowDialog.Shown()

1 Like

Maybe I didn’t explain it well, I want to access the variable “Binding1” and “Binding2” from the dialog class to use them to show a popup dialog device from the DialogTree array. I know how to access variables from another class but not from a class array. Here is an image to try to explain it better :slight_smile:

Maybe I’m wrong and this is not the way to do this, if so let me know :pray:

1 Like

If you pass the entire code so I can copy it to my editor, I’ll try to help you :slight_smile: