Ren'Py Questions

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Sakuya
Newbie
Posts: 19
Joined: Mon Jul 31, 2006 5:58 pm
Location: United States
Contact:

Ren'Py Questions

#1 Post by Sakuya » Tue Aug 01, 2006 2:23 am

I have some stupid newbie questions if you don't mind:

1. In Ren'Py's demo main menu screen, I think it takes at least 1 second after I click on the options there before the action is executed. Is that normal?

2. I think I will be using the demo's script (or Moonlight Walk's script) as a skeleton for my kinetic novel. So what are the things in the script that I can safely remove?

3. I'm doing a kinetic novel, so I don't need so many save_names since I don't have any choice branches. If anybody is doing kinetic novels, mind telling me what you did here? Should I divide it up into chapters?

4. In Part 2 of the tutorial, it says it declares a new background by scene bedroom1 with fade. But in the demo's script, it uses image. What happens when you use "scene"?

5. How do you pronounce "Ren'Py"? :)

I know I have some more questions but I have forgotten what they were. So that's all for now!

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: Ren'Py Questions

#2 Post by Jake » Tue Aug 01, 2006 3:01 am

Sakuya wrote:1. In Ren'Py's demo main menu screen, I think it takes at least 1 second after I click on the options there before the action is executed. Is that normal?
For me, there's a noticable delay, but it's still significantly less than a second. I guess it probably depends how fast the machine running it is - there's nothing in the script that would force a delay there.
Sakuya wrote:2. I think I will be using the demo's script (or Moonlight Walk's script) as a skeleton for my kinetic novel. So what are the things in the script that I can safely remove?
Um... all of it, or none of it, depending on how much of the original you want to keep?

Generally, the safest place to start editing would be right after the start: label - this is the 'script proper', where there's scenes and dialogue and so on, so you'd probably want to remove the dialogue and scene parts at least from this section.

You'll probably also want to change the image and Character declarations at the end of the first init block near the top, to include your own images and characters.

The style stuff right near the top of the first init block is probably the safest to keep, since that just deals with visual appearance and not story.


When I started out, the first thing I did was play with the demo script, successively taking bits like the init blocks out and seeing what broke/stopped happening, which gave me a good idea of what exactly each bit did.
Sakuya wrote:3. I'm doing a kinetic novel, so I don't need so many save_names since I don't have any choice branches. If anybody is doing kinetic novels, mind telling me what you did here? Should I divide it up into chapters?
That's what I'd do. I'm pretty sure the save name is only used for display on save games, but it seems to me to be sensible to give someone looking over the saves a clue or two as to how far through the game each save is.
Sakuya wrote:4. In Part 2 of the tutorial, it says it declares a new background by scene bedroom1 with fade. But in the demo's script, it uses image. What happens when you use "scene"?
Check the sections of the reference manual that cover the scene statement and the image statement - simply put: The 'image' statement is used to give an image file (e.g. "kitchen.png") a text label, e.g.:

Code: Select all

image kitchen = "kitchen.png"
binds the 'kitchen.png' to the image name 'kitchen'. This doesn't actually display the image, just 'load' it.
The 'scene' statement is used to display a named image as the background of a new scene (which also serves to remove other things that had been added to the old scene, like character graphics), e.g.:

Code: Select all

scene kitchen with fade
fades the old background and other scene elements, whatever they were, into a new scene with the kitchen image defined earlier as the background.
Sakuya wrote:4. How do you pronounce "Ren'Py"? :)
I'm fairly sure it's a clever pun on the term "Ren'Ai", which I seem to recall is more or less Japanese for 'True Love', and 'Python', the name of the language it's written in - so it's probably pronounced the same as the respective parts of those words: "Ren" as in "Renaissance", "Py" sounding like "Pie".

User avatar
Sakuya
Newbie
Posts: 19
Joined: Mon Jul 31, 2006 5:58 pm
Location: United States
Contact:

#3 Post by Sakuya » Tue Aug 01, 2006 3:13 am

Thanks, I'm starting to get the hang of this code. A new question:

6. It says sounds cannot be stopped once it starts playing. So I take it it will stop if you have it on loop=0 which means it plays only once? If I want it to loop until a certain thing takes place, such as a new background image that comes up which marks the start of a new chapter, would that be possible? Does this apply to music too?

User avatar
monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#4 Post by monele » Tue Aug 01, 2006 6:10 am

Code: Select all

$ renpy.play("soundfile.wav")    #plays a sound file that won't stop unless...
$ renpy.play("anotherfile.wav")    # ... another file is played before it's over
$ renpy.pause(0.5)
$ renpy.stop()    # ... or you stop the sound from playing at some point

