-
-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement "resume reload" command. #2609
Conversation
94ce83d
to
3d8bd14
Compare
Sorry; I was looking back thru some of my other changes, and I realized that perhaps this can be implemented better in a way that doesn't require a new https://github.com/nesbox/TIC-80/pull/840/files It's getting late here tonight, but tomorrow I will update my patch to do this instead; the way I have it currently is probably more complicated than it needs to be. I thought that making |
When resuming, you can pass "reload" as the argument, which causes the cart's code to be reloaded before resuming the game. This allows for a much smoother iterative development style where you can pause the game, make changes, and see the effect of those changes without restarting the game. It does require some special handling in the cart to support saving state to a global and avoiding that state being reinitialized if it's already set; for instance: state = state or {x=25, y=100, shots={}} This implements it in a way that will be supported by any script that already supports eval.
3d8bd14
to
11bf8a4
Compare
OK, I've replaced the implementation with a much simpler one that works across every I think I will probably follow this up with a patch to make it so that Fennel will allow you to |
Also have you tested this with more dynamic runtimes and objects? Just because you redefine a class doesn't necessarily mean all the existing objects already instantiated will have that new API (or that they will have magically lost the old API). Ruby being one example where monkey patching is "additive". This can lead to weird edge cases and bugs. I wouldn't recommend this be merged as-is. |
I can imagine this causing problems on less dynamic runtimes; for instance if you have a language that refuses to allow you to redefine a class if the class is already defined. But this is a purely additive patch. Nothing will change unless users specifically go out of their way to request a reload. If you work in a language that doesn't allow reloads, you are unlikely to run the
It's been a few decades since I used Ruby, so maybe you can refresh my memory here about what could go wrong, but yes, the point of this patch is to allow additive changes to be made. It would certainly be very bad if it were triggered every time you ran In any case, developing games without this kind of functionality in Lua/Fennel is rather tedious, so I want to make sure it is exposed somehow. If you think moving it to an argument of the If necessary, it could also be implemented specifically in |
I may be thinking of Rails reloading where it first un-defines the classes, which is different than what you're doing here. So you could end up with two
That sounds like a reasonable safety-rail.
He seems open to many things, so wouldn't surprise me if he's into it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any problems with this PR, especially since it is a separate parameter and doesn't affect the normal work of the resume command.
Thank you.
Thanks! How would you like me to handle documentation for this? It should be mentioned on https://github.com/nesbox/TIC-80/wiki/Console but if we add it now then people will expect it to be supported on the latest release. Should I add it with a note about (1.3+ only)? Also it appears I forgot to update the |
Thanks for this commit, that should help a lot! You can add it to the wiki mentioning it has been added in version 1.2 I think with this
An example of a situation where this is necessary would help make this more accessible. Edit: I understand how we would need to do |
I've added an explanation to the wiki here: https://github.com/nesbox/TIC-80/wiki/Reload Let me know if it's clear or if anything could be improved. |
That's clear, thanks! |
When resuming, you can pass "reload" as the argument, which causes the cart's code to be reloaded before resuming the game.
This allows for a much smoother iterative development style where you can pause the game, make changes, and see the effect of those changes without restarting the game. It does require some special handling in the cart to support saving state to a global and avoiding that state being reinitialized if it's already set; for instance:
This implements the reload method for the Lua and Fennel scripts, but it will need to be implemented for other scripts independently.