recolor with hex

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
User avatar
deliciumartis
Regular
Posts: 30
Joined: Mon Feb 09, 2015 11:32 am
Location: shadowland
Contact:

recolor with hex

#1 Post by deliciumartis » Sun Apr 12, 2015 8:00 pm

I'm trying to pass a variable into an image to perform a recolor based on a set variable.

If I try to do this with an init statement:

Code: Select all

init -1 python:
    class BaseCharacter():
        
        def __init__(self, name, race, auraR, auraG, auraB, auratype, aurastrength)
            self.name = name
            self.race = race
            self.auraR= auraR
            self.auraG= auraG
            self.auraB= auraB
            self.auratype = auratype
            self.aurastrength = aurastrength
and then use a python statement to set them after character creation based on variables selected, and working on the screen in image buttons:

Code: Select all

python:
        player = BaseCharacter(
                name = Player,
                race = PlayerRace,
                auraR = PlayerAuraR,
                auraG = PlayerAuraG,
                auraB = PlayerAuraB,
                auratype = PlayerAuraType,
                aurastrength = PlayerAuraStrength,
            )
the variables show up and work properly up to when I try to pass them into the image:

Code: Select all

image playeraura = LiveComposite((151,200),
            (0, 0), ConditionSwitch(
                "player.race == 'Human'", ConditionSwitch(
                        "player.auratype == 'mole'", im.Recolor("auramole.png", player.auraR , player.auraG , player.auraB, player.aurastrength),
                        "player.auratype == 'bunny'", im.Recolor("aurabunny.png", player.auraR , player.auraG , player.auraB, player.aurastrength),
Which only returns an error telling me the name player isn't defined. So I tried defining them:

Code: Select all

define player = ("Player", "PlayerRace",  PlayerAuraR,  PlayerAuraG,  PlayerAuraB, "PlayerAuraType", PlayerAuraStrength)
and get told that PlayerauraR isn't a defined name.
I've tried putting them into an init block, but then they can't seem to take any changes.
I'm a little stumped here. I've found costly workarounds but they tend to bog down the runtime.
In the end the only solution I could find to make the function do what it needed to do was to scrap the transparency system and make them a set alpha and use a different color string like so:

Code: Select all

    image playeraura = LiveComposite((151,200),
            (0, 0), ConditionSwitch(
                "player.race == 'Human'", ConditionSwitch(
                    "player.auracolor == 'GoldenDream'", ConditionSwitch(
                        "player.auratype == 'mole'", im.Recolor("auramole.png", 240 ,206 , 44, 120),
                        "player.auratype == 'bunny'", im.Recolor("aurabunny.png", 240 , 206 , 44, 120),
Which would be fine, if not for the 30 point personality background the writer came up with that comes up with a possible 300 colors for each of the 26 zodiacs this fantasy world has (two moons with a lunar calendar). So, I guess in my long winded way I'm asking, does anyone have any thoughts on anything I might have missed as possible solutions?
"What bothers me is, nothin' does."
--The dixie flatline

User avatar
deliciumartis
Regular
Posts: 30
Joined: Mon Feb 09, 2015 11:32 am
Location: shadowland
Contact:

Re: recolor with hex

#2 Post by deliciumartis » Mon Apr 13, 2015 2:11 am

Not the solution I was hoping for, but I was able to work out a work around using renpy.displayable and setting up various sub displayables to handle the load with less stress on runtime.
"What bothers me is, nothin' does."
--The dixie flatline

Post Reply

Who is online

Users browsing this forum: _ticlock_