pf111

Villager
Member
Joined
Jun 1, 2021
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Hi, I'm trying to call a sound effect via the script call 'AudioManager.playSe'. The thing is that I want to call the sound effect depending on a variable. The variable is a num type so I use .toString() to change it but the sound effect doesn't play. I've tried at least a 100 times with different variants. This is what the script looks like so far:

$gameVariables.setValue(8, $gameParty.members[1].actorId().toString());
AudioManager.playSe({name: $gameVariables.value(8), volume: 90, pitch: 100, pan: 0});

Basically i get an id from a current party member in battle, turn it to string then set it to a game varabile. Later just use the playSe function. The idea is that each party member plays a different sound (with voice acting?).

Is there a way to make this work, or perhaps using other stuff like plugins?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,467
Reaction score
2,587
First Language
English
Primarily Uses
RMMZ
In order for this to work, your sound effect file name would need to just be the actor's ID number. Is that the case?
 

pf111

Villager
Member
Joined
Jun 1, 2021
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMZ
That was quick! Yes, thats the idea. Having multiple id's being called by the variable 8. I'm not sure if the id goes 000X or just X, so I'm testing it with both formats just in case. Also I've tried testing a variable set to just 'X' (without extension .oog) and it worked, but still nothing using a numerical variable converted to string. Maybe toString() doesn't work by scripting in the event console?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,467
Reaction score
2,587
First Language
English
Primarily Uses
RMMZ
Oh, I see what you've done wrong. You're missing the () after members.
 

pf111

Villager
Member
Joined
Jun 1, 2021
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMZ
That did it! I thought it wasn't necessary since the script call list doesn't write () after members.
1623360172231.png
But that begs the question, is it necessary on every non-rpgmakermz function use?
Thanks a lot!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,467
Reaction score
2,587
First Language
English
Primarily Uses
RMMZ
Oh dear, I'd better let Archeia know about that so the script call list can be updated, because it won't work without the brackets.

It's necessary if you're calling a function, yes. The brackets are how you tell Javascript in the first place that you're calling a function rather than accessing a property.
 

pf111

Villager
Member
Joined
Jun 1, 2021
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMZ
Well, I better start editing all my scripts haha. Thanks again!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,467
Reaction score
2,587
First Language
English
Primarily Uses
RMMZ
Wait, what script call list are you seeing that in? They all have brackets in the Google Docs version.
 

pf111

Villager
Member
Joined
Jun 1, 2021
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMZ
I'm using the extended one, the Game Data page.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,467
Reaction score
2,587
First Language
English
Primarily Uses
RMMZ
You got a link for that?
 

pf111

Villager
Member
Joined
Jun 1, 2021
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMZ
https://docs.google. com/spreadsheets/d/1gQNAoYKpkO9Qglgbi8IplX_BPvXmfvG3Rk-R27W30DU/edit#gid=424264704
It got autoembeded erase the space after google.
 

Latest Threads

Latest Posts

Latest Profile Posts

I know it's a waste of time, but I decided to create a script that forces the RM2k game to always be in windowed mode. Just for fun anyway.
Rm2k.png
Coding some stuff. I just hope I'll be able to finish before school starts.
It's nice and breezy as well cool here, no AC needed! But keep you cozy
MrSaturnMZ.png Can confirm that Mr. Saturn is appearing in Vtubers Vs MOTHER and here's the MV/MZ compatible sprite sheet for them.

Forum statistics

Threads
112,438
Messages
1,068,297
Members
146,089
Latest member
hannesm
Top