PuzzleScriptPlus
PuzzleScriptPlus copied to clipboard
Consider adding a way to track state in-between levels
This is a big one. Goto is very cool, but I feel that it is missing a way to pass state between levels. I've been thinking about this off and on recently, mostly because it is a recurring discussion over on the Thinky Puzzle Discord channel, where it came up in a discussion about level selects.
It would allow use cases like this:
- Walking around a dungeon would allow you to spawn in the correct place in the target level (e.g. exiting the level on the right would spawn you on the left side in the other room)
- Building level selects as a level of its own!
Could be implemented as such:
- Some objects (or perhaps entire layers) are "persistent", when the level changes they are spawned again into (approximately) the same location.
- Alternative suggestion: spawn in sequence starting from the top left corner. To prevent any possible issues with overlapping objects that share a layer.
- The biggest issue here is how to deal with object placement when the room size changes between levels. Could be mitigated by explicitly designing around this, e.g. the way you are supposed to use object permanence is to only check the existence of permanent object and then using that in your own logic. But I imagine that this gets verbose very quickly.
- Having variables that persist between levels.
- Goto can pass an object to the next scene.
goto levelName objectName
. Spawns in top left corner?- But this only seems useful for going from room to room, not for e.g. level selects
- A rule can be given an condition, such as
completed(LevelName)
, to check if the level with that name was already completed.- Probably the cheapest of these to implement.
Mostly when people ask whether this is possible in vanilla PS they are suggested to use zoomscreen or flickscreen. Which I don't think is a bad approach. But can we do better?
Serialization approach also needs to be planned out, I've mostly avoided touching the save games for now but there won't be any way to get around it here :P
I think most of it can be done with two simple changes. You need a GOTO command that:
- takes you from one level to another, and keeps the state of the level you left, so when you GOTO that level any time later it looks the same as when you left it; and
- has an argument that specifies a movement. In the new level you can write rules to place the player at a particular entrance, or do anything you like based on that movement. [Dropping an object would work too, but I prefer a movement.]