Random Battle Transitions
Alright, I'm not quite sure if this is the right place for this, because it's just a script snippet. If you are like me, then you'd like some randomness in your games. It gets really annoying when the engine always uses the same transition for Scene_Battle.
First, go into the Script Editor. Next go to Scene_Battle1. Now look in the main method for where it says:
if $data_system.battle_transition == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition)
end
Replace those lines with:
trans = []
Dir['Graphics/Transitions/*.{png,jpg,bmp}'].each{ |file|
trans.push(File.basename(file, '.*'))
}
if FileTest.directory?('C:\Program Files/Common Files/Enterbrain/RGSS/Standard/Graphics/Windowskins')
Dir['C:\Program Files/Common Files/Enterbrain/RGSS/Standard/Graphics/Transitions/*.{png,jpg,bmp}'].each{ |file|
trans.push(File.basename(file, '.*'))
}
end
trans_index = rand(trans.size)
Graphics.transition(40, "Graphics/Transitions/" + trans[trans_index])
And there you have it, random battle transitions.
Note. It works even if you don't use the RTP.
"C:\" Should be either "C:\\" or "C:/". xD
You shouldn't hard code non-relative paths. That won't work on a 64 bit PC or if some installed the RTP somewhere else. The RGSS DLL has a function to get the RTP path, just use Win32API to use it.
What is the method, then?
And blizz, I don't know how it worked if C:\ doesn't work. It worked fine on my computer.
C:\Users\Cody\Projects
I think he means because you changed the slashes after the 'C:\' because every slash after that is '/'
Maybe Ruby was smart enough to realize that \P is not a character (unlike \r or \n or \t) and simply looked at the \ as if it was \\.
Since \ is used to designate an escape character, in order to get the actual character in a string, you have to use \\. I'm not entirely sure, but it could also be because of the '' strings instead of "" strings as '' strings are considered simple strings.
Here is an example in old script I made long ago. It gives paths to any/all RTP's (since up to 3 RTPs can be used).
http://forum.chaos-project.com/index.php/topic,5908.0.html