If you are storing your texts in an array, it could look like this:
dialogmode = 0
function "displaydialog": set dialogmode = 1, system set timescale = 0
- system create object dialog box
- system create object text
- text set text to array.at(x,0)
- set (instance variable) text.nexttext to array.at(x,1)
mouse clicked AND dialogmode = 1
IF text.nexttext not equal to -1:
- set text to array.at(text.nexttext,0)
- set text.nexttext to array.at(text.nexttext,1)
IF text.nexttext = -1:
- destroy dialog box
- destroy text
- set dialogmode = 0
- system set timescale = 1
When you call the function you pause the game (timescale), we set a variable to identify in which state the game is in (dialogmode = 1), which you could add as condition to other events that might interfere with the dialog.
then the dialog box and text are created. I assume we only have 1 instance of those in the layout - if not, you'd need to pick the correct instance each time you wanna work with it.
It sets the text to the proper tex to display and in the array we also have stored which text to display next. The next text to display is stored in the text's instance variable nexttext and when we press on it the text gets changed accordingly. If nexttext is -1, it means the dialog is over and the game continues, so the dialog box and text are destroyed and game's state is set to the way it was before.