Activate dialogue from a specific music

Started by JoanCortada, Sun 19/08/2018 11:12:37

Previous topic - Next topic

JoanCortada


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.

Khris

#1
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.

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


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

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

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


Lewis

#2
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
aMusic1.Play();
track_number=1;


Then use this for the conversation:

Code: ags
if (track_number==1)
{
  dDialogue1.Start();
}
  else if (track_number==2)
{
  dDialogue2.Start();
}
else
{
  dDialogue3.Start();
}
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

JoanCortada

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?

Khris

Leave it to "int" and set the default value to 0 (zero).


Cassiebsg

#6
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:
Code: ags

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.
There are those who believe that life here began out there...

Khris

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].

Lewis

#8
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.
Returning to AGS after a hiatus. Co-director of Richard & Alice and The Charnel House Trilogy.

SMF spam blocked by CleanTalk