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.
-
smollvrn
- Newbie
- Posts: 14
- Joined: Sun Mar 14, 2021 3:24 pm
-
Contact:
#1
Post
by smollvrn » Sun Mar 14, 2021 3:56 pm
hello, how to call dimensional dictionary with variables in say one line ????
Code: Select all
$ my_dict = {
"key": ("0", "1"),
"key1": ("0", "1")
}
$b = key
$i = 0
# work
a "[my_dict[key][0]]"
$c = my_dict[b][i]
a "[c]"
#doesn't work
a "[my_dict[b][i]]"
-
zmook
- Veteran
- Posts: 421
- Joined: Wed Aug 26, 2020 6:44 pm
-
Contact:
#2
Post
by zmook » Sun Mar 14, 2021 5:23 pm
The documentation for string substitution/interpolation is here:
https://www.renpy.org/doc/html/text.htm ... ating-data
If I am reading it right, substitution of dictionaries isn't fully supported, just "simple variables" and "fields and components of tuples". At any rate, the extra layer of square brackets is confusing it. I'd suggest either converting my_dict to a class so you can use field notation (ie, "The magic number is [my_data.key1[0]]"), or if that's impractical, you can force full python substitution like this:
Code: Select all
$ a( "the number of the counting is %s" % my_dict[b][i] )
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Users browsing this forum: Google [Bot]