Search code examples
colorsrenpy

Working with Ren.Py (Python), Syntax Errors


I thought it would be nice for the player to pick their color. My first attempt was:

define K = Character("Keeper")
define favcolor = (color="#ffffff")
define p1 = Character("Player1", (favcolor))


label start:
    K "Got a favorite color?"
    menu:
        "Blue":
            $ favcolor = color="#0033ff"
            jump Style
        "Red":
            $ favcolor = color="#ff3300"
            jump Style
        "Yellow":
            $ favcolor = color="#ffcc00"
            jump Style


label Style:
    p1 "Now I be styl'n"

but I get a syntax error. Likely because I have no idea what I'm doing.


Solution

  • It appears that an update has changed how this works. However, the following does work:

    define K = Character("Keeper")
    define E = Character('Eric', dynamic=True, color="#ffffff")
    
    ## The game starts here.
    
    label start:
    
        K "Got a favorite color?"
        menu:
            "Blue":
                $ E = Character('Eric', color="#0000ff")
                jump Style
            "Red":
                $ E = Character('Eric', color="#ff3300")
                jump Style
            "Yellow":
                $ E = Character('Eric', color="#ffcc00")
                jump Style
    
    
    label Style:
        E "Now I be styl'n"
    

    I'll update the answer if, and when, I can find a better workaround.