PlotScripting Dictionary of Commands

This is a listing of all the plotscripting commands implemented as of May 28 2000.

In addition to reading this document, I also reccomend you check out Plotscripting Tutorial and the HamsterSpeak Specification

Declarations
Wait Commands
Suspend and Resume
Moving Heros
Moving NPCs
Moving The Camera
Text Boxes
Triggering And Showing Stuff
Adding and Removing
Effects
Misc Functions
Tweaking Maps
Working with Tags
Working with Variables
Math, Comparison, and Logic Operators
Flow Control
Advanced Commands
Predefined Constants

declarations

define script (id,name,aruments)
The define script command names a script, and associates it with an ID number. Every script must have a unique ID number for your game to call it directly (scripts that will only be called indirectly, by other scripts can use the special ID autonumber). The first argument is the ID number. It is a number between 1 and 16383. If you try to give two individual scripts the same ID number, your script file will not compile. The next argument is the name of the script. this is the same name that will used later in your script command. The third argument is the number of arguments that the script can accept. If it doesnt need any arguments (most scripts dont) then use none. If there are arguments, you then follow the argument count with default values for each argument.

 # example of a simple script definition
 define script (1,my first script,none)

 # example of a script definition with arguments
 define script (2,my fancy script,3,0,0,0)

script,name (statements)
script,name,argumentnames (statements)

the script command contains the actual source code of a plotscript. every script command must have a corresponding define script statement. Script starts with the keyword script, a comma, and then the name of the script. If there are any arguments to the script, you list their names separated by commas after the name of the script. Then comes the text of the script. It is usually enclosed in begin and end statements.

 # example of a simple script
 script,my first script,begin
   # commands go here
 end

 # example of a script with arguments
 script,my fancy script,fe,fi,fo,begin
   # commands go here,
   # and they can use the aruments fe, fi, and fo
   # that where passed to the script
 end

global variable (id,name)
Creates a global variable that can be used in any script. The first argument to the global variable declaration is a unique ID number. The second argument is the name of the variable. The ID number for a global variable is a number from 0 to 500. Each global variable must have a unique number, but this number will not conflict with the ID numbers you use for scripts. It is allright to have a script and a global variable with the same ID number.
See also variable

variable (name)
Creates a local variable that can only be used inside the script where it was created. The value of this variable is lost when the script ends. If you need a variable who's value persists between calls to a script, or that is automatically saved when the player saves their game, you will need to use a global variable instead.

define constant (number,name)
Creates a global constant. The first argument is the number that the constant will represent, and the second argument is the name of the constant. Use constants to replace commonly used numbers with friendly names. The following constants have been delacred for you in PLOTSRC.HSD

zero one two three four five six seven eight nine ten false true off on north east south west up down left right upkey downkey leftkey rightkey usekey cancelkey menukey anykey me none autonumber currentstat maximumstat north wall east wall south wall west wall vehicle A vehicle B harm tile overhead tile

include, filename
The include command inserts another text file into your script. It is followed by a single filename that tells what file will be included. Windows long filenames are not supported.

Every plotscript file should start with include, plotscr.hsd The PLOTSCR.HSD file contains definitions and constants for most of the other plotscripting commands.


Wait Commands

wait (ticks)
Makes the script wait for the specified number of ticks. I havent timed how many ticks there are in a second, but I would guess roughly 15. If you leave out the argument, it will wait for one tick.

wait for text box
makes the script wait until there is no text box displaying on the screen. Useful to know when to move on after using a show text box command

wait for hero (who)
Waits for the specified hero stop walking. Use the constant me to refer to the leader, or use numbers 0,1,2,3 to refer to a specific hero. If you leave out the argument, the first hero will be assumed.

wait for key (key)
Waits for the player to press a key. You can use the follwing constants: any key, up key, down key, left key, right key, use key, cancel key, or menu key. If you do not specify, then any key will be used.

wait for NPC (who)
Waits for the specified NPC to stop walking. The argument is the number of the NPC, 0 to 35. If more than one copy of the NPC exists on the map, it only checks the first one.

wait for camera
Waits for the camera to stop moving after a pan camera or focus camera command.

wait for all
Waits for any camera motion to stop, waits for all heros to stop walking, and if suspend NPCs is active, waits for all NPCs to stop walking.


