[Solved] String tags in string variables.

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
jacktim
Newbie
Posts: 2
Joined: Tue Jun 10, 2008 11:02 am
Contact:

[Solved] String tags in string variables.

#1 Post by jacktim »

As part of a small project I'm working on (just mucking about with the RenPy system), I have a character select screen that stores a dialog line as a string. This string includes string tags (in particular the alpha tag) and when the string is called later, it displays the full string instead of parsing the tag. Is there any way to get it to parse the tag?

Code: Select all

    menu:
        "Who would you like to play as?"
        "Lawrence \"Law\" Dale":
            $ char = law
            $ diag = "\"Whaddya say kid? Wanna work together?\"\n\nPlay as the Demon Bounty Hunter, Law?"
        "Sarah \"Sadie\" Jaegar":
            $ char = sadie
            $ diag = "\"Let\'s do this! {alpha=0.5}But don\'t tell Law!{/alpha}\"\n\nPlay as Little Scorpion Sadie?"
        "\"Desi Ethica\"" if flags.Law and flags.Sadie:
            $ char = desi
            $ diag = "\"Aw, aren\'t you sweet? I\'ll play with you. ^_^\"\n\nPlay as the Black Cat Desi \"Miss Fortune\" Ethica?"
    menu:
        char "%(diag)s"
        "Yes":
            jump ch_00
        "No":
            jump char_select
I'm rather new to RenPy and Python, so there's no doubt a simple solution I'm missing out on.
Thanks in advance!
Last edited by jacktim on Mon Apr 17, 2017 12:13 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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:

Re: String tags in string variables.

#2 Post by PyTom »

Try using the new-form substitutions.

char "[diag]"
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

jacktim
Newbie
Posts: 2
Joined: Tue Jun 10, 2008 11:02 am
Contact:

Re: String tags in string variables.

#3 Post by jacktim »

Yeah, I just figured that one out. Thanks much!

I knew it was going to be something silly.

Post Reply

Who is online

Users browsing this forum: No registered users