2018-02-04 11:45:04

Hello,
The topic says it all.
Yesterday, I've managed to figure it out how to assign the three skills to each character. The problem is that I did it using some alerts when I pressed the keys, but now I want some sounds to be plaied.
It is possible to make a bidimensional sound array and play it? I'll put the code below to have a more detailed view on what I'm talking about.
So, the below code, when you press A or S, it will show an alert with the specific weapons of each character.
So, in stead of alerts, I want to do exactly the same things, but this time using sounds instead of alerts.
Should I create a bidimensional sound array? And how to make it working properly?

string[] character_skills_initialisation(int x)
{
string[][] character_skills;
character_skills.resize(3);
for(int s=0; s<2; s++)
character_skills[s].resize(3);

character_skills[0][0]="topor";
character_skills[0][1]= "sabie";
character_skills[0][2]= "cutit";
character_skills[1][0]= "catana";
character_skills[1][1]= "sabie";
character_skills[1][2]= "sapa";
return character_skills[x];
}

void fight(int character_name)
{
string[] a={" "," "," "};
a=character_skills_initialisation(character_name);
while(true)
{
if(key_pressed(KEY_Q)) exit();
if(key_pressed(KEY_A))
{
alert("hello", a[0]);
}
if(key_pressed(KEY_S))
{
alert("hello", a[1]);
}
if(key_pressed(KEY_ESCAPE))
{
personaj_menu();
}
wait(5);
}
}

2018-02-04 21:51:30

Do you mean to have a sound array that matches the skills array? Yeah, you can do that. Or to be more accurate, you'd have an array of handles, which means you'd initialize it like this:
sound@[][] skillsounds;
And when you set the value of a particular index, it'd be like this:
@(skillsounds[0][1]) = mysound;
I don't know that the parentheses () are strictly necessary, but after a certain point I lose track of order of operations, so I include them here just to be safe.
If you'd rather work with the sound_pool, you could use a string array of filenames, but if all you want is to say skillsounds[0][0].play_wait(); the sound array would be simpler.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2018-02-05 09:24:09

The @ at symbol should be used in the code as well, or did you just put it here on the forum?
I never seen this symbol used in BGT, that's why I am asking.

2018-02-05 22:10:19

You need @ in BGT when working with object handles. It's a strange querk of the language.
The forum sometimes changes the @ sign to something different, like [a-t], so remember that's meant to be the @ symbol.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.