Suspend and Resume

suspend player
Blocks the player from controlling the game, so the plotscript can have exclusive control. The one exception to this is text boxes. The player can advance text boxes no matter what.

resume player
Restores normal control after a suspend player command. This is very important. If you use suspend player, but forget resume player, the game will be stuck after the script ends.

suspend NPCs
Stops NPCs from walking around automatically. When Suspend NPCs is run, all NPCs stop in their tracks, ready for you to control them with the walk NPC command

resume NPCs
Restores automatic NPC movement after a suspend NPCs command

suspend obstruction
Allows heros to walk through NPCs, allows NPCs to walk through heros, and allows NPCs to walk through each other. Use resume obstruction to restore normal obstruction behavior.

resume obstruction
Restores normal obstruction after a suspend obstruction command

suspend hero walls
Allows heros to walk through walls. Use resume hero walls to restore normal wall behavior.

resume hero walls
Restores normal wall behavior after a suspend hero walls command

suspend NPC walls
Allows NPCs to walk through walls. Use resume NPC walls to restore normal wall behavior.

resume NPC walls
Restores normal wall behavior after a suspend NPC walls command.

suspend catapillar
Stops your other heros from following the leader. This is useful when you want to control them individually with walk hero commands. Also, It has come to my attention that the correct spelling should be "caterpillar" but because so many people have already used it in scripts, I will not change it.

resume catapillar
Reverses the suspend catapillar command, and makes your other heors follow the leader as normal.

suspend random enemys
Prevents enemies from attacking your party while walking over tiles that can normally spawn random battles. This is useful to prevent battles from interrupting a plotscript.

resume random enemys
Undoes the suspend random enemys and allows random battles to occur as normal.

suspend box advance
Prevents the player from advancing or clearing text boxes by pressing keys. While this is active, the only way to make a text box advance is with the advance text box command. Be very careful with this command, since you do not want to leave the player stuck on a text box forever

resume box advance
Undoes the suspend random enemys and allows the player to advance and clear text boxes by pressing keys as normal.

suspend overlay
Prevents overhead tiles from being drawn over heros and NPCs

resume overlay
Causes overhead tiles to be drawn over heros and NPCs as normal


Moving Heros

walk hero (who,direction,distance)
Makes the specified hero move in the specified direction for the specified number of tiles. The first argument tells who to move. Use me or numbers 0-3. The second argument is the direction. Use the constants: north, south, east, west, up, down, left, or right. The third argument is the number of tiles to move. If you leave out the third argument, the hero will move one tile. walk hero is usually used with the wait for hero command. You should normally use the suspend player command before moving heros, and if you want to move heros other than the leader, you should use the suspend catapillar command.

set hero direction (who,direction)
Makes the specified hero face in the specified direction. The following constants are avaialable for direction: north, south, east, west, up, down, left, or right.

set hero frame (who,frame)
Sets the walking frame of the specified hero to 0 or 1.

set hero position (who,X,Y)
Instantly moves the specified hero to an X,Y position on the map. The coordinates are in units of tiles.

set hero Z (who,Z)
Sets the Z location of the specified hero. The Z location is the number of pixels above the tile they are standing on. Useful for scripts where you want a hero to jump or levitate.

walk hero to X (who,X)
Makes the specified hero walk to a given X coordinate on the map

walk hero to Y (who,Y)
Makes the specified hero walk to a given Y coordinate on the map

set hero speed (who,speed)
Changes the walking speed of the specified hero. If you do not specify a speed, the hero's speed will return to the default, 4. Be careful with using speeds that do not divide evenly into 20, because tiles are 20 pixels in size, and an irregular walking speed may cause your hero to become misaligned with the tiles.

use door (number)
instantly uses the numbered door, just as if you had stepped into it.

teleport to map (map,x,y)
An alternative to use door, teleport to map moves you to a given x,y position on the specified map without the need to create a door-link on the map. Teleport to map does not fade to black.

dismount vehicle
Makes you dismount whatever vehicle you are riding. If you are not riding a vehicle, nothing will happen.


Moving NPCs

