Finding color of a character object with Python

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
Xenocartographer
Regular
Posts: 26
Joined: Fri Aug 31, 2012 12:49 pm
Contact:

Finding color of a character object with Python

#1 Post by Xenocartographer » Sat Feb 02, 2013 2:10 pm

I'm writing some code for someone else's project. In said code, I need to overwrite the default "say" statement to behave somewhat differently, as explained at http://www.renpy.org/wiki/renpy/doc/ref ... Statements . It's mostly done, but I need to make the displayed text match the character's color, as passed to the Character function. I can find the object representing the character, but I don't know how to find its color. I've looked at character.py but didn't see anything obvious; I've also tried some obvious guesses, like derp.color and derp.what_color, but didn't have any luck that way either (as you'd expect). If it clarifies anything, here's a code fragment:

Code: Select all

renpy.show("speech temporary", layer="transient", what=Text(what), color=who.color)
(The who.color part is the incorrect part that I need to change, ofc.)

Kinsman
Regular
Posts: 130
Joined: Sun Jul 26, 2009 7:07 pm
Location: Fredericton, NB, Canada
Contact:

Re: Finding color of a character object with Python

#2 Post by Kinsman » Sat Feb 02, 2013 2:26 pm

Ren'py tucks away display information into various dictionaries inside each Character object.

Code: Select all


        # This is initializing code for a Character in character.py
        for k in list(properties):

            if "_" in k:
                prefix, suffix = k.split("_", 1)

                if prefix == "show":
                    self.show_args[suffix] = properties[k]
                    continue
                elif prefix == "cb":
                    self.cb_args[suffix] = properties[k]
                    continue
                elif prefix == "what":
                    self.what_args[suffix] = properties[k]
                    continue
                elif prefix == "window":
                    self.window_args[suffix] = properties[k]
                    continue
                elif prefix == "who":
                    self.who_args[suffix] = properties[k]
                    continue
In your case, try

Code: Select all

who.who_args["color"]
Flash To Ren'Py Exporter
See the Cookbook thread

Xenocartographer
Regular
Posts: 26
Joined: Fri Aug 31, 2012 12:49 pm
Contact:

Re: Finding color of a character object with Python

#3 Post by Xenocartographer » Sat Feb 02, 2013 4:39 pm

Ah, thanks, worked perfectly.

Post Reply

Who is online

Users browsing this forum: No registered users