Trouble with text variables [Solved]

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
pancito
Newbie
Posts: 4
Joined: Sat May 10, 2014 8:51 pm
Location: In my happy place...
Contact:

Trouble with text variables [Solved]

#1 Post by pancito » Sat May 10, 2014 9:32 pm

This should be simple, but I can't find it anywhere. I'm just starting out, and I'm prolly doping something totally stupid, so there's that as well... So frustrated I actually joined the forum. :D

Here's the code, totally generic.

Code: Select all

# Declare characters used by this game.
define e = Character('Eileen', color="#c8ffc8")
$ age1 = 18
$ age2 = "eighteen"
$ age3 = 'eighteen'

# The game starts here.
label start:

    e "You've created a new Ren'Py game."

    e "I'm [age3] years old."

    return
I've tried all three of the variables but all error out. Here's the traceback.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 17, in script
    e "I'm [_age3] years old."
KeyError: u'_age3'

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/script.rpy", line 17, in script
    e "I'm [_age3] years old."
  File "C:\Users\me\Desktop\Games\renpy-6.17.6-sdk\renpy\ast.py", line 558, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\Users\me\Desktop\Games\renpy-6.17.6-sdk\renpy\exports.py", line 925, in say
    who(what, interact=interact)
  File "C:\Users\me\Desktop\Games\renpy-6.17.6-sdk\renpy\character.py", line 808, in __call__
    what = what_pattern.replace("[what]", sub(what, translate=translate))
  File "C:\Users\me\Desktop\Games\renpy-6.17.6-sdk\renpy\substitutions.py", line 223, in substitute
    s = formatter.vformat(s, (), kwargs)
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 549, in vformat
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 571, in _vformat
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 632, in get_field
  File "/home/tom/ab/x64lucid-deps/install/lib/python2.7/string.py", line 591, in get_value
KeyError: u'_age3'

Thanks for any help!
Last edited by pancito on Sat May 10, 2014 10:11 pm, edited 1 time in total.

briannavon
Miko-Class Veteran
Posts: 505
Joined: Mon Mar 26, 2012 6:51 pm
Location: Philadelphia
Contact:

Re: Trouble with text variables

#2 Post by briannavon » Sat May 10, 2014 9:35 pm

They are in the wrong place. Variables go after label start. :D
Join Me At LivingGame Productions!

http://livinggameproductions.blogspot.com/

pancito
Newbie
Posts: 4
Joined: Sat May 10, 2014 8:51 pm
Location: In my happy place...
Contact:

Re: Trouble with text variables

#3 Post by pancito » Sat May 10, 2014 9:45 pm

See! I told you it was simple. Thanks briannavon! And just for completeness, any one of those three formats will work (either single or double quotes) as long as it is in the right place.

Post Reply

Who is online

Users browsing this forum: bubblepasta, noeinan