Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: zeta_san on Mon 24/08/2020 11:00:25

Title: .Say block
Post by: zeta_san on Mon 24/08/2020 11:00:25
Hello guys

Is it possible to use loosely saying everything during sentences?

for example, I walk into a room and two men talk to each other as I approach

Code (ags) Select

cMan1.Say ("xxx");
cMan2.Say ("yyy");
Title: Re: .Say block
Post by: Slasher on Mon 24/08/2020 12:30:51
well you have SayBackground, if that's helpful...
Title: Re: .Say block
Post by: zeta_san on Mon 24/08/2020 13:00:19
I tried but it doesn't change. maybe I don't use it correctly ..
Title: Re: .Say block
Post by: Crimson Wizard on Mon 24/08/2020 13:08:00
Quote from: zeta_san on Mon 24/08/2020 13:00:19
I tried but it doesn't change. maybe I don't use it correctly ..

Please elaborate, what exactly are you trying to do, and what did you write in script?
Title: Re: .Say block
Post by: Khris on Mon 24/08/2020 13:43:31
Getting NPCs to converse in the background is a bit more complicated unfortunately, but there's a module for that called QueuedSpeech (https://www.adventuregamestudio.co.uk/forums/index.php?topic=23806.0).
Title: Re: .Say block
Post by: zeta_san on Mon 24/08/2020 14:34:22
I'm only interested in text, however, is it possible to try the module? (theme scumm)
Title: Re: .Say block
Post by: Khris on Mon 24/08/2020 15:47:16
Not sure what you're asking tbh; the module only does text afaik, it primarily allows you to chain multiple SayBackground commands.
It's possible to try the module, just download it and import it into your game. Check the thread for instructions.
Title: Re: .Say block
Post by: zeta_san on Mon 24/08/2020 17:28:00
Quote from: Khris on Mon 24/08/2020 15:47:16
Not sure what you're asking tbh;

the action is simple. The character walks and on the street there are 2 workers talking. I wish the character didn't get stuck
Title: Re: .Say block
Post by: Crimson Wizard on Mon 24/08/2020 19:23:12
Quote from: zeta_san on Mon 24/08/2020 17:28:00
the action is simple. The character walks and on the street there are 2 workers talking. I wish the character didn't get stuck

SayBackground does that, it plays non-blocking. But you said it does not change, so I asked to show your actual script where you call that function. Did it work in the end, or still does not? What exactly happens?

As for SayBackground issue, the problem with SayBackground is that it does not wait for previous SayBackground to finish on its own. So, if you want 2 people to say lines in turn, then you would need to script more complicated logic. If done by hand, you declare some kind of a counter variable, and use a timer to start new lines (see "SetTimer" and "IsTimerExpired" articles in the manual).
QueuedSpeech module does that for you, if I understand correctly.
Title: Re: .Say block
Post by: zeta_san on Tue 25/08/2020 07:52:35

thanks for your patience and sorry if i'm not clear

Crimson.. Sorry you're right, yesterday was a chaotic day, I tried to say background in different ways that I can't tell

let's say

room_RepExec () function
{

cOp1.SayBackground ("& 1 phrase1");
Wait (10);
cOp1.SayBackground ("& 2 answer1");
Wait (10);
cOp1.SayBackground ("& 3 phrase2");
Wait (10);
cOp1.SayBackground ("& 4 answer2");
Wait (10);

}
Title: Re: .Say block
Post by: Khris on Tue 25/08/2020 08:45:19
This will not work at all; while you can put Wait() commands in room_RepExec you're not supposed to do that; with a default game speed of 40 FPS, that functions runs 40 times per second, and Wait(10) pauses execution for 10/40ths of a second, not ten seconds. Regardless of the timing specifics, that function will simply make the game unresponsive, forever.

The entire reason for the creation of the QueuedSpeech module is beginners struggling with background conversations exactly like you are doing, again: it's not that simple, and this approach will never work as intended.

Why are you not trying to use the well documented module instead?
Title: Re: .Say block
Post by: zeta_san on Tue 25/08/2020 09:00:52
Quote from: Khris on Tue 25/08/2020 08:45:19

Why are you not trying to use the well documented module instead?



yes Khris sorry, I was replying to Crimson. Late but I wanted to answer
Title: Re: .Say block
Post by: zeta_san on Tue 25/08/2020 10:45:48
if or understood

first I install AGS.Plugin.AgsGet.dll

and after Queue dSpeech 410.scm
Title: Re: .Say block
Post by: arj0n on Tue 25/08/2020 12:18:51
Quote from: zeta_san on Tue 25/08/2020 10:45:48
first I install AGS.Plugin.AgsGet.dll
copy the dll into the "c:/program files (x86)/Adventure Game Studio 3.5.0/" folder

and after Queue dSpeech 410.scm
open ags and import the Queue dSpeech 410.scm into the scripts section from within the Explore Project panel.
Title: Re: .Say block
Post by: zeta_san on Tue 25/08/2020 12:37:07
(https://i.ibb.co/QM4t7Zp/c.png)
Title: Re: .Say block
Post by: Khris on Tue 25/08/2020 12:48:33
No, it's not a plugin, and you definitely don't need a .dll file. It's a module, which means it's just a bunch of regular AGS code.

All you need to do is right-click the Script node of the Project tree, and pick "Import script...", then select the .scm file.
Title: Re: .Say block
Post by: arj0n on Tue 25/08/2020 12:54:24
Ah, I already wondered why zeta_san mentioned the dll...  ???
Title: Re: .Say block
Post by: Crimson Wizard on Tue 25/08/2020 16:07:49
 zeta_san, just in case there's a misunderstanding - you do not need AGS.Plugin.AgsGet plugin to install script modules, that plugin is purely optional and made for convenience of finding certain modules.
Anyway, if you downloaded QueuedSpeech scm, simply import it into project, like Khris explained above.


That it's indeed much easier to use module if you're beginner, so you probably should do that.

Regarding SayBackground, I apologize for not giving full script example earlier, but only for the reference and if you are curious, chained SayBackground is implemented roughly like this:
Spoiler

Code (ags) Select

int backgroundDialogCounter;

function room_AfterFadein()
{
    // start background speech timer,
    // 120 is number of game ticks,
    // if game runs 40 fps by default, that would be 3 seconds
    SetTimer(1, 120);
}

function room_Leave()
{
    // disable background speech timer,
    // in case player left the room before it expired
    SetTimer(1, 0);
}

function room_RepExec ()
{
    if (IsTimerExpired(1))
    {
         switch (backgroundDialogCounter)
         {
         case 0: cOp1.SayBackground ("& 1 phrase1"); break;
         case 1: cOp1.SayBackground ("& 2 answer1"); break;
         case 2: cOp1.SayBackground ("& 3 phrase2"); break;
         case 3: cOp1.SayBackground ("& 4 answer2"); break;
         }
         // increase counter by 1
         backgroundDialogCounter++;
         // when it reaches 3 start all over again (optional)
         if (backgroundDialogCounter > 3)
         {
              backgroundDialogCounter = 0;
         }
         // start timer till next phrase
         SetTimer(1, 120);
    }
}

[close]
Title: Re: .Say block
Post by: Snarky on Tue 25/08/2020 16:44:53
Zeta, it seems like you're struggling with some of the fundamental ways that AGS works. I would highly recommend reading the manual, which has helpful sections on several of these topics.
Title: Re: .Say block
Post by: zeta_san on Tue 25/08/2020 17:35:17
thank you all