$ renpy.music.play("musicfile.mp3")    # plays a music file that should loop by default
$ renpy.pause(10)    #waits 10 seconds
$ renpy.music.stop()    # stops the music

$ renpy.music.play("sometune.ogg", fadein=5) # plays a tune that will take 5 seconds to fade in
$ renpy.pause(5)
$ renpy.music.stop(channel=7, fadeout=5) # fades the music out over 5 seconds, then stops it (channel 7 is the default music channel)
There, that should be enough ^^

User avatar
Sakuya
Newbie
Posts: 19
Joined: Mon Jul 31, 2006 5:58 pm
Location: United States
Contact:

#5 Post by Sakuya » Tue Aug 01, 2006 4:55 pm

Thanks. So it loops automatically if you don't put in the "loops=" attribute? And "loops=0" makes it play only once?

If I ever wanted to advertise my finished game in the future in this forum, can I? Even though it won't be ren'ai at all.

User avatar
monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#6 Post by monele » Tue Aug 01, 2006 5:48 pm

Actually it seems it's either loops=True or loops=False. And it's only available for musics... So if you want to make a looping background sound (like some crowd ambience), you'll have to play it as a music.
Tip : there's a way to make more channels be "music", hence loopable, channels.

I posted my game, which isn't so much ren'ai, here and didn't get kicked too much, so it should be okay. But of course, the crowd appreciate the promise of possible ren'ai elements ^^.

User avatar
PyTom
Ren'Py Creator
Posts: 15423
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

#7 Post by PyTom » Tue Aug 01, 2006 5:53 pm

I got rid of the loop counter around 5.1 or so, as it was hard to implement and unreliable in the face of saving, loading, rollback, and the like. You can sorta fake it with renpy.music.queue, however... just queue up the music as many times as you want.

I don't think we're very strict about enforcing the Ren'Ai aspect of things.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

User avatar
yummy
Miko-Class Veteran
Posts: 733
Joined: Fri Jul 07, 2006 9:58 pm
Projects: Suna to Majo
Location: France
Contact:

#8 Post by yummy » Fri Aug 04, 2006 6:51 pm

Monele, I wonder how you managed to handle that type of SFX looping.

Actually I wanted to play a sfx for a certain amount of time with your technique then use the renpy.pause method so that I would stop and fade the SFX, but I can't seem to make it work... (even by using different channels)

Code: Select all

        $ renpy.music.play('bgm002.ogg', channel=1)
        $ renpy.music.play('se010.ogg', channel=2, fadeout=3, fadein=3)
By the way I'm still searching through the demo how to put up a music on the main menu screen... Any hints?

User avatar
monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

#9 Post by monele » Fri Aug 04, 2006 8:07 pm

The trick :

Code: Select all

init:
    python:
        renpy.sound.set_mixer(6, "sfx")
        renpy.sound.set_mixer(5, "sfx")
This says that channel 5 & 6 will be assigned to sound effects... yet they are really music channels (in that they can loop and all that stuff).

In-game, you would then go :

Code: Select all

    $ renpy.music.play('fire_amb.ogg', channel=6, loop=True, fadein=3)
    $ renpy.music.play('jungle_amb.ogg', channel=5, loop=True, fadein=3)
You will *have* to indicate one of those special channels for it to work.

Not sure exactly what you're trying to do but I'll assume you want to :
1) play a background music
2) at some point play a *looping* sfx for some time (if it's not looping, it's a totally different thing)
3) after some time (either a pause or the script going on for a few lines), stop that sfx with a fadeout.

Code: Select all

$ renpy.music.play('music.ogg') # will just play some tune in the background, on the default music channel

[...]

$ renpy.music.play('loopsound.wav', channel=6) # start playing the sound loop on channel 6

[...]

$ renpy.music.stop(channel=6, fadeout=3) # fades the sound out (3 seconds) and stops it
If you want the loop sound to fade in too, just add "fadein=X" as a parameter to music.play.

User avatar
Sakuya
Newbie
Posts: 19
Joined: Mon Jul 31, 2006 5:58 pm
Location: United States
Contact:

#10 Post by Sakuya » Fri Aug 04, 2006 8:10 pm

Interesting. So SFX and music can be either WAV or OGG or MP3? Doesn't matter?

I'm also interested in how to edit the main menu by adding a custom-made background/CG as well as BGM.

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

#11 Post by Jake » Fri Aug 04, 2006 8:41 pm

Sakuya wrote:I'm also interested in how to edit the main menu by adding a custom-made background/CG as well as BGM.
The background image is specified in style - in the demo script the lines (in the init block riiight at the bottom of the file) that control the background images are:

