Page 1 of 1

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

Posted: Thu Jan 11, 2018 4:52 pm
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!

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

Posted: Thu Jan 11, 2018 5:10 pm
by Ocelot

Code: Select all

$ yourcards_text = ', '.join(yourcards)
"Your cards are [yourcards_text]"

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

Posted: Thu Jan 11, 2018 11:33 pm
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.

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

Posted: Fri Jan 12, 2018 9:55 am
by wtgamer
Thanks! That works.

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

Posted: Fri Jan 12, 2018 12:19 pm
by Ocelot
a class instance would just print a pointer to a memory address
Unless you define __str__(self) for your class