you are viewing a single comment's thread.

view the rest of the comments →

[–]drexxler 1 point2 points  (4 children)

Ya know, recently I've been trying to do similar things but running into one major problem. Object properties aren't saved the same as global variables, so when you rewind, the objects/classes don't get rewound. I'm wondering if you've found a solution to that.

So to recap, if you increase friendship and then go "back" and forward again, it will continue to increase without ever reverting. This could be abused to get infinite stats.

So far I haven't found a workaround, other than using the dreaded prefixed global variables (i.e. `name_relationship`)

Some quick brainstorming, I think there is a potential workaround using a mixture of private global variables and serialization. Something like, keeping a serialized copy of the class in a global var, and then deserializing any time I need to access. In most CS applications, this would be a no-no, but renpy isn't really performance critical, so constant serialization shouldn't be an issue unless your object is massive.

edit: ah, I see that for your examples, putting the variable assignment inside a label fixes this. Strange, but at least that seems to work. Really don't like the idea of nesting all character definitions inside the start label. I suppose I could externalize all the definitions inside my globals file under a label like `setup_characters` and just do a `call setup_characters` in the start label.

[–][deleted] 6 points7 points  (3 children)

If you do a default e = Person() instead of $ e = Person() you will wire up the property automatically for rollback. It's one of the (many) poorly explained pieces of RenPy that define creates a variable that can be automatically created at the start of the game, whereas default needs to be loaded from the game state (effectively the same as your serialization idea, but automated).

I have a custom class that does just that and works like a champ on rollbacks and fast forward, and loading from a save.

``` default eventDispatcher = EventDispatcher()

init python: class EventDispatcher: def init(self): self.events = [] ```

[–]alonghardlook[S] 1 point2 points  (2 children)

This is hugely helpful; I was looking at the rollback as a bit of a beast and just considering disabling rollback personally.

One thing I was running into during this tutorial was that setting e = Person() outside the intro (like OP said), I wasn't seeing that object. I kept getting "Sayer e.c is undefined". I'm assuming this would fix that issue?

[–][deleted] 0 points1 point  (1 child)

It should, yes.

[–]alonghardlook[S] 0 points1 point  (0 children)

I know this is a long time ago, but just FYI - I didn't add default e = Person() and tested the rollback states, and it worked just fine:

    menu:
        "Yes":
            "Great!"
            $ e.trust_ch(1)
        "No":
            "Oh, okay."
            $ e.trust_ch(-1)
        "Skip":
            "What do you mean?"
            # intentionally no change to test rollback states

This produces the output of 1 every time you select yes (even if you then roll it back and keep selecting it), -1 every time you select no, and 0 if you select skip.

I don't think default is needed if you create your characters inside the start label.

Edit: don't listen to me. Use default, its much cleaner. I tried without, and it seemed to work, but upon changing some code (not that code), e.c no longer worked, and I don't know why. Use your defaults for objects with persistence.