Sections of a PuzzleScript file

A puzzlescript file is divided into the following sections.

Sounds

Here's where you hook up sounds to in-game actions.

There are sound buttons above the console, that produce sound seeds that you can use in this section. Each time you click on a button, you get a new randomly generated sound within a category, like "explosion sound" or "bird tweet sound". Keep trying -- sooner or later you'll get one you like.

These numbers are saved representations of the sounds, and you use them in the sound sections. You can click on the links in the console window to hear the sound.

A sound section could look like the following:

SOUNDS
======
Player Move Up 142315
Player Move Down 142313
Player Move Right 142311
Crate Move 412312
Player CantMove Up 41234
Crate CantMove 41234
Crate Create 41234123
CloseMessage 1241234
Sfx0 213424
Sfx3 213424

Sound Volume

You can specify a volume after the seed like this.
Player Move Up 142315:12
Player Move Down 142313:6
Endgame 123413:20

The sound volume is a scale of tenths, so that a volume of 6 is 60% and 20 is 200% of default. You can use any integer value between 1 and 39 included.

Note that increasing the volume of a sound can add distortion to it, and conversely, decreasing the volume of a sound can make it sound smoother. The reason is that the volume setting directly multiplies the soundwave's amplitude before it is capped to 1, and this capping causes distortion.

Object Events

Sound events in this group are triggered by something happening to a particular object. Note that move and cantmove can be supplied with directions, so that certain sounds play if you move (or can't) move in particular directions during a movement phase.
Crate Action 123414
Triggers when a crate is subject to the action during a movement phase.
Crate Create 123414
Triggers when a crate is created.
Player CantMove 4123412
Triggers when that object unsuccessfully moves, in any direction.
Player CantMove Down Left 4123412
Triggers when that object unsuccessfully moves, either down or left.
Crate Destroy 123414
Triggers when a crate is destroyed.
Player Move 4123412
Triggers when that object successfully moves, in any direction.
Player Move Down Left 4123412
Triggers when that object successfully moves either down or left.
Player Move Horizontal 4123412
Triggers when that object successfully moves horizontally. Vertical is also valid here.

Command Events

Sounds in this group are triggered by rule commands.
Cancel 123413
Played when the a rule triggers the cancel command.
SFX0 123434
Can be anything form SFX0 to SFX10. These are custom sound events that can be triggered from rules.

Game Events

Sounds in this group are triggered by an event for the game as a whole.
CloseMessage 123434
Makes a sound when the player closes a message window
EndGame 123413
When you finish the game, and end up back at the title screen.
EndLevel 123413
When you finish a level.
Restart 123413
Played when the player presses the restart button (R).
ShowMessage 123434
makes a sound when a message appears
StartGame 123413
When you start a new game from the title screen.
Startlevel 123413
Played at the start of each level.
TitleScreen 123414
Triggers when the title screen is loaded.
Undo 123413
Played when the player presses the undo button (Z).

Animation PuzzleScript Next

The Sounds section also lets an object have an animation instead of or as well as a sound. Use it like this.

player move up afx:slide
player cantmove up afx:slide
player move left afx:zoom
player cantmove left afx:zoom

m lclick afx:turn
w lclick afx:fade

b create  afx:turn
b destroy afx:turn
y create  afx:fade:scale
y destroy afx:fade:

player lclick 32169907 afx:turn=.25,0      // anticlockwise 90
player rclick 32169907 afx:turn=-.25,0     // clockwise 90

All animations start with afx and have one or more parameters separated by :. Each parameter may have an argument separated by =. The animations and their parameters are as follows.

slide[=n,m...]
Animates a sliding movement of an object
zoom[=n,m...]
animates zooming in or out (resizing) of an object
fade[=n,m...]
animates fading (alpha, transparency) of an object
turn[=n,m...]
animates turning (rotation) of an object
ease[=function]
applies an easing function (non-linear tweening), as per tween_easing in the prelude.

An argument of n,m... is a comma-separated list of values that define the animation, how the value changes over time. Default values are defined in a table in the source code and will be documented here once stable. Meanwhile feel free to experiment.

All animations take place in a single period of time, set in the prelude by animate_interval. Multiple animations may be applied to an object. The default is 0.25 sec. Note that if you enable tweening by setting tween_length, animation is disabled.


 animate_interval 0.4   // set animations to run in 0.4 secs
 // tween_length = 0.4  // tweening must not be set