Page 1 of 1

Subdirectories and audio in init blocks

Posted: Wed May 07, 2014 4:38 am
by Vict0r1994
Ok, my questions are pretty much what the title says. I consulted both the Ren'py wiki and manual to no avail, and my inquiries are as follows:
1. Can I define my audio files in an init block (pretty much like images) so that I could only write play music x instead of play music "insertlongname.mp3" within the script?
2. How can I reference subdirectories within the game folder without writing something like this - "D:/Imagini/renpy-6.14.1-sdk/Work_in_progress/game/Graphics/Backgrounds/House.png" - in every single image definition I have? Same thing goes for sounds and music which are placed now inside /game/Audio/Sounds and /game/Audio/Music. (now you probably know why I want to define the audio in init blocks too...)

Isn't there any way to avoid this tedious work? I don't want my game directory to look like a recycle bin with pngs, oggs and rpys in the same fies-ridden folder, but I don't want to write whole directories throughout the whole script either, so help will be very appreciated!

Re: Subdirectories and audio in init blocks

Posted: Wed May 07, 2014 5:16 am
by Asceai
1. Can I define my audio files in an init block (pretty much like images) so that I could only write play music x instead of play music "insertlongname.mp3" within the script?
Yep.

Code: Select all

init python:
  x = "insertlongname.mp3"
or

Code: Select all

define x = "insertlongname.mp3"
For reference, this isn't defining an audio file so much as setting a variable to a string, but it will still work for play music x.
2. How can I reference subdirectories within the game folder without writing something like this - "D:/Imagini/renpy-6.14.1-sdk/Work_in_progress/game/Graphics/Backgrounds/House.png" - in every single image definition I have? Same thing goes for sounds and music which are placed now inside /game/Audio/Sounds and /game/Audio/Music. (now you probably know why I want to define the audio in init blocks too...)
You don't want to do that anyway. Your game will break on anyone else's computer. Give paths relative to the 'game' directory- that is, your House.png is:

Code: Select all

image House = "Graphics/Backgrounds/House.png"

Re: Subdirectories and audio in init blocks

Posted: Wed May 07, 2014 5:44 am
by Taleweaver
Ren'Py-specific questions go into the Ren'Py Questions forum.

Moving.

Re: Subdirectories and audio in init blocks

Posted: Wed May 07, 2014 6:00 am
by Vict0r1994
Thanks a lot! I tried to do a relative-to-the-game-directory-pathway, but I always wrote it "game/Graphics/Backgrounds/House.png" instead of just "Graphics/Backgrounds/House.png" and it didn't work... Again, thanks for the help!
EDIT: Although the pathway works in its new form, I still can't define music! Whether I try it after "init python" or before in the ways suggested above, ren'py crashes and says "IO Error: couldn't find file [defined-name]"

Re: Subdirectories and audio in init blocks

Posted: Wed May 07, 2014 7:46 am
by Asceai
Vict0r1994 wrote:EDIT: Although the pathway works in its new form, I still can't define music! Whether I try it after "init python" or before in the ways suggested above, ren'py crashes and says "IO Error: couldn't find file [defined-name]"
Post code, both the code where you define it and the code where you play it.

Re: Subdirectories and audio in init blocks

Posted: Wed May 07, 2014 7:49 am
by Vict0r1994
The code where I define it:

Code: Select all

define alarm_clock = "Audio/Sounds/alarm_clock.mp3"
The code where I play it:

Code: Select all

play sound "alarm_clock"
I double-checked the name and extension of the file and it is indeed "alarm_clock.mp3". What am I doing wrong?

Re: Subdirectories and audio in init blocks

Posted: Wed May 07, 2014 8:02 am
by Vict0r1994
No matter. Found the mistake. I shouldn't have put commas where I played it. Thanks again!