h

In the Simple Dialogue practice, when is advance() called?

holytryst

I went back to re-review and while I got the exercise correct, I can't see anything in LinearDialogue.gd or even LinearDialogueTests.gd that calls advance(), so I'm not sure as to why they're advancing.

I thought that functions besides _ready (and perhaps others that I'm unaware of) need to be called. Even _process is "called" by advancing a frame. 

Is my understanding of functions incorrect?

1 love
Reply
  • Nathan Lovato replied

    We connected the button's pressed signal to the advance() function. When clicking the button at runtime, the button emits its pressed signal, and because of the connection, Godot calls the advance() function in response.

    So, it is getting called.

    Relevant code snippet from the lesson:

    Your understanding of functions needing to be called is correct.

  • h
    holytryst replied

    I think we're talking about different things. I'm talking about the practice and LinearDialogue.gd, which auto-plays without a button.

    This is the script:


  • Nathan Lovato replied

    Ah, my bad! The advance() function gets called in the practice tests, on the following line:

    scene_root.advance()

    It can be difficult to spot in tests because there's a sort of generic framework that tests your practices. In this framework, scene_root represents the root node of the practice scene, here, the SimpleDialogue node.

  • h
    holytryst replied

    Ah, got it. Not sure how I missed it last time, but I appreciate your answer regardless. 

    It might be good to have a comment above the advance() function to that effect (i.e. clarifying that it will be called in testing). 

    1 love