SetVariable isn't instant

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
DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

SetVariable isn't instant

#1 Post by DesertFox »

I'm having an issue with how quickly a variable sets. The idea is to let the player select between two color schemes. However, the styles and variables don't set with one click on either button, at least to begin with. There's some middling state, where some elements are orange and some are green. You have to double click to get what you want. Any suggestions as to why the variable doesn't 'set' properly?

Code: Select all

screen pretheme():
    textbutton _("Green") action [StylePreference("color", "#2CD11B")], [SetVariable("orange", False)], [SetVariable("persistent.orange", False)] etc.

Code: Select all

init -2 python:
    renpy.register_style_preference("color", "#2CD11B", style.default, "color", "#2CD11B") etc.

Code: Select all

image monitor = ConditionSwitch("persistent.orange", "monitor1",
    "True", "monitor2")

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: SetVariable isn't instant

#2 Post by PyTom »

Is anything conditional on orange or persistent.orange? You may need to set those before calling StylePreference. A lot depends on what the actual conditions are.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

Re: SetVariable isn't instant

#3 Post by DesertFox »

PyTom wrote:Is anything conditional on orange or persistent.orange? You may need to set those before calling StylePreference. A lot depends on what the actual conditions are.
Those images using Conditionswitch are. There are several images using the same kind of thing. In the above example, monitor1 and monitor2 are other defined images, with the Conditionswitch choosing between them based on the persistent.orange variable. Then in that prescreen, there's also the textbutton to choose to set orange and persistent.orange to True, I just didn't include it.

Also set is the following:

Code: Select all

init -2 python:
    orange = False
    persistent.orange = orange

philat
Eileen-Class Veteran
Posts: 1912
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: SetVariable isn't instant

#4 Post by philat »

A list of actions is run in order. I think what PyTom means is try putting SetVariable before StylPreference and see if that fixes the problem.

DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

Re: SetVariable isn't instant

#5 Post by DesertFox »

No that doesn't fix the issue. There's still a delay in that the coloring of the text and buttons (sometimes the image) doesn't set with just one click. Since it's the text sometimes too, that suggests there's an issue with StylePreference as well.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: SetVariable isn't instant

#6 Post by PyTom »

Can you put together a replication so I can look at this?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

Re: SetVariable isn't instant

#7 Post by DesertFox »

Here's a replication.
Last edited by DesertFox on Sun Oct 11, 2015 11:51 pm, edited 2 times in total.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: SetVariable isn't instant

#8 Post by gas »

You can set the images as a part of the style definition, like a frame or window background property.
I think this is more consistent, and I applied the same to let the player choose the whole interface style between 5 colours. No bugs at all.
The choice get saved as a persistent value. So if you choose the red interface, next time you launch the game it start with the red one. If you load a game, it load the style definitions of that game.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

DesertFox
Regular
Posts: 196
Joined: Sun Jul 28, 2013 1:29 pm
Completed: Over The Hills And Far Away
Projects: My Little Dictator
Organization: WarGirl Games
Contact:

Re: SetVariable isn't instant

#9 Post by DesertFox »

gas wrote:You can set the images as a part of the style definition, like a frame or window background property.
I think this is more consistent, and I applied the same to let the player choose the whole interface style between 5 colours. No bugs at all.
The choice get saved as a persistent value. So if you choose the red interface, next time you launch the game it start with the red one. If you load a game, it load the style definitions of that game.
Considering I'm using the overlay here, how would I apply a style to that image?

Post Reply

Who is online

Users browsing this forum: Bing [Bot], snotwurm