if lang == "english":Does it work inside label?

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.
Post Reply
Message
Author
User avatar
johandark
Veteran
Posts: 355
Joined: Sat Apr 30, 2016 11:04 am
Completed: Wild Guards, In Dreams
Projects: Pact with a witch
Deviantart: johandarkweb
Location: Barcelona
Contact:

if lang == "english":Does it work inside label?

#1 Post by johandark »

I want to put voice to my game, but my base language is Spanish, I just want to add voice in English... So my idea was use Conditional Statements.

If I put "if lang == "english":" and later the voice thing, should only work on english... but I discovered renpy just Completely ignore this statement... my question is... WHY?!!

Code: Select all

label start:
    if lang == "None":
        voice "voices/day01/na_sienteselfuerteagarron.ogg"
        n "Here you hear this sound because you had chosen original language."

    elif lang == "english":
        voice "voices/day01/d_¡corre!¡sigueme!.ogg"
        d "These words are chosen because you had english option."
    
    d "¡Corre! ¡Sígueme!"
This code is completely ignored except the label start: and d "¡Corre! ¡Sígueme!"... What am I doing wrong?

Thanks!
Image

User avatar
Donmai
Eileen-Class Veteran
Posts: 1958
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question, To The Girl With Sunflowers
Projects: Slumberland
Location: Brazil
Contact:

Re: if lang == "english":Does it work inside label?

#2 Post by Donmai »

Here are the answers to similar questions. Good luck.
viewtopic.php?f=8&t=40993
viewtopic.php?p=364054#p364054
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: if lang == "english":Does it work inside label?

#3 Post by Remix »

If you are considering going with the config.auto_voice, you might want to sneak in something like this...

It basically just informs you which voice file it is looking for as you step through say statements in a label

Code: Select all

default voice_file_string = "voices/{language}/{identifier}.ogg"
default voice_file_name_info = ""

init python:
    def get_voice_file_name(identifier):
        global voice_file_name_info
        vdict = {'identifier' : identifier,
                 # Amend the dict {lang name : folder name} to suit 
                 'language' : {None:'en', 'Spanish':'es'}[_preferences.language]
                }
        voice_file_name = voice_file_string.format(**vdict)
        if renpy.loadable(voice_file_name):
            voice_file_name_info = "Found: {0}".format(voice_file_name)
        else:
            voice_file_name_info = "Missing: {0}".format(voice_file_name)            
        return voice_file_name

    # Tell Ren'py to *try* to voice every line
    # using the above function to locate file
    config.auto_voice = get_voice_file_name

screen track_data():
    vbox:
        area (0.2, 0.0, 0.6, 85)
        if voice_file_name_info != "":
            text voice_file_name_info
        textbutton "English" action Function(renpy.change_language, None)
        textbutton "Espanol" action Function(renpy.change_language, "Spanish")

label start:
    show screen track_data
    "First Line"
    "Second Line"
    "Last Line"
    return
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Ocelot