Auto advance say dialogue boxes

Prompted by a question on discord, here is how to automatically advance dialogue from say commands. This could be useful if you want to make a cutscene and not rely on the player pressing a button to advance the text.

Key points:

  • If you call say multiple times in a row in a script, the last say will replace the previous.
  • wait and play execution is paused while a say dialogue box is on screen, so you can't (for example) wait for 2 seconds then call say again to auto-advance...
  • ...but not everything pauses! Songs for example will continue to play, and you can trigger code to run after a song ends with the pattern once "songName" then.

This snippet from a room script will give auto-advancing dialogue:

on enter do
  say "Test dialogue"
  once "rest2s" then
    say "Auto advanced!"
  end
end

Where rest2s is a song with volume 0 that lasts for 2 seconds.

This only works with songs and not sounds unfortunately, so the downside is it will interfere with your music (as you can only have one song playing at a time). If however this was being used for a cutscene with music synced to the dialogue it could work well!

Of course as soon as I posted about this, @Jongjungbu realised there are other ways of waiting and calling another say - the player draw event continues to be called every frame while a say dialogue box is on screen, so another way of auto-advancing dialogue is like this:

In the room "blahblah" script:

on enter do
  say "Test dialogue"    
end

In the player script:

on draw do
  if event.room=="blahblah" then
    counter++
    if counter==60 then 
      say "Advance!"
    end
  end
end

No matter your approach, one thing to bear in mind is that the player could still dismiss your dialogue with a button press before it is auto-advanced. As per the docs ignore/listen does not affect advancing or dismissing text. You could get around this by setting a high value for config.sayAdvanceDelay (and then setting it back afterwards so you don't stop regular dialogue from being advanced/dismissed!)

Of course if you really want fine control over your dialogue, you can forgo say entirely and use window and label (and whatever else) in the player draw event :slight_smile:

3 Likes