- Sep 30, 2019
- 225
- 980
Hey guys, wonder if you can help me. I used to be a decent beginner programmer so I only sorta know how to program (lol). The VN I'm working on has a couple thousand images and I make heavy use of transitions but I fear the transitions might get on the nerves of some people. So the solution I thought up was to create a Transition Speed slider in preferences and it works for the most part:
I can change and retrieve the value of the slider no problem. The problem I'm running into is that the Dissolve object is being created at the start of the program and the dissolve duration is being taken from what the value of persistent.transition_speed is at the start of the program. This means if someone were to change the slider in preferences for Transition Speed, it would only take effect once the app is restarted. I want the changes to take place instantaneously.
The solution I thought I had was to use an action, since FieldValue supports an action call, to create a new Dissolve object for dissolveM:
The problem with this code is that I'm getting all sorts of weirdness going on because I think the action is being called before the value for persistent.transition_speed is changed. Not only that, I'm not even sure how many times it's calling the action, whether the action is only called when the slider has stopped moving or whether an action is called for every frame that the slider is moved. Another possible solution I thought of is to have every dissolveM call check to see if a flag is set for transition speed being changed, if so, create a new Dissolve object with the new transition_speed value. But I don't quite understand the crisscross of Renpy and python so I don't know how to create a function for that. Is there a solution I'm missing here?
Python:
## Extra code for Preferences screen goes here
##
label _("Transition Speed")
bar value FieldValue(persistent, 'transition_speed', 2.0, max_is_zero=False, offset=0, step=.2) xmaximum 525 alt "Transition Speed"
## End Preferences screen code
## Create custom transition to use slider speed
define dissolveM = Dissolve(0.5 * persistent.transition_speed)
default persistent.transition_speed = 1.0
## How I call the custom transition in the script
scene s001_i001 with dissolveM
The solution I thought I had was to use an action, since FieldValue supports an action call, to create a new Dissolve object for dissolveM:
Python:
label _("Transition Speed")
bar value FieldValue(persistent, 'transition_speed', 2.0, max_is_zero=False, offset=0, step=.2, action= SetVariable("dissolveM", Dissolve(0.5 * persistent.transition_speed))) xmaximum 525 alt "Transition Speed"