Embedding variables in Text not working

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
SwitchGameDev
Newbie
Posts: 5
Joined: Fri May 13, 2016 6:08 pm
Projects: NytWalk
Organization: Switch
Tumblr: SwitchGameDev
Skype: switchgamedev
itch: switchgamedev
Contact:

Embedding variables in Text not working

#1 Post by SwitchGameDev » Fri May 13, 2016 6:39 pm

Correct me if I'm wrong, as I am sure I've been doing this correctly.

Code: Select all

$ sw = False

label start:
    $ Cornelia_Points = 0
    menu:
        "Choose whether you want to show swearing"
        "Enable swearing":
            $ sw = True
            "Swearing Enabled"
        "Disable swearing":
            $ h = "heck"
            $ sh = "shiz"
            "Swearing Disabled"
    if sw == True:
        "chicken is delicious"

    scene black
    "... [h]"
(Please ignore the part about chicken, I was testing something. That part works.)
I'm trying to give the user an option to enable or disable swearing. however when I try to embed the new variable name 'h' into narration via the brackets [], This message shows:

Image

I don't know what it is. %()s and %()d ( as well as %()r) Do not work either and they give a message like: u'unbound> in the narration box. I don't know what has happened. Funny thing is, it worked earlier all of a sudden when before that it had also been acting badly. It's like it worked only for a few minutes.

I thought that updating the engine would be a good idea, so I updated it a few minutes ago and still no luck. What is going on?

Neither config.new_substitutions: True will work, and on the topic of that- are "True" functions supposed to light up in green or something because sometimes (Not all the time as you can see above) mine stay black and are useless as if I might as well be saying Frog = green (Without green being defined or in speech marks) rather then Frog = True.

User avatar
Darim
Regular
Posts: 67
Joined: Sun Jun 21, 2015 4:17 pm
Organization: Setsuna Ken
Github: SetsunaKen
Location: Germany
Contact:

Re: Embedding variables in Text not working

#2 Post by Darim » Fri May 13, 2016 7:12 pm

try this:

Code: Select all

$ sw = False

label start:
    $ Cornelia_Points = 0
     "Choose whether you want to show swearing"
      menu:
        "Enable swearing":
            $ sw = True
            "Swearing Enabled"
        "Disable swearing":
            $ h = "heck"
            $ sh = "shiz"
            "Swearing Disabled"
     if sw == True:
         "chicken is delicious"

    scene black
    "... [h]"
Or with right indentation :)

Image

User avatar
theCodeCat
Regular
Posts: 62
Joined: Sun Sep 06, 2015 8:40 pm
Projects: Lucid9, Mystic Destinies: Serendipity of Aeons
Skype: theCodeCat
Contact:

Re: Embedding variables in Text not working

#3 Post by theCodeCat » Fri May 13, 2016 8:39 pm

Your "h" variable never gets defined when the user selects the "Enable swearing" option.
You need to have a line like

Code: Select all

$ h = "some swear word"
in there somewhere.

User avatar
SwitchGameDev
Newbie
Posts: 5
Joined: Fri May 13, 2016 6:08 pm
Projects: NytWalk
Organization: Switch
Tumblr: SwitchGameDev
Skype: switchgamedev
itch: switchgamedev
Contact:

Re: Embedding variables in Text not working

#4 Post by SwitchGameDev » Sat May 14, 2016 4:09 am

Thank you so much @theCodeCat you are right. That's so silly of me to not notice. Alas. It was late. That makes perfect sense.

@Darim thanks for your suggestion, and thanks for checking out my site :)

Post Reply

Who is online

Users browsing this forum: Google [Bot]