Code: Select all

    $ style.mm_root.background = Image("mainmenu.png")
    $ style.gm_root.background = Image("gamemenu.png")
Here, as you can guess from the file names, "style.mm_root.background" is the background for the main menu, and "style.gm_root.background" is the background for the game menu, which one gets to via right-clicking inside a game, or clicking the 'Preferences' button on the main menu.

As I understand it, you can assign any displayable to those, so if you wanted a custom CG you could assign an Image() object like in the demo examples, but you could equally assign a Solid() (e.g. "Solid((0,0,0,255))" for black) colour, or composite something together in your init block or whatever.


As for playing music, all you need to do is add a 'main_menu' label to your script, which will get called by Ren'Py when it wants to display the main menu. If you want to run the entire menu yourself you can then messa round with ui functions and jump out of context to start the game (which is detailed a bit in the manual) but if all you want to do is play some music, you can turn control over to Ren'Py to finish off the menu by jumping to the '_library_main_menu' label.

By way of example, if you copy and paste this label into the demo script - best put it right at the beginning or right at the end to make sure you're not interrupting any other code - then you'll get the Joplin piece played on the menu screen:

Code: Select all

# This label will get called automatically when the game gets to the main menu.
label main_menu:

    # Set some music playing.
    $ renpy.music.play('sun-flower-slow-drag.mid')

    # Lastly, tell Ren'Py to go manage the menu like it normally does.
    jump _library_main_menu

User avatar
Sakuya
Newbie
Posts: 19
Joined: Mon Jul 31, 2006 5:58 pm
Location: United States
Contact:

#12 Post by Sakuya » Fri Aug 04, 2006 9:24 pm

Thanks very much. So having a character image appear with a fade-in on the main menu before the options appear is possible by putting it above the BGM line of code?

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

#13 Post by Jake » Fri Aug 04, 2006 9:34 pm

Sakuya wrote:Thanks very much. So having a character image appear with a fade-in on the main menu before the options appear is possible by putting it above the BGM line of code?
On one hand, yes. If you use the following code instead:

Code: Select all

label main_menu:

    scene bg carillon
    show eileen happy
    with fade
    
    $ renpy.pause(3)

    $ renpy.music.play('sun-flower-slow-drag.mid')

    jump _library_main_menu
Then Ren'Py fades in Eileen standing in front of the Carillon, pauses for 3 seconds, then starts playing the music and jumps to the main menu. Bear in mind that the main menu clears the scene, so anything you draw here won't stay visible unless it's also on your man menu's background.

On the other hand, if you scroll right to the bottom of the demo script there's a commented-out section that starts "label splashscreen:" - as the comment above suggests, this code is executed before the menu is shown for the first time (but not subseqent times in that execution) so if you're looking to do a short intro, that's the place to put it.

You can also start music playing there which lasts into the main menu, but the splashscreen doesn't get called if the game ends/resets and goes back to the main menu, so in those situations you'd get no music if you only started it in the splashscreen code.

User avatar
Sakuya
Newbie
Posts: 19
Joined: Mon Jul 31, 2006 5:58 pm
Location: United States
Contact:

#14 Post by Sakuya » Fri Aug 04, 2006 9:59 pm

Well, what I meant was, have the character image appear ON the main menu instead of having it fade out and then fade in the main menu. So:

1. Main menu image fades in.
2. Character image fades in.
3. Music fades in.
4. Options fades in.
5. And if it's possible, when the user selects Start, everything will fade to black before the game begins. :o

Edit:
If there's no way to do that, then perhaps I can put the character image onto the main menu image PNG. That way, when the code jumps to the main menu, it will still have the character there.

User avatar
Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

#15 Post by Jake » Fri Aug 04, 2006 10:09 pm

Sakuya wrote:1. Main menu image fades in.
2. Character image fades in.
3. Music fades in.
4. Options fades in.
5. And if it's possible, when the user selects Start, everything will fade to black before the game begins. :o
To my knowledge, you can't actually fade into or out of the main menu - but you can more than likely cheat and make it look like you have. Consider instead:


(In main_menu label)
* Fade to image of character
* Fade in music
* Fade to a screenshot of the menu screen
* Jump to _library_main_menu

(set main menu BG image to the image of the character from before)

(In start label, called when 'start game' is clicked)
* display screenshot of the menu screen with no transition effects
* fade from screenshot to black
* begin game


... make sense?

PyTom will probably come back from Otakon and tell me I've got it all wrong anyway and you can in fact fade in and out of the actual functioning-while-it's-fading main menu... ;-)

[Edit: I see you had the same idea I did!]

Post Reply

Who is online

Users browsing this forum: Google [Bot]