walk NPC (who,direction,distance)
Makes the specified NPC move in the specified direction for the specified number of tiles. The first argument tells who to move. Use numbers 0-35. If more than one copy of the NPC exists on the map, only the first one will be moved. The second argument is the direction. Use the constants: north, south, east, west, up, down, left, or right. The third argument is the number of tiles to move. If you leave out the third argument, the NPC will move one tile. walk NPC is usually used with the wait for NPC command. You should normally use the suspend NPCs command before moving NPCs.

set NPC direction (who,direction)
Makes the specified NPC face in the specified direction. The following constants are avaialable for direction: north, south, east, west, up, down, left, or right. If more than one copy of the same NPC exists on the map, only the first one will turn.

set NPC frame (who,frame)
Sets the walking frame of the specified NPC to 0 or 1. If more than one copy of the same NPC exists on the map, only the first one's frame will be changed.

set NPC position (who,X,Y)
Instantly moves the specified NPC to an X,Y position on the map. The coordinates are in units of tiles. If more than one copy of the same NPC exists on the map, only the first one will be moved.

walk NPC to X (who,X)
akes the specified NPC walk to a given X coordinate on the map. If more than one copy of the same NPC exists on the map, only the first one will be moved.

walk NPC to Y (who,Y)
Makes the specified NPC walk to a given Y coordinate on the map. If more than one copy of the same NPC exists on the map, only the first one will be moved.

set NPC speed (who,speed)
Changes the walking speed of the specified NPC. If you do not specify a speed, the NPC's speed will return to the default, 4. Be careful with using speeds that do not divide evenly into 20, because tiles are 20 pixels in size, and an irregular walking speed may cause the NPC to become misaligned with the tiles. If more than one copy of the same NPC exists on the map, only the first one will be moved.


Moving the Camera

camera follows hero (who)
Normally, the camera follows your leader. With this command, you can make the camera follow any hero you want. If you leave out the argument, the camera will follow your leader as normal.

camera follows NPC (who)
With this command, you can make the camera follow an NPC instead of the hero. If more than one copy of the specified NPC exists, the camera will follow the first one. To revert the camera to normal, use camera follows hero.

pan camera (direction,distance,pixelstep)
This command causes the camera to stop following your leader and pan in the specified direction. For direction, you can use the constants: north, south, east, west, up, down, left, or right. The distance is the number of tiles you want the camera to move before it stops. You can also specify the number of pixels you want the camera to move for each tick. if you leave the last argument out, the camera will move by 2 pixels per tick. This command is normally used with wait for camera. To revert the camera to normal, use camera follows hero.

focus camera (x,y,speed)
This command causes the camera to focus itself on the specified X,Y coordinates of the map. These coordinates are in units of tiles. The third argument, the speed, tells how fast the camera will pan. If you do not specify a speed, the camera will pan 2 pixels per tick. This command is normally used with wait for camera. To revert the camera to normal, use camera follows hero.


Text Boxes

show text box (number)
Displays the numbered text box, just as if you had talked to an NPC. The text box will not actually pop up until the next wait command. This command is most often used with the wait for text box command.

advance text box
Advances a text box just as if the player had pressed a key. For use while suspend box advance is active.


Triggering and Showing Stuff

fight formation (number)
Starts a battle with the numbered enemy formation. This command returns false if you lost or ran from battle, or true if you won.

game over
Resets the game and returns you to the title screen. This command is most useful for after-you-win-the-game type scripts, and for death-scripts that are triggered when you lose in battle.

show value (number)
Displays the number in the bottom left corner of the screen. Useful for count-down timers, and for debugging complicated scripts.

show no value
Gets rid of the number in the bottom left corner of the screen after a show value command.

show backdrop (number)
displays the specified full screen backdrop on the screen. This allows you to show full screen pictures without attaching them to text boxes. You can also do some simple animation effects by calling show backdrop many times with wait commands in between.

show map
shows the map again after a show backdrop command


Adding and Removing

get money (amount)
Adds the specified amount to your party's money

lose money (amount)
Subtracts the specified amount from your party's money.

pay money (amount)
A function that checks to see if you have enough money to pay the amount specified. If you do, it subtracts it, and returns true. If you do not have enough, it subtracts nothing, but returns false. Intended for use in if statements.

