Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: JoanCortada on Sun 19/08/2018 11:12:37

Title: Activate dialogue from a specific music
Post by: JoanCortada on Sun 19/08/2018 11:12:37

I am trying to activate an action from a specific music, I explain: the player goes to a music team and selects a song from a list, if you select a song in particular (aMusic3) I want a specific dialogue with one of the characters.

I have tried it with the command:
if (aMusic3.Play = True) ....

but there is no result.
Title: Re: Activate dialogue from a specific music
Post by: Khris on Sun 19/08/2018 12:44:02
Right after you start the music, also start the dialog. There's no need for the check you tried, even if it did work that way.

  // specific choice was made
  aMusic3.Play();
  dSomeDialog.Start();


Or set a global variable when the music was picked, then check that.

  // specific choice was made
  aMusic3.Play();
  player_picked_3 = true;

  // later
  if (player_picked_3) dSomeDialog.Start();

Title: Re: Activate dialogue from a specific music
Post by: Lewis on Sun 19/08/2018 12:59:05
Unless you mean a conversation would be different when activated depending on what music was previously selected.

In which case, set a global variable like 'track_number' and set the track number when you play the music:

Code (ags) Select
aMusic1.Play();
track_number=1;


Then use this for the conversation:

Code (ags) Select
if (track_number==1)
{
  dDialogue1.Start();
}
  else if (track_number==2)
{
  dDialogue2.Start();
}
else
{
  dDialogue3.Start();
}
Title: Re: Activate dialogue from a specific music
Post by: JoanCortada on Mon 20/08/2018 09:02:42
Hello Lewis,

that is what I want to do, depending on the music I want one character to say a specific think, dont need to be a dialog, but at the same time some dialogs will be activated or deactivated.

I am now on the Global variables, but I am not sure how I should fill the gaps:

https://postimg.cc/image/5w258427v/

Can someone give me a hand here?
Title: Re: Activate dialogue from a specific music
Post by: Khris on Mon 20/08/2018 09:23:13
Leave it to "int" and set the default value to 0 (zero).
Title: Re: Activate dialogue from a specific music
Post by: JoanCortada on Mon 20/08/2018 16:46:32
I'm trying it like that:

https://postimg.cc/image/z9yc6ztkb/

https://postimg.cc/image/dot9jdwtn/

https://postimg.cc/image/ibzblhrzv/

but for now I doesn't work
Title: Re: Activate dialogue from a specific music
Post by: Cassiebsg on Mon 20/08/2018 20:04:23
I don't see anything, what "doesn't work" exactly?

Also you can post the code like this:
[ code ]
remove the spaces inside the [ ] and copy/paste the code in here!
[ /code ]

This will give you:

function blabla_onClick()
{
    // more lines of code in here ...
}


Also: You don't need any variable, just put your code after setting the music track like Khris showed... instead of starting a dialogue just put your "cutscene" character.say code instead of the start dialogue.
Title: Re: Activate dialogue from a specific music
Post by: Khris on Mon 20/08/2018 21:11:14
In case that's the issue, some commands don't run immediately but only after the current function finishes. Dialog.Start() is one of them, as mentioned in its manual entry.
Which means the code from the second image that checks track_number should be moved inside the dialog script, before the stop command (you can use standard script commands in dialogs if you indent them by at least one space).


Also, please don't post code as image. We often take people's code and edit it, and having to retype it first will make people less likely to provide help.
If you must post images, please pick a host that doesn't horribly distort the pictures, or include them in your post (right-click the image after it was uploaded, click "copy image location" then paste that in between [img] and [/img].
Title: Re: Activate dialogue from a specific music
Post by: Lewis on Tue 21/08/2018 09:57:28
Quote from: Cassiebsg on Mon 20/08/2018 20:04:23
You don't need any variable

I'm pretty sure they're trying to check whether music is already playing, rather than trigger the dialogue to start at the same time as the music.

JoanCortada -- earlier you said you wanted a character to say a particular thing, but that it doesn't need to be a dialogue.

What's the purpose of dialog0?

In any case, I'm pretty sure the reason your example isn't working is because you're setting track_number=3 and then trying to call if track_number==2 -- which is returning 'false' because, well, it's false.