[Solved]Attributes messed up by Mouse Wheel

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
Killverin
Newbie
Posts: 10
Joined: Wed May 25, 2022 4:45 pm
Contact:

[Solved]Attributes messed up by Mouse Wheel

#1 Post by Killverin » Thu Jun 02, 2022 10:40 pm

I don't want to disable it, but the scroll wheel doesn't roll back the in-game time, and if you roll back to a screen where attributes were being adjusted, it doubles down on the changes instead of reversing them, same with the time. I always thought the scroll wheel was a full-auto undo button, but that's not the case here at least. How should I approach this issue?
Last edited by Killverin on Fri Jun 03, 2022 9:23 am, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
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: Attributes messed up by Mouse Wheel

#2 Post by PyTom » Fri Jun 03, 2022 12:29 am

The most likely problem is that the object with the attribute is created in an init block. Only objects reachable from variables that are changed after the end of the init phase are saved, and only those variables are changed.

Chances are, what you need to do is to create your object in a default statement. For example:

Code: Select all

init python:
    class GameState: 
         def __init__(self):
              self.time = 0
         def bump_time(self):
              self.time = self.time + 1

default state = GameState()
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

Killverin
Newbie
Posts: 10
Joined: Wed May 25, 2022 4:45 pm
Contact:

Re: Attributes messed up by Mouse Wheel

#3 Post by Killverin » Fri Jun 03, 2022 9:22 am

Thank you! I was doing that, yeah. I'm glad the solution is so straight forward. :lol:

Post Reply

Who is online

Users browsing this forum: No registered users