add hero (who)
Puts the named hero in your party. If there is no room, the hero will be added to your reserve. Use the constants defined in your HSI file. They are in the form of hero:name

delete hero (who)
Removes the named hero from your party. If you have more than one copy of the hero in your party, only the first one will be deleted. Use the constants defined in your HSI file. They are in the form of hero:name

swap in hero (who)
Moves the named hero in your from your reserves to your active party. If there is no room in your active party, the hero will not be moved. Use the constants defined in your HSI file. They are in the form of hero:name

swap out hero (who)
Moves the named hero from your active party into your reserve. Use the constants defined in your HSI file. They are in the form of hero:name

lock hero (who)
Locking a hero prevents the player from moving the hero on the party menu. Locked heros in the active party cannot be moved into the reserve, and locked heros in the reserve are completely hidden. Also prevents a hero from being moved by swap in hero or swap out hero. Use the constants defined in your HSI file. They are in the form of hero:name

unlock hero (who)
Reverses lock hero (who), and makes it possible to move a hero in and out of the active party again. Use the constants defined in your HSI file. They are in the form of hero:name

swap by name (name,name)
Swaps two named heros in your party no matter what position they are in. Use the names defined in your HSI file in the form hero:name

swap by position (position,position)
Swaps two heros in your party based on their positions in the party

get item (item,number)
Adds the specified number of the specified item to your inventory. If you do not specify a number, only one will be added. You can refer to the item by number, or you can use the constants defined in your HSI file, which are in the form of item:name

delete item (item,number)
Removes the specified number of the specified item from your inventory. If you do not specify a number, only one will be removed. You can refer to the item by number, or you can use the constants defined in your HSI file, which are in the form of item:name


Effects

play song (song)
Plays the specified song. Use the constants defined in your HSI file. They appear in the form of song:name

stop song
Stops whatever music is currently playing.

fade screen out (red,green,blue)
Fades the screen to a solid color. If you do not specify any arguments, the screen will fade to black. The red, gree, blue values are numbers from 0 to 63 that tell how bright that particular color should be. (63,0,0) would be blood red. (40,0,40) would be purple. (63,63,63) would be bright white. The screen will remain faded out until you run fade screen in, fight a battle, or use a door.

fade screen in
Fades the screen back to normal after a fade screen out command.


Misc Functions

random(lownumber, highnumber)
Returns a random number in the range of the two numbers. The returned value will be greater than or equal to the first number, and less than or equal to the second number

inventory (item)
Returns a count of how many of the specified item are in your inventory. If you do not have the item, it returns zero or false. You can refer to the item by number, or you can use the constants defined in your HSI file, which are in the form of item:name

leader
Returns the hero number of the current leader.

hero X (who)
returns the specified hero's X position in tiles.

hero Y (who)
returns the specified hero's Y position in tiles.

NPC X (who)
returns the specified NPC's X position in tiles.

NPC Y (who)
returns the specified NPC's Y position in tiles.

hero direction (who)
returns the specified hero's direction.

NPC direction (who)
returns the specified NPC's direction.

room in active party
A function that returns the number of available spaces in your active party. It will return zero or false if there is no room.

current map
returns the number of the current map.

days of play
returns the number of days that the game has been played

hours of play
returns the number of hours that the game has been played, 0 to 23

minutes of play
returns the number of minutes that the game has been played, 0 to 59

key is pressed (scancode)
Returns true if the keyboard key with the specified scancode is being pressed, or false if it is not.


Tweaking Maps

read map block (x,y)
Returns the value of a map tile on the current map at the specified X,Y position. Normal map tiles return values from 0-159, animating maptiles from set 1 return 160-207 and animating maptiles from set 2 return 208-255.

write map block (x,y,value)
Writes a new tile to the specified X,Y position on the current map. This change will only persist until you leave the map or fight a battle.

read pass block (x,y)
Returns the value of a passability (wallmap) tile on the current map at the specified X,Y position. The return value will be from 0 to 255 and consists of eight flag bits.

  bit 1   = north wall
  bit 2   = east wall
  bit 4   = south wall
  bit 8   = west wall
  bit 16  = vehicle A
  bit 32  = vehicle B
  bit 64  = harm tile
  bit 128 = overhead tile
