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.
-
thorskin
- Newbie
- Posts: 5
- Joined: Sat Oct 15, 2022 9:13 pm
-
Contact:
#1
Post
by thorskin » Sat Oct 15, 2022 9:36 pm
I have a complex scene with different characters who can have different poses and clothing
For each character I create a string with the image name (png file)
and use :
Code: Select all
label start :
$ index = 0
while index < 10
show expression thestring[index]
$ index = index + 1
Now I want to add a tag to each character
Code: Select all
define mytags = ["girl1","girl2",.... ] # actually created in a while loop
label start :
$ index = 0
while index < 10
show expression thestring[index] as mytags[index]
$ index = index + 1
But I don't find the correct syntax to do it.
ie how to convert a string into a tag to use as parameter for the as transform.
Last edited by
thorskin on Sun Oct 16, 2022 6:58 am, edited 1 time in total.
-
Ocelot
- Eileen-Class Veteran
- Posts: 1882
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#2
Post
by Ocelot » Sun Oct 16, 2022 3:51 am
< < insert Rick Cook quote here > >
-
thorskin
- Newbie
- Posts: 5
- Joined: Sat Oct 15, 2022 9:13 pm
-
Contact:
#3
Post
by thorskin » Sun Oct 16, 2022 6:54 am
Thanks,
$ renpy.show(thestring[index], tag = mytags[index])
I already tried this syntax but was getting an error : name 'mytags[index]' is not defined
and I thought my syntax was wrong.
But the error was elsewhere : the mytags array was empty when this line was called.
-
thorskin
- Newbie
- Posts: 5
- Joined: Sat Oct 15, 2022 9:13 pm
-
Contact:
#4
Post
by thorskin » Sun Oct 16, 2022 7:14 am
My first attempt was :
$ renpy.show(thestring[index], tag = "girl[index]")
thinking that interpolation would work and that the tags would be "girl1","girl2" ...
but actually interpolation does not work here and the tags were always "girl[index]"
and I was only seeing the last one in the list.
actually the easier way to do what I want is :
$ renpy.show(thestring[index], tag = "girl" + str(index) )
anyway, thanks for the answer
-
Ocelot
- Eileen-Class Veteran
- Posts: 1882
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#5
Post
by Ocelot » Sun Oct 16, 2022 11:58 am
RenPy interpolation works only for RenPy statements. If you use Python (in Python block, Python one-liners or Python expressions) you need to perform Python formatting.
< < insert Rick Cook quote here > >
Users browsing this forum: Google [Bot], Majestic-12 [Bot]