Extend call_replay scope with support for nested store attributes #5076
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Synopsis:
This pull request aims to enhance the functionality of
renpy.call_replay
by enabling support for nested store attributes within thescope
parameter andconfig.replay_scope
variable. Currently, when usingrenpy.call_replay("label", scope={"states.characters.player.health": 100}
, the scope assigns the value to a key with the same name, rather than allowing for nested stores as expected.To address this, the proposed change modifies the behaviour to accommodate nested stores, making it more user-friendly. This improvement aligns with the convention of utilizing dots within keys to represent nested structures in Ren'py, thus ensuring compatibility across all projects.
The ability to work with nested stores offers several advantages in development, such as simplifying organization, preventing the pollution of scopes with unrelated variables, enabling iteration over nested structures, and facilitating the management of saves and changes across different versions of a project.
This modification enhances the flexibility and utility of Ren'py, providing a more efficient and intuitive approach for developers working with complex data structures in their projects.
Please let me know if you need further assistance with this pull request or if you'd like to see the code changes.
Use case:
Let's say you want to use call_replay to implement a gallery feature in your game. With the extended scope support, you can track the state of the gallery for each character individually. By using nested store attributes with the extended call_replay scope, you can effectively organize and manage data for different game elements more efficiently.