Sections of a PuzzleScript file

A puzzlescript file is divided into the following sections.

Levels

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.

Level Commands

message So you thought that was too easy? Try this!
The message text is displayed before or after a level. Longer messages are automatically wrapped, and can use up to 3 lines.
section Tutorial levels
The name of the section will appear in the level select screen, and may be the target of a goto or link.
level Crossing the Bridge
Sets the name of the level. If you don't, it will be named "Level N", where N is the number of the level. This name will appear in the pause menu and in the "continue from" option of the title screen. It should be short (maximum 16 characters) and make sense for the player.
link someobject Level 5 PuzzleScript Next
Creates a link from this level to Level 5, which can be activated by the link rule command when the player is on someobject. The name can be the default (Level 5) or a name set by either the level or the section command.
Levels
The level itself comes after any other commands and ends with a blank line. Each character in the level grid defines the contents of a single tile.

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

Level Select Example

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!

Level BranchingPuzzleScript Next

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#
###############