A puzzlescript file is divided into the following sections.
Here's where all the fun happens! The level section of a game looks something like this.
=======
LEVELS
=======
#########
#.......#
#.*.*.O.#
#..*..O.#
#.P.*.*.#
#.......#
#########
MESSAGE Woah, that was tough, eh?!
#########
#.....@.#
#.P.*.O.#
#.......#
#########
#########
#.....@.#
#.P.*.O.#
#.......#
#########
MESSAGE Thank you for playing the game.
Levels are separated by blank lines, and you can also display messages and do some other things if you want to.
If you click ⌘/Ctrl+Left Click on the level in the text editor, it will load the level in game.
Those single characters can be set up in the legend like this. If you want to have several objects occupying a single tile, you specify this with and.
LEGEND
=======
. = Background
# = Wall
P = Player
* = Crate
@ = Crate and Target
O = Target
If you want to use the level_select feature or the goto commands, you need to divide your game into named sections.
You can use a goto command to redirect the player to any named section after the preceding level was won.
MESSAGE Select your preferred difficulty setting.
#########
#...P...#
#.E...H.#
#########
SECTION Easy Levels
#########
#.P..*O.#
#########
#########
#.P.*.O.#
#########
GOTO The End
SECTION Hard Levels
#########
#.P..*O.#
#.......#
#########
#########
#.P.....#
#...* O.#
#########
SECTION The End
MESSAGE Congratulations!
If you want a continuous open world you can set zoomscreen or flickscreen in the prelude. But if you want real level branching, read on.
The level command LINK provides a link from one level to another, triggered by a specified object. Links are created anywhere in the levels section, and apply to all subsequent levels. So yes, you can reuse your objects to link to different places in different levels.
The rules command LINK activates a link if the player is on a linked object. The game switches to the new level, but remembers where it came from. Winning a level reached by a link returns the player to where the link came from instead of winning the game. The player will be on the linking location, so a rule can delete the linking object and consider that sub-level won.
The prelude option allow_undo_level allows a player to go back to just before where a link came from. If you are using links, you will most likely want to set this option.
The demo/test program is soko_link.
RULES
[ Player links ] -> [ Player ] checkpoint // must have been a win
[ t ] -> [ t crate ]
[ links ][ crate ] -> [ links ][ ]
[ crate ][ t ] -> [ crate ][ ]
[ > Player | Crate ] -> [ > Player | > Crate ]
late [ Player links ] -> link
WINCONDITIONS
all Crate on Target
no links
LEVELS
link e Level 3
link f Level 4
link g Level 5
link h Level 6
###############
#O...........O#
#..P.e.f.g.h..#
#O.........t.O#
###############
message OK, doing well, half way there
link e Part 2d
link f Part 2c
link g Part 2b
link h Part 2a
###############
#O...........O#
#..P.h.g.f.e..#
#O.........t.O#
###############