.Say block

Started by zeta_san, Mon 24/08/2020 11:00:25

Previous topic - Next topic

zeta_san

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

cMan1.Say ("xxx");
cMan2.Say ("yyy");

Slasher

well you have SayBackground, if that's helpful...

zeta_san

I tried but it doesn't change. maybe I don't use it correctly ..

Crimson Wizard

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?

Khris

Getting NPCs to converse in the background is a bit more complicated unfortunately, but there's a module for that called QueuedSpeech.

zeta_san

I'm only interested in text, however, is it possible to try the module? (theme scumm)

Khris

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.

zeta_san

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

Crimson Wizard

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.

zeta_san


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);

}

Khris

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?

zeta_san

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

zeta_san

if or understood

first I install AGS.Plugin.AgsGet.dll

and after Queue dSpeech 410.scm

arj0n

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.

zeta_san


Khris

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.

arj0n

Ah, I already wondered why zeta_san mentioned the dll...  ???

Crimson Wizard

#17
 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

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]

Snarky

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.

zeta_san


SMF spam blocked by CleanTalk