[SOLVED] Animate variables when they are updated?
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.
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.
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
[SOLVED] Animate variables when they are updated?
Hello experts of Ren'py
I've been wondering for a while now about the way I could make a variable on the HUD blink/transform/whatever (for a sec) after the player has a made a choice and the variable has changed? Couldn't find anything on the forums... I'm using menu arguments (to highlight variables that are going to be changed) if that helps.
Any help would be appreciated. Thanks!
I've been wondering for a while now about the way I could make a variable on the HUD blink/transform/whatever (for a sec) after the player has a made a choice and the variable has changed? Couldn't find anything on the forums... I'm using menu arguments (to highlight variables that are going to be changed) if that helps.
Any help would be appreciated. Thanks!
Last edited by OrsonDeWitt on Fri Nov 20, 2020 5:35 pm, edited 3 times in total.
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: Animate variables when they are updated?
should be a good example.
Code: Select all
default var = 1
screen something():
textbutton "increment" action SetVariable("var", var + 1) align (0.5, 0.5)
text str(var):
align (0.5, 0.25)
at animation_update
transform animation_update():
on update:
alpha 0.0
easein 0.25 alpha 1.0
label start:
call screen something
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
Re: Animate variables when they are updated?
Thanks, hell_oh_world! But unfortunately it does not seem to do anything. I've tried different effects and none of them fires, the variable just changes as always does with no effect whatsoever. :/
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
Re: Animate variables when they are updated?
Still haven't found a solution
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: Animate variables when they are updated?
I don't know what you did. But my code works exactly well iirc. I even tried it before, so maybe you're missing something? Perhaps an issue with the Ren'Py version you're using? Not sure.
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
Re: Animate variables when they are updated?
You're right, it works! I was trying to test it like this:hell_oh_world wrote: ↑Sun Oct 18, 2020 3:00 pm I don't know what you did. But my code works exactly well iirc. I even tried it before, so maybe you're missing something? Perhaps an issue with the Ren'Py version you're using? Not sure.
Code: Select all
screen test():
vbox:
textbutton "increment" action SetVariable("svar", svar + 1)
text str(svar):
align (0.5, 0.25)
at animation_update
Thanks a lot for your help!
I have just one problem with this, the animation activates whenever I click or hover over any button (that has a tooltip). I guess "on update" takes the update in Ren'py as a condition, not the update of the variable itself?
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
Re: Animate variables when they are updated?
vbox does not prevent transform from happening. It does not work because on update event is not triggered for screen text str(svar). on update event is triggered for direct children of the screen test.OrsonDeWitt wrote: ↑Tue Nov 17, 2020 4:06 pm And would never for the life of mine think that vbox would prevent transform from happening.
For example, the transform will be triggered in this case (for all children):
Code: Select all
screen test():
vbox:
at animation_update
vbox:
textbutton "increment" action SetVariable("svar", svar + 1)
text str(svar):
align (0.5, 0.25)
Code: Select all
screen test():
vbox:
vbox:
at animation_update
textbutton "increment" action SetVariable("svar", svar + 1)
text str(svar):
align (0.5, 0.25)
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
Re: Animate variables when they are updated?
Why is it triggered whenever I hover over UI elements in HUD screen then...?
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
Re: Animate variables when they are updated?
Do you mean on hover and on idle statements in transform? On update is triggered for direct children and each of them updated its content/children without passing on update to each individual element. On hover and on idle statements work differently. They are triggered for elements that gains/loses focus.OrsonDeWitt wrote: ↑Tue Nov 17, 2020 5:22 pm Why is it triggered whenever I hover over UI elements in HUD screen then...?
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
Re: Animate variables when they are updated?
No, I use the code of hell_oh_world in a separate screen while I also have HUD screen on top that is opened by clicking a button. So whenever I "open" HUD and whenever I hover over any of its elements (textbuttons and imagebuttons), the code of hell_oh_world gets activated and the blinking happens even though the variable is not being updated._ticlock_ wrote: ↑Tue Nov 17, 2020 11:14 pmDo you mean on hover and on idle statements in transform? On update is triggered for direct children and each of them updated its content/children without passing on update to each individual element. On hover and on idle statements work differently. They are triggered for elements that gains/loses focus.OrsonDeWitt wrote: ↑Tue Nov 17, 2020 5:22 pm Why is it triggered whenever I hover over UI elements in HUD screen then...?
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
Re: Animate variables when they are updated?
'On update' is triggered every time the screen is updated. It is not directly related to the variable svar or the screen 'test' itself. HUD screen can also trigger 'on update' for screen 'test'.
I am not quite sure why it is triggered when you hover over elements of HUD screen. I believe you have an action, that is run when the element gains focus. That can result in triggering 'on update' as well.
I am not quite sure why it is triggered when you hover over elements of HUD screen. I believe you have an action, that is run when the element gains focus. That can result in triggering 'on update' as well.
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
Re: Animate variables when they are updated?
Does it mean that there is no way to do what I had described in the post?_ticlock_ wrote: ↑Wed Nov 18, 2020 12:44 pm 'On update' is triggered every time the screen is updated. It is not directly related to the variable svar or the screen 'test' itself. HUD screen can also trigger 'on update' for screen 'test'.
I am not quite sure why it is triggered when you hover over elements of HUD screen. I believe you have an action, that is run when the element gains focus. That can result in triggering 'on update' as well.
Here's how my imagebuttons that open HUD are defined:
Code: Select all
idle "Gods_screen.png" action Hide("gods_screen", transition=dissolve)
idle "Gods_screen.png" action Show("gods_screen", transition=dissolve)
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
Re: Animate variables when they are updated?
Am I right that you want the transform to happen only when the variable svar is changed? And not when you click on other elements that can result in 'update' event of the screen?
One option to do it is to use another variable to track if svar is changed. You can modify your screen test like this:
Screen variable update_svar tracks if you need to apply transform animation_update or not.
One option to do it is to use another variable to track if svar is changed. You can modify your screen test like this:
Code: Select all
screen test():
default update_svar = False
textbutton "increment" action SetVariable("svar", svar + 1), SetScreenVariable("update_svar", True)
if update_svar:
$ update_svar = False
text str(svar):
align (0.5, 0.25)
at animation_update
else:
text str(svar):
align (0.5, 0.25)
Screen variable update_svar tracks if you need to apply transform animation_update or not.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Contact:
Re: Animate variables when they are updated?
Alternatively, you can just do this, short but a neat trick, passing variables around atl makes them dynamic on each interaction restart.
Code: Select all
transform animation_update(var): # make an argument where we can receive the variable.
alpha 0.0
easein 0.25 alpha 1.0
default var = 1
screen something():
vbox:
align (0.5, 0.25)
textbutton "increment" action SetVariable("var", var + 1) align (0.5, 0.5)
text str(var):
at animation_update(var) # then just pass the var for no reason...
Last edited by hell_oh_world on Fri Nov 20, 2020 1:24 pm, edited 1 time in total.
-
- Regular
- Posts: 45
- Joined: Thu Dec 06, 2018 3:23 am
- Contact:
Re: Animate variables when they are updated?
Ah, amazing! Thank you!_ticlock_ wrote: ↑Thu Nov 19, 2020 4:31 pm Am I right that you want the transform to happen only when the variable svar is changed? And not when you click on other elements that can result in 'update' event of the screen?
One option to do it is to use another variable to track if svar is changed. You can modify your screen test like this:
Code: Select all
screen test(): default update_svar = False textbutton "increment" action SetVariable("svar", svar + 1), SetScreenVariable("update_svar", True) if update_svar: $ update_svar = False text str(svar): align (0.5, 0.25) at animation_update else: text str(svar): align (0.5, 0.25)
Screen variable update_svar tracks if you need to apply transform animation_update or not.
I cannot reply to messages anymore.
> Your IP has been blocked because it is blacklisted.
> Your IP has been blocked because it is blacklisted.
Who is online
Users browsing this forum: Semrush [Bot]