to check the value of a specific bit, use the and operator. For example:
  variable (pass)
  set variable(pass,read pass block(hero X(me),hero Y(me)))
  if (pass,and,harm tile) then begin
    # this checks if the hero is standing
    # on a harm tile
  end

write pass block (x,y,value)
Writes a new passability (wallmap) information to the specified X,Y position on the current map. This change will only persist until you leave the map or fight a battle. The value is a number from from 0 to 255 that consists of eight flag bits.

  bit 1   = north wall
  bit 2   = east wall
  bit 4   = south wall
  bit 8   = west wall
  bit 16  = vehicle A
  bit 32  = vehicle B
  bit 64  = harm tile
  bit 128 = overhead tile
You can add the constants together. For example:
  variable (pass)
  set variable(pass,northwall+southwall+eastwall+westwall)
  write pass block(15,3,pass)
  # this makes the fifteenth tile in the third column
  # impassable on all directions


Working with Tags

set tag (tag,value)
Sets the value of a tag. The available constants are: off, on, true, or false. You can specify the number of the tag, or you can use the constants in your HSI file. These constants are in the form of tag:name.

check tag (tag)
A function that checks the value of a tag, and returns true if the tag is turned on, and false if the tag is turned off. It can be used in if and while statements You can specify the number of the tag, or you can use the constants in your HSI file. These constants are in the form of tag:name.


Working with Variables

set variable (variable,value)
This command assigns a new value to a variable. If you do not specify the new value, the variable will be reset to zero. This command works exactly the same for global and local variables.

increment (variable,amount)
This command adds an amount to the current value of a variable. If you do not specify the amount, then the variable will be incremented by one. This command works exactly the same for global and local variables.

decrement (variable,amount)
This command subtracts an amount from the current value of a variable. If you do not specify the amount, then the variable will be decremented by one. This command works exactly the same for global and local variables.


Math, Comparison, and Logic Operators

Pre-December 1999 versions of HamsterSpeak used a different syntax for math. For more information, see the HamsterSpeak Specification

number + number
Adds two values together and returns the result. This can also be written as number,add,number

number -- number
Subtracts the second number from the first number and returns the result. It is neccisary to use the double minus so that HSPEAK.EXE can tell the difference between subtraction, and a minus sign that indicates a negative number. You can also write number,subtract,number

number * number
Multiplies two values together and returns the result. This can also be written as number,multiply,number

number / number
Divides the second number into the first number and returns the result. The result will be rounded to the nearest integer. This can also be written as number,divide,number

number,mod,number
Divides the second number into the first number and returns the remainder.

number ^ power
Raises a number to a power and returns the result. Normally you will only be raising things to a power of 2. Raising to very large powers will most certainly produce an overflow error. This can also be written as number,exponent,power

number == number
Checks to see if the two numbers are equal. If they are equal it returns true, otherwise it returns false. This can also be written as number,equal,number

number <> number
Checks to see if the two numbers are not equal. If they are not equal it returns true. If they are equal it returns false. This can also be written as number,not equal,number

number << number
Checks to see if the first number is less than the second number. If it is, it returns true, otherwise it returns false. This can also be written as number,less than,number

number >> number
Checks to see if the first number is greater than the second number. If it is, it returns true, otherwise it returns false. This can also be written as number,greater than,number

number <= number
Checks to see if the first number is less than or equal to the second number. If it is, it returns true, otherwise it returns false. This can also be written as number,less than or equal to,number

number >= number
Checks to see if the first number is greater than or equal to the second number. If it is, it returns true, otherwise it returns false. This can also be written as number,greater than or equal to,number

value,and,value
Returns true if both of the values are true (non-zero). If either of them is false, and returns false.

value,or,value
Returns true if at least one of the values are true (non-zero). Only if both of them are false does or return false.

value,xor,value
Returns true if one, but not both of the values are true (non-zero). If both of them are true, or both of them are false, xor returns false.


Flow Control

begin
 # other commands
end

begin is a synonym for ( and end is a synonym for ). Parenthesis are normally used for bracketing things that all fit on the same line, and begin/end statements are often used to enclose very long things such as whole scripts or long flow control blocks that take up several lines. For example, the following two blocks of code are identical;

 if (check tag(2)) do (show text box (5),wait for text box)
 
 if (check tag(2)) do
 begin
   show text box (5)
   wait for text box
 end

