How to reference element of array when compiler says that I'm trying to call a function with 'decides' effect

line_class := class<concrete>:

    @editable
    Title : string = "Title"
    @editable
    Description : string = "Message"
    @editable
    Decisions : []decision_class = array{}
    @editable
    Camera : gameplay_camera_fixed_point_device = gameplay_camera_fixed_point_device{}
    @editable
    Trigger : trigger_device = trigger_device{}
    @editable
    PopUpDialog : popup_dialog_device = popup_dialog_device{}

# A Verse-authored creative device that can be placed in a level
hello_world_device := class(creative_device):

    var Players : [] player = array {}

    @editable
    Button : button_device = button_device{}

    @editable
    MyLines:[]line_class = array{}

    var CurrentLine : int = 0

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=

        Button.InteractedWithEvent.Subscribe(StartDialogue)

    StrToMsg<localizes>(S : string) : message = "{S}"

    StartDialogue(Agent : agent) : void =

        set CurrentLine = 0
        Initialization(CurrentLine, Agent)

    Initialization(LineNumber : int, Agent : agent) : void =

        LineNow : line_class = MyLines[LineNumber]

        Title : message = StrToMsg(LineNow.Title)
        Description : message = StrToMsg(LineNow.Description)
        PopUp : popup_dialog_device = LineNow.PopUpDialog
        Decisions : []decision_class = LineNow.Decisions

        PopUp.SetTitleText(Title)
        PopUp.SetDescriptionText(Description)
        for (Index := 0..Decisions.Length-1):
            DecisionNow : decision_class = Decisions[Index]
            PopUp.SetButtonText(StrToMsg(DecisionNow.Text), Index)
        
        PopUp.Show(Agent)
        PopUp.RespondingButtonEvent.Subscribe(DecisionMade)

In this code I have array “MyLines” of line_class

When I’m trying to refernce one of the elements in “Initialization” function using MyLine[LineNumber] compiler says that I’m trying to call a function with “decides” effect. How to fix it?

Hi.
Any time you call an array, it is a failable expression. This is because when you call it, there might be nothing there and it will return as false or fail. All you have to do is call the array from within an IF or FOR expression. In other words, call it conditionally. MyLines needs to be called like this:
if (MyLine[LineNumber]):

And then you can assign any value it returns IF it succeeds.

Perhaps this tutorial will help too: