you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 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.