Ren'Py Change "what" and "who" colors

PlayWithMe

New Member
Feb 5, 2019
14
33
Hey, I am having a bit of trouble with this, so what I want to do is allow the user to customize the color of the text and name. That should be done on the Preferences screen, so each (important) character will have 6 bars, 3 for what and 3 for who. being Red, Green, and Blue first I tried to do it with persistent:

Code:
init -4 python:
    if persistent.color_ed_whatR is None:
        persistent.color_ed_whatR = 255
    if persistent.color_ed_whatG is None:
        persistent.color_ed_whatG = 0
    if persistent.color_ed_whatB is None:
        persistent.color_ed_whatB = 255
      
    if persistent.color_ed_whoR is None:
        persistent.color_ed_whoR = 0
    if persistent.color_ed_whoG is None:
        persistent.color_ed_whoG = 0
    if persistent.color_ed_whoB is None:
        persistent.color_ed_whoB = 0
  
init -3 python:
    #What ?
    if persistent.color_ed_what is None:
        persistent.color_ed_what = (persistent.color_ed_whatR, persistent.color_ed_whatG, persistent.color_ed_whatB, 255)
    #who
    if persistent.color_ed_who is None:
        persistent.color_ed_who = (persistent.color_ed_whoR, persistent.color_ed_whoG, persistent.color_ed_whoB, 255)
then on the screen:

Code:
bar value VariableValue(persistent.color_ed_whatR, 255):
    xalign 1.0 yalign 0.0
    xmaximum 400
    ymaximum 15
    left_bar Frame("left_bar", 10, 0)
    right_bar Frame("right_bar", 10, 0)
    left_gutter 0
    right_gutter 0
    thumb "thumb_bar"
You don't have permission to view the spoiler content. Log in or register now.

It is probably easy but yeah...
I need some help plz.

NOTE: 2nd time that I edit the question.
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
Code:
I'm sorry, but an uncaught exception occurred.

[...]
  File "renpy/common/00barvalues.rpy", line 277, in get_adjustment
    value = getattr(self.object, self.field)
TypeError: getattr(): attribute name must be string
Well, the error say it all, and a look at confirm what the error message said :
Code:
variable
    A string giving the name of the variable to adjust.
You need to pass the name of the variable to VariableValue, not directly its value.
 
  • Like
Reactions: PlayWithMe

PlayWithMe

New Member
Feb 5, 2019
14
33
Thanks.
Then I ask something, then I see the answer I fell much stupid. Anyways

Code:
  File "game/script/in_game_screens.rpy", line 460, in execute
    bar value VariableValue("persistent.color_ed_whatR", 255):
  File "D:\Programas\Renpy 7.3.2\renpy-7.3.2-sdk\renpy\sl2\sldisplayables.py", line 242, in sl2bar
    return renpy.display.behavior.Bar(range, value, width, height, vertical=False, **properties)
  File "D:\Programas\Renpy 7.3.2\renpy-7.3.2-sdk\renpy\display\behavior.py", line 1619, in __init__
    adjustment = value.get_adjustment()
  File "renpy/common/00barvalues.rpy", line 277, in get_adjustment
    value = getattr(self.object, self.field)
AttributeError: 'StoreModule' object has no attribute 'persistent.color_ed_whatR'
Do I have to do something else to use persistent files?
As I said if I alter on the initial declaration, then delete persistent files changes the color during the game.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,302
15,172
Code:
AttributeError: 'StoreModule' object has no attribute 'persistent.color_ed_whatR'
My bad, I followed what you already wrote, without taking care of the fact that you worked with a persistent value. VariableValue is for literal variable, while you're working with an attribute of the persistent object. What you need to use is :
Code:
bar value FielValue(persistent, "color_ed_whatR", 255):
    [...]
 
  • Like
Reactions: PlayWithMe

PlayWithMe

New Member
Feb 5, 2019
14
33
My bad, I followed what you already wrote, without taking care of the fact that you worked with a persistent value. VariableValue is for literal variable, while you're working with an attribute of the persistent object. What you need to use is :
Code:
bar value FielValue(persistent, "color_ed_whatR", 255):
    [...]
Thanks, I will try, I tried also without persistent and didn't give an error but then I quit the game and reopen it goes back to the initial value. I don't know if I will use that but how it works? (I mean save a value outside of a save in non-persistent), In practice what would be the difference?

And since I am where already to do something like what is on the attachments (change between the tabs on the right is, in each button call a different screen right? (just yes or no, I want to try to do it myself).

And for last I don't want to go back then I click on the right button on the mouse, because I use the "return" button to change something, can I cancel it and/or do something the I click it

1st the screen that show every character:
You don't have permission to view the spoiler content. Log in or register now.

The screen that shows the info then I click on the character. What happaned has then I go for page 2 for the 1 character and then clicked on the RMB and tried go to the second and it has only one image it brokes. The 3 first line don't let that happen but if as like 3 images it starts at the second, and if I put it always as 0 it does go back and forth.
You don't have permission to view the spoiler content. Log in or register now.

I am abusing your generosity, but thanks for the help.