Being a novice as far as scripting goes, I have tried a couple of different ways of getting this to work, but so far I've just hacked and slashed my way to a million different syntax errors and given myself a headache. So I'm throwing in the towel now and turning to anyone who actually knows what they're doing, because I clearly don't.
Anyway, what I'd like to accomplish is the possibility of script-calling a random voice clip, stored in the SE directory, based on the character leading the party. ($game_party.actors[0].id)
So it'd be something like:
Audio.se_play("Audio/SE/" + *party leader's id* + *random number 1-10, maybe a variable ID?*)
Only with a syntax that actually does something other than cause a crash.
Also, I realize that with a great deal of conditional branching this could probably be accomplished without scripting, but the lag this would include is a bit much when the whole playable cast is involved.
Thanks in advance.
A random number is created by using this syntax:
Where var is the variable and num is the maximum number. The minimum number is 0. Can you discover the rest yourself?
Actually, in my opinion, this would be quite simple using Common Events, and wouldn't cause any significant amount of lag. It would work with a script as well, and this is the script request board after all, but let me know if you're interested in seeing how to do it my way.
module Random_SE
def self.play(volume = 100, pitch = 80)
rand = rand(10) # Or however many different SFX you have for each actor.
filename = "Audio/SE/Actor#{$game_party.actors[0].id}_#{rand}"
se = RPG::AudioFile.new(filename, volume, pitch)
$game_system.se_play(se)
end
end
I haven't testes this at all, just now wrote in the window, but this should work. Just have the SFX named like this:
Actor1_0, Actor1_1, Actor3_2
The Actor1 will represent the first actor in the database, etc, and the second number after the _ will be the number of the random SE for that actor. Just make sure you start with 0, and that all actors have the same number of SFX.
Use this syntax for a call script: Random_SE.play
You can also call it with arguments, though it is not required, like this: Random_SE.play(volume, pitch)
Let me know if that works. I can't remember if "id" is a variable for game_actor, or if that is only in $data_actors.
Okay, so I gave that a shot, (the code ForeverZero provided) but now I get an error reading:
"Unable to find file Section100:130:in 'se_play' Audio/SE/Audio/SE/Actor1_0"
Can anyone make any sense of that?
Try this:
module Random_SE
def self.play(volume = 100, pitch = 80)
rand = rand(10) # Or however many different SFX you have for each actor.
filename = "Actor#{$game_party.actors[0].id}_#{rand}"
se = RPG::AudioFile.new(filename, volume, pitch)
$game_system.se_play(se)
end
end
That resolves the repeat directory part of the error, but I still get the strange message:
"Unable to find file Section100:130:in 'se_play'"
Try using the cache see if that works if u use the cache u don't have to add the flie location just the name also you might want to check but game_system might already call the location