[Solved] How do you display list elements cleanly in Renpy say statements?

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
wtgamer
Newbie
Posts: 2
Joined: Thu Jan 11, 2018 4:34 pm
Contact:

[Solved] How do you display list elements cleanly in Renpy say statements?

#1 Post by wtgamer »

How do you get elements from a list to be displayed without square brackets and the u' prefix?

For example:

Code: Select all

default yourcards = ["Ace", "King", "Queen"]

label start:
	"Your cards are [yourcards]"
Comes back as:
Your cards are [u'Ace', u'King', u'Queen]

When what I would like is for it to come back as:
Your cards are Ace, King, Queen.

Note, I'd like them to display all in one line all at once, so this for example doesn't work either, as it requires a click through and lists each element one at a time:

Code: Select all

python:
	for c in yourcards:
		renpy.say(narrator, c)
Any help appreciated!
Last edited by wtgamer on Fri Jan 12, 2018 9:55 am, edited 1 time in total.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: How do you display list elements cleanly in Renpy say statements?

#2 Post by Ocelot »

Code: Select all

$ yourcards_text = ', '.join(yourcards)
"Your cards are [yourcards_text]"
< < insert Rick Cook quote here > >

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: How do you display list elements cleanly in Renpy say statements?

#3 Post by Milkymalk »

Long answer:

When you integrate a variable into your dialogue using brackets, its content is inserted exactly like the Python command print(variable) would output it. So you first need to format its content if it's something else than plain text or a number. While a list is still somewhat readable (like your example), a class instance would just print a pointer to a memory address. Always feed the say statement exactly what you need it to output.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

wtgamer
Newbie
Posts: 2
Joined: Thu Jan 11, 2018 4:34 pm
Contact:

Re: How do you display list elements cleanly in Renpy say statements?

#4 Post by wtgamer »

Thanks! That works.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2384
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: [Solved] How do you display list elements cleanly in Renpy say statements?

#5 Post by Ocelot »

a class instance would just print a pointer to a memory address
Unless you define __str__(self) for your class
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: Google [Bot]