Skip to content

Conversation

@saghm
Copy link

@saghm saghm commented Sep 17, 2025

I spent probably more time than I should have trying to figure out why I had trouble getting PersistentVars working, only to eventually realize that the issue was that I was overwriting it unconditionally each time the mod was loaded, which of course caused anything I wrote into it before to be thrown away. In retrospect, it was a bit obvious, but I do think it's a somewhat subtle issue for people to figure out, since it's pretty hard to distinguish between what's going on and what would happen with any global variable without special persistence semantics.

In case it might help future developers, I think updating the example snippet to check for nil before initializing would make sense. Presumably a decent number of people start out by copying the examples directly and then updating them as needed, and if I'm not missing something, it seems like the nil check would be pretty much required in order to actually do anything with the variables being persisted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant