Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Victsantgt on Tue 19/12/2023 21:11:06

Title: How to make a Display skip automatically?
Post by: Victsantgt on Tue 19/12/2023 21:11:06
Hello! I've seen searching through the manual and the forum all day, but couldn't find a solution to a problem I've been having.

Basically, I am trying to create a typewriter styled dialogue box using displays and substrings.

However, I've managed to get everything working as I wanted, except for one thing. Despite all my efforts, the displays don't skip automatically, and you need to click with the mouse to advance through the display letter by letter.

Is there any way to make the display skip to the next one?

This is the code I have for reference:
String text = "test";
  for (int i = 0; i <= text.Length; i++)
  {
    String substring = text.Substring(0, i);
    DisplayAt(50,400,500, substring);
  }
Title: Re: How to make a Display skip automatically?
Post by: Crimson Wizard on Tue 19/12/2023 21:31:49
Display command is "super blocking", which means that no script is run when it's on the screen, not even "repeatedly_execute_always", and so it cannot be skipped by a command from the script. So will be unusable in your case.

For your case the solution is to not use Display at all, but use other means: GUI with label, or Overlay.CreateTextual, combined with Wait function.
If you are using GUI with a label, then you just need to assign new text to a label on its step.
If you are using Overlay, then you would need to save created overlay in a variable, and call Remove to delete old overlay before creating a new one with a longer text.

EDIT: I might also mention a TypedText module, that does this effect in many kind of ways:
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-typedtext-0-7-0/
Title: Re: How to make a Display skip automatically?
Post by: Victsantgt on Wed 20/12/2023 19:02:17
Thank you! Afer adapting the code for labels it worked like a charm!

Really grateful for your help!