Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Racoon on Sun 01/12/2019 11:18:29

Title: Questions for "Display" [SOLVED]
Post by: Racoon on Sun 01/12/2019 11:18:29
Hello again,

Where can I set where the "Display" text appears? I wish for all text to appear at the buttom of the screen. I know there is a DisplayAt function, but is there a easier way than to change all the Display function I already did?

And also, I don't want the animations to stop when text is displayed. How do I do that?

I really come across a alot of questions that mostly take me a long time to figure out, even if I search the manual. Would someone be willing to let me ask this questions per private message so I don't need to make a thread every time? I would be super grateful!

Title: Re: Questions for "Display"
Post by: eri0o on Sun 01/12/2019 11:45:16
Make a function for displaying text and use it instead of Display directly, then you can change it's behavior later. There's a find all command in the Editor so you can replace by your function.

A way to create a non-blocking way to show text is making your own, using a GUI with a label and changing the text in the label and closing the GUI by clicking on it.

You can always perform a search on the forums so it's best to ask here : https://www.google.com/search?q=show+text+without+blocking+site%3A+adventuregamestudio.co.uk
Title: Re: Questions for "Display"
Post by: Khris on Sun 01/12/2019 18:39:06
You can just use a single thread for all your questions, no need to keep opening new ones.
Title: Re: Questions for "Display"
Post by: Crimson Wizard on Sun 01/12/2019 18:54:03
Quote from: eri0o on Sun 01/12/2019 11:45:16
A way to create a non-blocking way to show text is making your own, using a GUI with a label and changing the text in the label and closing the GUI by clicking on it.

I think you may also just use Wait with GUI. Depends on how much do you want to allow happen on the background.

IIRC following is enough to keep animations playing (and repeatedly_execute_always running). Assuming you have a GUI gMessage which has a label lblMessage:
Code (ags) Select

lblMessage.Text = "my text";
gMessage.Visible = true;
int time_to_wait = Game.TextReadingSpeed * lblMessage.Text.Length;
WaitMouseKey(time_to_wait);
gMessage.Visible = false;


Now, if you think: "wow that's lots of lines, compared to calling Display, do I have to put this everywhere?"

This is where we come to ---
Quote from: eri0o on Sun 01/12/2019 11:45:16
Make a function for displaying text and use it instead of Display directly, then you can change it's behavior later. There's a find all command in the Editor so you can replace by your function.

You may make a function in GlobalScript (or another script module) like this:
Code (ags) Select

void DisplayText(String text)
{
    lblMessage.Text = text;
    gMessage.Visible = true;
    int time_to_wait = Game.TextReadingSpeed * text.Length;
    WaitMouseKey(time_to_wait);
    gMessage.Visible = false;
}


Then you declare this function in GlobalScript's header:
Code (ags) Select

import void DisplayText(String text);


And now you can use it just as you used Display, anywhere:
Code (ags) Select

DisplayText("Hello, this is my new text displaying method.");




You can do alot of fun stuff with this approach, like adding images around your text, and more.
Title: Re: Questions for "Display"
Post by: Racoon on Tue 03/12/2019 00:26:01
Thanks for your answers! I will try if I can make it work tomorrow and let you know how it worked out :)

I was not sure if it was okay to keep asking questions in the same thread since it said in the "Read first" thread that you should use a specific subject for your thread. But if everybody is ok with it, I will ask questions in one thread.
Title: Re: Questions for "Display"
Post by: Racoon on Thu 05/12/2019 19:32:22
Again, thanks so much Crimson Wizard. It is working perfectly fine and I am super happy right now. I can understand what you did in the script, but I wouldn't have been able to do it by myself. I think I understand a little bit more about GUIs now.