if(condition) then(commands) else(commands)
The if statement checks the value of its condition, and if the value is true, it runs the commands in the then block. If the value is false, it runs the commands in its else block. The conditional is usually an equality operator such as == or <>, or it is a check tag command. The else is optional as long as you have a then, and the then is optional as long as you have an else. There are some examples of if statements in the HamsterSpeak Specification, and in WANDERP.HSS

while(condition) do(commands)
The while command checks the value of its condition, and if the value is true it runs the commands in the do block. It keeps checking the conditional and runs the do block over and over again until the conditional returns false. The conditional is usually an equality operator such as == or <>, or it is a check tag command.

for(counter,start,finish,step) do(commands)
The for command runs the commands in the do block a specified number of times. The first argument to for is the counter. It must be a variable. The next two arguments are the starting value and the finishing value. For example, if you use a start value of 1 and a finish value of 10 then the do block will run 10 times. The first time the do block runs, the counter will be 1, then it will be 2, then 3 and so on until it reaches 10, the finish value. The fourth argument of for is optional. It is the step by which the counter will change each loop. If you use a step of 2 then the counter will count 1,3,5,7,9. If you switch the start and finish values and use a step of -1 then the counter will go backwards. If you use 0 as the step, the counter will never change, so the do block will repeat forever. There are examples of for commands in WANDERP.HSS


Advanced Commands

alter NPC (who,NPCstat,value)
Changes the stats of an NPC. Constants for this command have been included in PLOTSCR.HSD. Advanced uses should have no trouble figuring out how to use this command by looking at PLOTSCR.HSD.

set death script (id)
Changes the script that is run when you die in battle. The argument is the script's ID number, NOT the script's name. Calling set death script with no argument disables the death script.

find hero (who)
Searches through your party to see if the specified hero is there, and returns the position where the hero was found, or -1 if the hero was not found. Use the names defined in your HSI file in the format hero:name. Not only does this tell you if a hero is in your party, but you can also use it to tell whether or not the hero is in your active party. find hero will return 0,1,2 or 3 if the hero is in the active party, but it will return a number 4 or higher if the hero is in the reserve

get hero stat (who,stat,type)
A function that returns one of a hero's stats. The first argument is the name of the hero you want to check as defined in your HSI file. The second argument is the name of the stat that you want to check. The names of the stats are also define in your HSI file in the form stat:name. The third argument is either current stat or maximum stat. If you leave the last argument blank, current stat will be assumed.

set hero stat (who,stat,value,type)
A command that changes one of a hero's stats. The first argument is the name of the hero you want to change as defined in your HSI file. The second argument is the name of the stat that you want to change. The names of the stats are also define in your HSI file in the form stat:name. The third argument is the new value of the stat. The last argument is either current stat or maximum stat. If you leave the last argument blank, current stat will be assumed.


Predefined Commands

numeric constants
zero, one, two, three, four, five, six, seven, eight, nine, ten

PLOTSCR.HSD defines constants for the numbers from 0 to 10. you can use these constants to make your scripts look friendly :)

boolean constants
true, false, ON, OFF

PLOTSCR.HSD defines constants for true and false, and for ON and OFF. These are useful for checking and setting the values of tags.

direction constants
north, south, east, west
up, down, right, left

PLOTSCR.HSD defines constants each of the four directions. These constants are useful for commands such as walk hero and walk NPC, which take a direction as an argument.

keyboard constants
upkey, downkey, leftkey, rightkey
usekey, cancelkey, menukey, anykey

PLOTSCR.HSD defines constants that correspond to each of the usable keys (or joystick buttons) that the player can press while playing. These are useful with the wait for key command

me
me is a constant that can be used to refer to the first hero in your party (hero zero) in any command that takes a hero number as an argument.

none
none is a constant that means the same as zero. It is normally used in define script commands for scripts that do not have any arguments

autonumber
autonumber is a constant that is used as the ID number in define script commands for scripts that do not need to be called directly from toe OHRRPGCE. Autonumber scripts are only called from within other scripts.

current stat
a constant for use with the get hero stat and set hero stat commands.

maximum stat
a constant for use with the get hero stat and set hero stat commands.