# Declarations

plotscript, name, argumentnames (statements)
plotscript
The plotscript command contains a list of commands that can be triggered directly by an event in your game. Plotscript starts with the keyword plotscript, a comma, and then the name of the plotscript. If there are any arguments to the script, you list their names separated by commas after the name of the script with default values. Then comes the text of the script. It is enclosed in begin and end statements. Scripts that are defined as plotscripts can be called directly from events in your game, or by name within other scripts.
# example of a simple script plotscript,my first script,begin # commands go here end
# example of a script with arguments plotscript,my fancy script,fe=0,fi=0,fo=0,begin # commands go here, # and they can use the aruments fe, fi, and fo # that where passed to the script end
script, name, argumentnames (statements)
script
The script command contains a list of commands. 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 with default values. Then comes the text of the script. It is enclosed in begin and end statements. Scripts that are defined as script cannot be called directly from events in your game. They can only be called by name within other scripts. To make a script that can be run directly from your game, use plotscript.
# 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=0,fi=0,fo=0,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)
global variable
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 4095. Each global variable must have a unique number, but this number will not conflict with the ID numbers you use for scripts. It is all right to have a script and a global variable with the same ID number. See also variable
# any script can read and set the value of a global global variable(1,mini game score)
variable (name)
variable
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 globalvariable instead.
variable(points) # make a new variable variable+=1 # add one to it
define constant (number,name)
define constant
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 northwall eastwall southwall westwall vehiclea vehiclea harmtile overheadtile
include, filename
include
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.
include, plotscr.hsd # Plotscripting definitions include, mygame.hsi # constants particular to my game
define script (id,name,arguments)
define script
ubersetzung

This declaration is available for backwards compatability, but it is not required anymore. See script and plotscript instead.

The define script command names an old-style script, and associates it with an ID number. Old scripts used to require a unique ID number. 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 don't) 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. this script # has three arguments, all of which default to zero if they # are not specified define script (2,my fancy script,3,0,0,0)

# Wait Commands

wait (ticks)
wait
Makes the script wait for the specified number of ticks. There are roughly 18 ticks to a second, but this can vary under some conditions. If you leave out the argument, it will wait for one tick.
show text box(2) # Show a text box wait(50) # Wait about 3 seconds advance text box # "hit spacebar"
wait for text box
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 showtextbox command.
show text box(2) # Show a text box wait for text box # wait until the player continues
wait for menu (menu handle)
wait for menu
Given a

menu handle

(for example, the one returned by openmenu), causes the script to wait until that menu has been closed.
wait for hero (who)
wait for hero
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.
move hero to y (me, 10) # move hero to (x, 10) wait for hero (me) # wait until he stops
wait for key (key)
wait for key
Waits for the player to press a key. You can use the following constants: anykey, upkey, downkey, leftkey, rightkey, usekey, cancelkey, or menukey. If you do not specify, then anykey will be used. These are not scancodes, and can not be mixed with scancodes! Use waitforscancode if you want to use scancodes or wait for other keys.

usekey

will wait for Space, Ctrl or Enter; and

cancelkey

and

menukey

both wait for Alt or Esc. If and only if anykey is used, waitforkey will return the scancode of the key that was pressed.
show text box(623) # "press cancel!" wait for key(cancel key)
wait for scancode (key)
wait for scancode
ubersetzung
Waits for the player to press a specific key. You can use any of the constants from keyispressed to specify the key.

You must include scancode.hsi to use these constants.

show text box(624) # "press P!" wait for scancode(key:P)
wait for NPC (who)
wait for NPC
Waits for the specified NPC to stop walking. The argument is either an NPC reference, or an NPC ID (if more than one copy of that NPC exists on the map, it only waits for the first one).
walk NPC (2,up,3) # make the NPC go up three spaces wait for NPC (2) # wait until he's done
wait for camera
wait for camera
Wait for the camera to stop panning after a pancamera or focuscamera command.
pan camera (left,10) # show the villan 10 tiles off screen wait for camera # wait until he's on screen
wait for all
wait for all
Waits for any camera motion to stop, waits for all heroes to stop walking, and if suspendnpcs is active, waits for all NPCs to stop walking.
# do a bunch of things all at once wait for all # wait until everything is done

# Suspend and Resume

suspend player
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, unless you use suspendboxadvance.
suspend player # do stuff resume player
resume player
resume player
Restores normal control after a suspendplayer command. This is very important. If you use suspendplayer, but forget resume player, the game will be stuck after the script ends.
suspend NPCs
suspend NPCs
Stops NPCs from walking around automatically. When suspend NPCs is run, all NPCs stop in their tracks once they've finished their current move, ready for you to control them with the walknpc command. You can use waitforall to wait for all NPCs to stop moving. Use setnpcmoves(who, false) instead to prevent a single NPC from moving.
suspend NPCs # do stuff resume NPCs
waitfornpc
waitforall
setnpcmoves
resume NPCs
resume NPCs
Restores automatic NPC movement after a suspendnpcs command. This does not resume NPCs suspended with setnpcmoves.
suspend obstruction
suspend obstruction
Allows heroes to walk through NPCs, allows NPCs to walk through heroes, and allows NPCs to walk through each other. Use resumeobstruction to restore normal obstruction behavior. Use setnpcobstructs(who, false) instead to allow a single NPC to move through heroes and NPCs, and vice-versa.
suspend obstruction # walk through things resume obstruction
resume obstruction
resume obstruction
Restores normal obstruction after a suspendobstruction command. This doesn't undo the effect of setnpcobstructs.
suspend hero walls
suspend hero walls
Allows heroes to walk through walls. Use resumeherowalls to restore normal wall behavior.
suspend hero walls # hero is now a ghost # walk through things resume hero walls # back to mortality...
resume hero walls
resume hero walls
Restores normal wall behavior after a suspendherowalls command
suspend NPC walls
suspend NPC walls
Allows NPCs to walk through walls. Use resumenpcwalls to restore normal wall behavior. Use setnpcignoreswalls(who, true) instead to allow a single NPC to walk through walls.
suspend NPC walls # npc is now a ghost # walk through things resume NPC walls # back to mortality...
resume NPC walls
resume NPC walls
Restores normal wall behavior after a suspendnpcwalls command. This doesn't undo the effect of setnpcignoreswalls.
suspend caterpillar
suspend caterpillar
Stops your other heroes from following the leader. This is useful when you want to control them individually with walkhero commands. In earlier versions this was misspelled as suspend catapillar. The old spelling still works for backwards compatability.
suspend caterpillar # cutscene # move heroes, probably fight a battle or two... resume caterpillar # normal game again.
resume caterpillar
resume caterpillar
Reverses the suspendcaterpillar command, and makes your other heroes follow the leader as normal. In earlier versions this was misspelled as resume catapillar. The old spelling still works for backwards compatability.
suspendcaterpillar
suspend catapillar
May 22 2001
resumecaterpillar
resume catapillar
May 22 2001
suspend random enemies
suspend random enemies
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. In earlier versions, this was misspelled as suspend random enemys. The old spelling still works for backwards compatability.
suspend random enemies # no battles for now walk hero (me, up, 10) # cross pit of evil monsters of doom resume random enemies # back to normal
resume random enemies
resume random enemies
Undoes the suspendrandomenemies command and allows random battles to occur as normal. In earlier versions, this was misspelled as resume random enemys. The old spelling still works for backwards compatability.
suspendrandomenemies
suspend random enemys
resumerandomenemies
resume random enemys
suspend box advance
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 advancetextbox command (or showtextbox). Useful for cut scenes that play out like a movie, where the player just watches the dialogue unfold. Be very careful with this command, since you do not want to leave the player stuck on a text box forever.
suspend box advance # stop players from mucking things up show text box(2) # Show a text box wait(45) # Wait about 3 seconds advance text box # "hit spacebar" resume box advance # go back to normal
resume box advance
resume box advance
Undoes the suspendboxadvance command and allows the player to advance and clear text boxes by pressing keys as normal.
suspend overlay
suspend overlay
Draws old-style overhead tiles under heroes and NPCs instead of over them. This does not affect the drawing of normal layers. You might still find this useful for creating bridges or catwalks that can be walked on or passed under. Undo with resumeoverlay.
resume overlay
resume overlay
Undoes the suspendoverlay command, causing overhead tiles to be drawn over heroes and NPCs as normal.
suspend map music
suspend map music
serendipity
Causes ambient music not to automatically play when you enter a map. Does not affect the currently playing music, or the map's ambient music. Use when playing thematic music during a scene that involves changing maps.
# begin scene play song(song:Happy Times) show textbox (117) wait for textbox # goto another map without triggering music fade screen out wait suspend map music use door(3) fade screen in # continue scene show textbox (118) wait for textbox # return to normal music behaviour and play the ambient music resume map music play song (get ambient music)
setambientmusic
getambientmusic
resume map music
resume map music
serendipity
Causes ambient music to automatically start playing when you enter a map again after a suspendmapmusic command.
suspend timers
suspend timers
Causes all plot timers started with settimer to be paused. It does not cancel them. Undo with resumetimers
resume timers
resume timers
Undoes suspendtimers. All previously paused plot timers will become active again.

# Moving Heroes

walk hero (who, direction, distance)
walk hero
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 waitforhero command. You should normally use the suspendplayer command before moving heroes, and if you want to move heroes other than the leader, you should use the suspendcaterpillar command.
suspend player # stop player walk hero(me,up,3) # move him up 3 tiles resume player # ok, done
set hero direction (who, direction)
set hero 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 direction (me,right) # face right
set hero frame (who, frame)
set hero frame
Sets the walking frame of the specified hero to 0 or 1.
heroframe
set hero position (who, x, y)
set hero position
Instantly moves the specified hero to an X,Y position on the map. The coordinates are in units of tiles. For pixel-positioning use the puthero command.
set hero z (who, z)
set hero 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)
walk hero to x
Makes the specified hero walk to a given X coordinate on the map
walk hero to y (who,x)
walk hero to y
Makes the specified hero walk to a given Y coordinate on the map
check hero wall (who,direction)
check hero wall
Returns true if there is a wall blocking the hero from moving in the specified direction. No actual movement takes place.
set hero speed (who, speed)
set hero 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.
getherospeed
use door (number)
use door
Instantly uses the numbered door, just as if you had stepped into it. (This command implies a one-tick wait)
teleport to map (map, x, y)
teleport to map
An alternative to usedoor, 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. (This command implies a one-tick wait)
dismount vehicle
dismount vehicle
Makes you dismount whatever vehicle you are riding. If you are not riding a vehicle, nothing will happen.
hero is walking (who)
hero is walking
Returns true if the specified hero (by position in the caterpillar) is currently walking. Returns false if the hero is standing still.
put hero (who, x, y)
put hero
Moves a hero to a precise location on the map. The first argument is the hero's position in the walkabout party. The second and third arguments are the X,Y pixel position of the top left corner of the hero walkabout sprite, relative to the top left corner of the map. Be aware that using this command can misalign your hero with the tile-grid, preventing it from walking normally. To position the hero by tile, use the setheroposition command. Normally you will use this command to escape the tile-based movement system.
# This script will make the hero jump in an arch 15 pixels high 2 tiles to the right, # but it won't animate it. You can use setheroframe or setheropicture to do that. variable (i, jump) suspend player set hero direction (me, right) jump := -5 for (i, 0, 10) do ( put hero (me, hero pixel X (me) + 4, hero pixel Y (me) + jump) jump += 1 wait ) resume player

# Moving NPCs

NPC reference (ID, copy)
NPC reference
What is an NPC reference? A reference is a number that uniquely identifies an NPC on a map. You can use an NPC reference to specify which NPC you are controlling in most NPC-related commands. The first argument to NPC reference is the ID number of the NPC you want to work with. The ID is the same number that appears in CUSTOM.EXE when you are editing NPCs or placing NPCs on the map. The second argument is optional. It specifies which copy of the NPC you want, in case there are more than one on the map. If you don't specify which copy you want, you will just get a reference to the first NPC on the map with the right ID. Copies are counted starting from zero. You can see the copy number of NPCs in the Map Editor if you placed them in Custom. If the NPC ID/copy which you asked for is not found on the map then NPC reference will return false. If you plan on using the same NPC reference many times in a script you can store it in a variable.

NPCs hidden due to tag conditions are never returned by this command.

include,plotscr.hsd

#---NPC reference example---

plotscript,ref example,begin

variable(Fred)

# find the first copy of NPC 10, # and store the reference in a variable Fred := NPC reference(10,0)

# now we can manipulate that NPC with the variable walk NPC (Fred,south,3) wait for NPC (Fred)

# make the NPC spin! set NPC direction (Fred,east) wait(2) set NPC direction (Fred,north) wait(2) set NPC direction (Fred,west) wait(2) set NPC direction (Fred,south) wait(2)

end
npcatspot
npcatpixel
createnpc
npccopycount
NPC at spot (x, y, number)
NPC at spot
This command returns a reference to the NPC at the given X and Y coordinate, in tiles, on the map. The optional third argument lets you choose which NPC to reference in case there is more than one NPC standing on that same spot (starting from the bottom-most NPC, which is number 0). false is returned if there is no NPC there, or

number

is too large. You can also pass the constant getcount for the third argument to return the total number of npcs on that tile.

An NPC's tile is the tile its top left corner is on.

npcreference
NPC at pixel (x, y, number)
NPC at pixel
This command returns a reference to the NPC at the given X and Y coordinate in pixels. That is, any npc whose 20x20 sprite (including transparent sections) is over that pixel. The optional third argument lets you choose which NPC to reference in case there is more than one NPC standing on that same spot (starting from the bottom-most NPC, which is number 0). false is returned if there is no NPC there, or

number

is too large. You can also pass the constant getcount for the third argument to return the total number of npcs on that tile.
npcreference
walk NPC (who, direction, distance)
walk NPC
Makes the specified NPC move in the specified direction for the specified number of tiles. The first argument tells who to move. You can use an npcreference or the NPC's ID number. 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 waitfornpc command. You should normally use the suspendnpcs command before moving NPCs to prevent their automatic movements from interfering with your scripted movements.
set NPC direction (who, direction)
set NPC 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. You can use either an npcreference or the NPC's ID number to specify which NPC will turn.
set NPC frame (who, frame)
set NPC frame
Sets the walking frame of the specified NPC to 0 or 1. You can use either an npcreference or the NPC's ID number to specify which NPC will change.
npcframe
set NPC position (who, X, Y)
set NPC position
Instantly moves the specified NPC to an X,Y position on the map. The coordinates are in units of tiles. You can use either an npcreference or the NPC's ID number to specify which NPC will be moved.
walk NPC to X (who, X)
walk NPC to X
Makes the specified NPC walk to a given X coordinate on the map. You can use either an npcreference or the NPC's ID number to specify which NPC will move.
walk NPC to Y (who, Y)
walk NPC to Y
Makes the specified NPC walk to a given Y coordinate on the map. You can use either an npcreference or the NPC's ID number to specify which NPC will move.
check NPC wall (who, direction)
check NPC wall
Returns true if there is a wall blocking the NPC from moving in the specified direction. No actual movement takes place. It does not matter whether the NPC is set to ignore walls.
set NPC speed (who, speed)
set NPC 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.Normally you would only give an NPC ID number to set NPC speed, but if you want to use an npcreference it will still work. Just remember that set NPC speed changes every copy of the NPC on the map, not just the specific one you referenced.
NPC is walking (who)
NPC is walking
Returns true if the specified NPC is currently walking. Returns false if the NPC is standing still. You can use either an npcreference or the NPC's ID number to specify which NPC will be checked.
get NPC ID (reference)
get NPC ID
This command is the opposite of npcreference. If you give get NPC ID a reference to an NPC it will return the NPC&s ID. If the NPC ID is not valid then

get NPC ID

will return -1

In some older versions, This command was useful if you needed to do an alternpc or a setnpcspeed on an NPC that you are working with by reference. This is no longer neccisary, because both those commands now support NPC references (although they still affect every copy of that NPC on the map)

NPC copy count (ID)
NPC copy count
This command tells you how many copys of a particular NPC ID exist on the map. This can be very useful if you want apply the same action to each copy of an NPC on the map. However if the NPCs with t
include,plotscr.hsd

#---NPC copy count example---

plotscript,every NPC example,begin

variable(loop,guard count,current guard)

# the guard is NPC 10, and there are many copies of him on the map guard count := NPC copy count(10)

# this loop repeats once for each copy of NPC 10 for(loop,0,guard count) do,begin

current guard := NPC reference(10,loop) walk NPC(current guard,south,4) # if we added a "wait for NPC(current guard)" right here # then the guards would walk one at time

end

# but we want them to all walk at the same time, # so we just wait here wait for all

end
change NPC ID (reference,new ID)
change NPC ID
This command takes an npcreference and lets you change the ID number of the NPC it points to. This means that the NPC will now use a different picture, an different palette, a different walking speed, an different text box, everything. This change is not permanent. It only lasts until the next time a map gets loaded.
create NPC (ID,X,Y,direction)
create NPC
This command will magically create a new copy of an NPC with the given ID number. You can specify an X and Y position where it will be created, and optionally a direction too (if you leave out the direction, the new NPC will be facing south). create NPC returns an npcreference that you can use to refer to the new NPC in other commands like walknpc. If the new NPC cannot be created (there is a maximum of 300 total NPC copies in memory at a time) then create NPC will return false (zero). The new NPC is not permanent. It only lasts until a new map is loaded.
destroy NPC (reference)
destroy NPC
This command will erase the specified NPC. You can use either an npcreference or the NPC's ID number. The deletion is not permanent. Unless this is an NPC that you created with createnpc, the NPC will be back again next time the map gets loaded. If you need to permanently remove an NPC, use tags.

This only deletes the one NPC you specify. If you use an NPC ID number as the argument, only the first copy of the NPC on the map will be deleted

put npc (who,x,y)
put npc
Moves an NPC to a location on the map in pixels. The first argument is and npcreference or an NPC ID number. The second and third arguments are the X,Y pixel position relative to the top left corner of the map. Be aware that using this command can mis-align your NPC with the tile-grid, preventing it from walking normally. To position the NPC by tile, use the setnpcposition command.

# Moving the Camera

camera follows hero (who)
camera follows hero
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)
camera follows NPC
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 camerafollowshero.
pan camera (direction,distance,pixelstep)
pan camera
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 waitforcamera. To revert the camera to normal, use camerafollowshero.
focus camera (x,y,speed)
focus camera
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 waitforcamera. To revert the camera to normal, use camerafollowshero.
put camera (x,y)
put camera
This command causes the top left corner of the camera to instantly jump to the specified X,Y pixel coordinates of the map. These coordinates are in units of pixels, not tiles. To position the camera by tiles, just multiply the tile position by 20. To revert the camera to normal, use camerafollowshero.

# Text Boxes

show text box (number)
show text box
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 waitfortextbox command.
show text box(2) # Show a text box wait for text box # wait until the player continues
advance text box
advance text box
Advances a text box just as if the player had pressed a key. For use while suspendboxadvance is active.
current text box
current text box
Returns the number of the currently displayed text box, or -1 if there's none.

# Triggering and Showing Stuff

fight formation (number)
fight formation
Starts a battle with the numbered enemy formation. This command returns false if you lost or ran from battle, or true if you won. However, if you lose the battle, the game will still end as normal unless you set a death script. (This command implies a one-tick wait)
setdeathscript
use NPC (who)
use NPC
Remotely trigger an NPC. You can use either an npcreference or an NPC ID number. Whatever actions are associated with triggering that NPC will be taken, text box, script, vehicle, item, whatever. (This command implies a one-tick wait)
game over
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. This command is similar to resetgame, the main difference being that if the title screen and load screen have been disabled, it will completely exit the game, taking you back to the game select screen, or exiting to the operating system.
reset game
reset game
Resets and starts a new game, skipping both title and load game screens. It can be necessary to use this instead of gameover as it will not exit the program if the title screen and load screen have been disabled. It always resets the game back to the beginning.
show value (number)
show value
Displays the number in the bottom left corner of the screen. Useful for count-down timers, and for debugging complicated scripts.
show no value
show no value
Gets rid of the number in the bottom left corner of the screen after a showvalue command.
cancel map name display
cancel map name display
If the map name is being displayed, this command makes it disappear. For example, this may be useful if you want the map name to appear when you enter a map normally, but not when you jump to the map for a plotscripted cutscene.
show backdrop (number)
show backdrop
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
show map
shows the map again after a showbackdrop command
use shop (shop)
use shop
Takes you directly to a shop. You can specify the shop's ID number or its name in the form shop:name
main menu
main menu
Takes you directly to the main menu.
show mini map
show mini map
Displays the mini-map
items menu
items menu
Takes you directly to the items menu. Note that if the player uses an item that calls up a text box, the items menu command will behave like a showtextbox command for that text box.
status screen (who)
status screen
Takes you directly to a hero's status screen. Specify the hero using its position in the party 0-3. Use findhero if you want to specify the hero by name. The pickhero command can also be useful.
spells menu (who)
spells menu
Takes you directly to a hero's spells menu. Specify the hero using its position in the party 0-3. Use findhero if you want to specify the hero by name. The pickhero command can also be useful.
equip menu (who)
equip menu
Takes you directly to a hero's equip menu. Specify the hero using its position in the party 0-3. Use findhero if you want to specify the hero by name. The pickhero command can also be useful. If you do not specify any hero, the first hero in the party will be used.
save menu (reallysave)
save menu
Takes you directly to the save menu. Will return a number 1-4 indicating the slot the player saved in, or false if the player did not save. You can optionally pass an argument of false to make the menu display without actually saving
autosave
saveinslot
load menu (reallyload)
load menu
Displays the load game menu. The player can load a game or select New Game or Exit/Cancel. If the player picks New Game then the calling script continues, otherwise the current game is terminated and either quits to the titlescreen (if there is one) or a game is loaded. If you want the New Game option to actually reset the game, call resetgame immediately after

load menu

. You can optionally pass an argument of false to make the menu display without actually loading or quiting. If you do this, you'll need to interpret the return value to find out which option the player selected: positive values are save slot numbers, 0 means New Game and -1 is Quit.
loadfromslot
order menu
order menu
Takes you directly to the order menu, where you can change the order of the heroes in your active party.
team menu
team menu
Takes you directly to the team menu, where you can change the order of the heroes in your active party, and swap heroes in and out of your reserve.

# Adding and Removing

party money
party money
Returns how much money your party has.
get money (amount)
get money
Adds the specified amount to your party's money
lose money (amount)
lose money
Subtracts the specified amount from your party's money.
set money (amount)
set money
Changes the amount of money your party has.
pay money (amount)
pay money
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.
if(pay money(1000)) then, begin get item(item:uber sword) end, else, begin show text box(61) # ha ha, no uber sword for you! wait for text box end
add hero (who)
add hero
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. This command returns the party slot that the hero was added to, or -1 if both the active and reserve parties are completely full.
delete hero (who)
delete hero
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)
swap in hero
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)
swap out hero
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)
lock hero
Locking a hero prevents the player from moving the hero on the party menu. Locked heroes in the active party cannot be moved into the reserve, and locked heroes in the reserve are completely hidden. Also prevents a hero from being moved by swapinhero or swapouthero. Use the constants defined in your HSI file. They are in the form of hero:name
unlock hero (who)
unlock hero
Reverses lockhero, 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)
swap by name
Swaps two named heroes 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)
swap by position
Swaps two heroes in your party based on their positions in the party
get item (item,number)
get item
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)
delete item
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
unequip (hero,slot)
unequip
Removes the item that the specified hero has equipped in the specified slot. The first argument is the position of the hero in your party, 0-3 for the active party, 4-40 for the reserve. (use findhero if you want to refer to the hero by name). The second argument is the slot to unequip. Use the number 1-5 or the names slot:weapon, slot:armor, etc.
force equip (hero,slot,item)
force equip
Forces a hero to equip an item, even if it is not normally equipable. The first argument is the position of the hero in your party, 0-3 for the active party, 4-40 for the reserve. (use findhero if you want to refer to the hero by name). The second argument is the slot to equip. Use the number 1-5 or the names slot:weapon, slot:armor, etc. The third argument is the item to equip. you can use the item's number or the item:name constants from your .HSI file.
equip where (hero,item)
equip where
Returns the number of the slot that a hero can equip an item in, or false if the hero cannot equip it. The first argument is the position of the hero in your party, 0-3 for the active party, 4-40 for the reserve. (use findhero if you want to refer to the hero by name). The second argument is the item to check the equipability of. you can use the item's number or the item:name constants from your .HSI file.
check equipment (hero,slot)
check equipment
Returns the number of the item that the specified hero has equipped in the specified slot, or -1 if there is nothing equipped there. The first argument is the position of the hero in your party, 0-3 for the active party, 4-40 for the reserve. (use findhero if you want to refer to the hero by name). The second argument is the slot to check. Use the number 1-5 or the names slot:weapon, slot:armor, etc.
get default weapon (hero)
get default weapon
Returns the number of the item that the specified hero uses as a default weapon when no other weapon is equipped. The argument is the position of the hero in your party, 0-3 for the active party, 4-40 for the reserve. (use findhero if you want to refer to the hero by name).
set default weapon (hero,item)
set default weapon
Changes the item that the specified hero uses as a default weapon when no other weapon is equipped. The first argument is the position of the hero in your party, 0-3 for the active party, 4-40 for the reserve. (use findhero if you want to refer to the hero by name). The second argument is the item to use as the new default weapon. you can use the item's number or the item:name constants from your .HSI file.
give experience (hero,amount)
give experience
Gives experience to either a hero by position in party (use result returned by findhero command) or the whole active party, if the constant party is passed as first argument. If you give experience to the whole battle party, then it will be split amongst the heroes as it is in battle; dead heroes get experience depending on whether the "Dead heroes gain share of experience" general bitset is set. This command can cause heroes to level up and learn spells but does not inform the player or trigger any effects. See herolevelled and spellslearnt for dealing with this. You should use setexperience to remove experience in a way that allows delevelling.

# Effects

play song (song)
play song
Plays the specified song. Use the constants defined in your HSI file. They appear in the form of song:name
current song
current song
Returns the number of the currently playing song, or -1 if none.
stop song
stop song
Stops whatever music is currently playing.
set victory music (song)
set victory music
Changes the after-battle victory music to the specified song. Use the constants defined in your HSI file. They appear in the form of song:name
get victory music
get victory music
Returns the number of the after-battle victory music. Compare with the constants defined in your HSI file. They appear in the form of song:name
set ambient music (song)
set ambient music
Plays a song and sets it as the map's ambient music, that is the song that is played when you enter the map (if you call savemapstate with mapstate:all or mapstate:mapsettings) or after a textbox with 'restore music' set. Unless you save the mapstate, the effect goes away if you change maps or fight a battle. You can use the constants song:silence and song:sameaslastmap for

song

, the deault is silence.
playsong
get ambient music
get ambient music
Returns the song number of the map's ambient music, either a song ID or the constants song:silence or song:sameaslastmap.
currentsong
set music volume (volume)
set music volume
Sets the volume at which music is played,

volume

being a number on the scale of 0 to 255, 0 being silent, 255 loudest. If you want to manipulate the sound (e.g. fading out the music) you should take note of the original vulume that the player has set and return to this. The default volume is not the maximum 255, so you should not hardcode fades to begin at volume 255.

The actual resolution at which the volume is set is not necessarily 1/255th of full volume but depends on your implementation. Currently vanilla OHR uses only 0-15 internally, so 240-255 all translate to the same volume, etc.

get music volume
get music volume
Returns the volume at which music is played, on a scale of 0 to 255, 0 being silent, 255 loudest.
fade screen out (red,green,blue)
fade screen out
Fades the screen to a solid color. If you do not specify any arguments, the screen will fade to black. The red, green, 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 fadescreenin, fight a battle, or use a door.
fade screen in
fade screen in
Fades the screen back to normal after a fadescreenout command, or applies the changes made with other palette commands such as greyscalepalette, tweakpalette, resetpalette, and writecolor.
load palette (palette number)
load palette
Loads a different master palette (one of the palettes on the "View Master Palettes..." menu), and the user interface colors for that palette. Use this if a backdrop or entire map was imported/drawn with a palette other than the default. Changes to the palette do not take effect until you call updatepalette or fadescreenin, however the UI colors are changed immediately.
update palette
update palette
Instantly returns from fade screen out, and applies changes made by other palette command such as greyscalepalette, tweakpalette, resetpalette, and writecolor.
greyscale palette (first, last)
greyscale palette
Converts a section of the master palette from color to greyscale. The two arguments determine what range of colors will be affected. If called with no arguments, the entire palette is affected. Changes do not take effect until you call updatepalette or fadescreenin. Changes to the master palette last as long as you are playing, but are not stored in saved-games. If you need to make master-palette changes persist in saved-games you will have to use the on-load plotscript trigger.
tweak palette (red, green, blue, first, last)
tweak palette
Color-adjusts a section of the master palette. The first three arguments are the changes to make to the red, green, and blue values of each palette color. For example, tweak palette (20,-30,0) would redden everything, and drop out most of the green. These arguments expect values in the range -63 to 63, NOT -255 to 255. The last two arguments determine what range of colors will be affected. If they are left out, the entire palette is affected. Changes do not take effect until you call updatepalette or fadescreenin. Changes to the master palette last as long as you are playing, but are not stored in saved-games. If you need to make master-palette changes persist in saved-games you will have to use the on-load plotscript trigger.
reset palette
reset palette
Reloads the default master palette and its user interface colors, undoing any changes you have made with other palette-altering commands such as tweakpalette or greyscalepalette Changes to the palette do not take effect until you call updatepalette or fadescreenin, however the UI colors are changed immediately.
read color (index, element)
read color
Returns a color value from the master palette. The first argument is the index in the palette to read from, 0 to 255. The second argument is the color value to read, red, green, or blue. You can use 0,1, and 2, or you can use the predefined constants colorred, colorgreen, and colorblue. The counterpart to this is writecolor.

This command operates on values from 0-63. For operation on full color values (0-255), see getcolor

getcolor
write color (index, element, value)
write color
Writes a color value into the master palette. The first argument is the index in the palette to write to, 0 to 255. The second argument is the color value to write, red, green, or blue. You can use 0, 1, and 2, or you can use the predefined constants colorred, colorgreen, and colorblue. The third argument is the color value to write. It can be in the range of 0 to 63. Changes do not take effect until you call updatepalette or fadescreenin The counterpart to this is readcolor. Changes to the master palette last as long as you are playing, but are not stored in saved-games. If you need to make master-palette changes persist in saved-games you will have to use the on-load plotscript trigger.
setcolor
get color(index)
get color
Returns a color value from the master palette. The argument is which index in the palette to return. The value is a 32-bit number representing the red, green and blue components of the palette entry. See rgb for more details on its format.
setcolor
extractcolor
set color(index, value)
set color
Updates the master palette with a new 32-bit color. The

value

, a 32-bit number representing the red, green and blue components of the color, can come from rgb or getcolor.
getcolor
rgb
RGB(red, green, blue)
RGB
Combines the individual red, green and blue components of a color into a single 32-bit number. The formula used is "red * 256 * 256 + green * 256 + blue". The highest byte is unused, but reserved for future potential use for alpha transparency.
extractcolor
extract color(color, component)
extract color
Takes a 32-bit color value, and extracts the red, green or blue component, based on the

component

parameter. You may use the colorred, colorgreen and colorblue parameters to choose which one.
rgb
play sound (num,loop,preempt)
play sound
Plays or resumes a sound effect. Pass true to

loop

if you want the sound effect to start over when it finishes instead of stopping. Pass true to

preempt

if you want to automatically stop the sound before playing it. If

preempt

is false, and the sound is already playing, this command will do nothing.
stopsound
stop sound (num)
stop sound
Stops a sound effect. If the sound is not playing, nothing will happen.
playsound
pause sound (num)
pause sound
Temporarily stops a sound effect. It can be resumed with playsound, wherein it will continue from whence it left off.
playsound
sound is playing (num)
sound is playing
Checks to see whether a sound effect is playing or not. Useful for synchronization, etc.
playsound
stopsound

# Hero's Spells

teach spell (hero,attack)
teach spell
Tries to teach a hero a spell. The first argument is the hero's position in the party (as returned by findhero). The second argument is the attack to learn. You can use the names defined in your .HSI file in the form atk:attackname (You may also use the attack's ID number. This is the number you see in the attack editor + 1). If the hero is capable of learning the spell, teach spell will return true, or if the hero cannot learn the spell it will return false. Note that this only works when a spell is set to "learned from item". It will not work for spells learned based on level.
forget spell (hero,attack)
forget spell
Causes a hero to forget a spell. The first argument is the hero's position in the party (as returned by findhero). The second argument is the attack to forget. You can use the names defined in your .HSI file in the form atk:attackname (You may also use the attack's ID number. This is the number you see in the attack editor + 1). If the hero does not know the spell, nothing happens.
read spell (hero,list,slot)
read spell
Returns the ID number of a chosen spell slot, or 0 (false) if there is no spell in that slot. The first argument is the hero's position in the party (as returned by findhero). The second argument is the number of the spell list to check. This is a value from 0 to 3. The third argument is the slot to check. This is a number from 0 to 23. Spell slots are numbered in rows, so the first row is 0,1,2 the second row is 3,4,5, and so-on.
write spell (hero,list,slot,attack)
write spell
Forces a hero to learn a particular spell. The first argument is the hero's position in the party (as returned by find hero). The second argument is the spell list to put the spell in. This is a number from 0 to 3. The third argument is the slot to put the spell in. This is a number from 0 to 23. Spell slots are numbered in rows, so the first row is 0,1,2 the second row is 3,4,5, and so-on. The last argument is the attack to put in the spell list. You can use the names defined in your .HSI file in the form atk:attackname (You may also use the attack's ID number. This is the number you see in the attack editor + 1). You can also erase a spell by writing 0 or none as the attack ID. Note that this command will overwrite and replace any spell that is already in that slot. If you overwrite a slot that can normally learn another spell, you will never learn that other spell (unless you first erase the spell you wrote there)
knows spell (hero,attack)
knows spell
Checks to see if a hero already knows a spell. The first argument is the hero's position in the party (as returned by findhero). The second argument is the attack to check for. You can use the names defined in your .HSI file in the form atk:attackname (You may also use the attack's ID number. This is the number you see in the attack editor + 1). If the hero knows the spell, knows spell will return true. If the hero does not know the spell, it will return false
can learn spell (hero,attack)
can learn spell
Checks to see if a hero is capable of learning a spell from an item or from the teach spell command. The first argument is the hero's position in the party (as returned by findhero). The second argument is the attack to check for. You can use the names defined in your .HSI file in the form atk:attackname (You may also use the attack's ID number. This is the number you see in the attack editor + 1). If the hero can learn the spell, can learn spell will return true. If the hero cannot learn the spell (or learns it from levelups), it will return false
spellslearned
spells learnt
spells learned (hero,number)
spells learned
Returns the id numbers (+1) of spells the hero learned from the last battle (for heroes in the active battle party) or giveexperience, setherolevel or setexperience command that involved this hero. If the second argument is getcount then the number of spells that the hero learned is returned. Pass 0 for number to get the first spell learnt, 1 the second, etc. You can use a loop and strings to list to the player all the spells a hero learned:

If you want to use this command with attack ID numbers, you must add 1 to the ID number.

# the following script uses strings 0, 1, 2 for its use (will be overwritten) plotscript, print learned spells, who=0, begin variable(i) get hero name (1, who) # construct the static part of the text in string 1 $1+" learned spell " for (i, 0, spells learned (who, get count) -- 1) do ( read attack name (2, spells learned (who, i)) # get the i-th spell learnt 0 $= 1 # copy the static part to the displayed string 0 $+ 2 # combine with the spell name show string at (0, 160, 100) wait for keypress (anykey) ) hide string (0) end
update level up learning(who, allowforget)
update level up learning
Update a hero to make sure they know the spells they are supposed to have learned for their current level. The

who

is the hero's position in the battle party. You can optionally pass false as the

allowforget

argument if you want to make sure the hero will not forget any spells that they are not supposed to know yet. This spell is most useful for situations where you are manipulating the heros level, and for some reason do not want to use setherolevel which automatically handles learning. This command can also be handy when playtesting a game in progress, since it can be used to make sure that heroes loaded from a saved-game will learn spells that did not exist yet at the time when they got their last level-ups.
outsidebattlecure
outside battle cure
map cure (attack, target, attacker)
map cure
Uses an attack on a hero outside of battle as if you had used it from an item or cast it as a spell. In spite of the name, it works for both cure spells and damage spells. The first argument,

attack

is name of the attack from your HSI file in the form atk:name. (You may also use the attack's ID number. This is the number you see in the attack editor + 1.) The second argument,

target

is the position in the party of the hero to cure (or harm). The third optional argument,

attacker

is the position in the party of the hero who is using the attack. If this argument is ommitted or set to -1, then the average stats of the active party will be used, just like when the attack is used from an item. The return value is true if the cure/attack succeeded, and false if it did nothing.

The

map cure

command replaces the old command

outside battle cure

which had a bug which required you to use

atk:name -- 1

# Mouse Functions

init mouse
init mouse
Initializes the mouse, returning true if one is present. This command should be run before any mouse functions are be used. It causes the normal mouse cursor to be hidden when over the game's window, and causes mouse clicks to trigger on-keypress scripts. Therefore, it is a good idea to place this command in the newgame and loadgame scripts if you are going to use the mouse.

Running this command does not draw a cursor on screen - your script must do this itself by placing a slice or npc at the appropriate location.

Here is an example:
include,plotscr.hsd

#Mouse cursor example

plotscript, display mouse, begin

#start up the mouse init mouse

#loop while the game is running while (true) do,begin

#NPC 0 is the mouse cursor put npc (0, mouse pixel x + camera pixel x, mouse pixel y + camera pixel y) wait end end
mouse pixel X
mouse pixel X
Returns the X coordinate in pixels of the mouse on the screen.
mouse pixel Y
mouse pixel Y
Returns the Y coordinate in pixels of the mouse on the screen.
mouse button (which)
mouse button
Returns true if the specified mouse button is pressed. You can use the constants leftbutton and rightbutton to specify the button.
put mouse (X, Y)
put mouse
Changes the location of the mouse on the screen, in pixels. Note that this function might do nothing, if the game's window is not active. initmouse should be called before this command is used.
mouse region (x min, x max, y min, y max)
mouse region
Constricts the mouse to a rectangular part of the window/screen, such as a choice selection box. It is recommend you do not use this command, as it is very annoying in windowed mode. The maximum values are inclusive. Call without arguments to free the mouse to leave the window. initmouse should be called before this command is used.

# String Functions

When refering to a position in a string,

position

is a 1-based index into the string, not a 0-based index. For example, given a string "ABCDEFG", position=3 is "C", not "D". This is because the string commands are based on BASIC string commands, which are 1-based. This also means that position 0 is invalid. Beware!There is no limit on string length (previously, they were limited to 40 characters, the width of the screen)
show string (ID)
show string
Displays string #ID in the bottom left corner of the screen, as with the showvalue command. Use shownovalue to remove the string from the screen. Note that this command displays the value of the string at the moment the command was run. Later changes to the value of the string will not appear unless you run show string again. If you need real-time display of changes to a string, use showstringat or centerstringat instead.
showvalue
shownovalue
showstringat
centerstringat
clear string(ID)
clear string
Erases the string buffer #ID to the empty string (""). That's all.
append ascii (ID, char)
append ascii
Appends the character with ascii code 'ascii' to the string with ID #ID. Remember: Numbers are 48 - 57, uppercase letters are 65 - 90, lowercase letters are 97 - 122.
appendnumber
append number (ID, number)
append number
Appends the textual representation of

number

to the string with ID #

ID

. For example, append number(1,65) will append "65", not "A".
appendascii
number from string (ID, default)
number from string
Try to read the string specified by

ID

as a number and return it. Blank spaces at the beginning of the string will be ignored, and thre string can start with a - sign for negatives. No other characters except numerical digits can appear in the string. You can also provide an optional default value that will be returned if the string is not a valid number (for example, if it contains a non-numeric letter)
appendnumber
copy string (dest, source)
copy string
Copies the text from string #

source

to string #

dest

, overwriting the existing string completely. If you prefer, you can write

dest $= source

instead. You must supply string id numbers, not strings, as arguments.
concatenate strings (dest, source)
concatenate strings
Copies the text from string #

source

to string #

dest

. However, unlike copystring, the text is appended to the end of

dest

. If you prefer, you can write

dest $+ source

instead. You must supply string id numbers, not strings, as arguments.
string length (ID)
string length
Returns the length of string #

ID

.
string compare (ID1, ID2)
string compare
Returns true if the two strings #

ID1

and #

ID2

are identical, case sensitive.
replace char (ID, position, char)
replace char
Replaces the character at

position

in string #

ID

with a character with ascii code

char

. The first position of the string is 1, and the last position of the string is the same as stringlength.
delete char (ID, position)
delete char
This deletes the character at

postion

in string #

ID

, causing all the following characters to move over a slot. The first position of the string is 1, and the last position of the string is the same as stringlength.
ascii from string (ID, position)
ascii from string
Returns the ascii code of the character at

position

in string #

ID

. The first position of the string is 1, and the last position of the string is the same as stringlength. If you pass 0 as the position or a position past the end of the string, 0 will be returned.
string to globals (ID, starting global, length)
string to globals
This command will fill global variables (starting with #

starting global

), up to

length

globals, with the ascii values of the characters in string #

ID

. If the string is not long enough, the rest of the globals in this "field" are padded with the value 256.
globalstostring
globals to string(ID, starting global, length)
globals to string
This command is the opposite of stringtoglobals. It will build a new string in slot #

ID

, using the ascii values from the global variables #

starting global

and

length

globals thereafter. Pass the same value for

length

as you did to stringtoglobals if you don't know the length of the string. If a global has a value greater than 255, the value will be ignored.
stringtoglobals
get hero name (ID, hero)
get hero name
This command will take the name of hero #

hero

, and stick it in string #

ID

, overwriting its contents.

Remember that this command expects the hero's position in the party, not the hero:name constants nor the hero's position in the walkabout party. If you want to get the name of a hero according to their position in the walkabout party, you should use herobyrank and findhero

# This example gets the name of the leader and stores it in string ID 1

get hero name (1,find hero(hero by rank(0)))
set hero name (ID, hero)
set hero name
This command will take string #

ID

, and set hero #

hero

's name to it.
get item name (ID, item)
get item name
This command will take the name of item #

item

and stick it in string #

ID

, overwriting its contents. This can be useful for "You got <item>!" type messages.
get map name (ID, map)
get map name
This command will take the name of map #

map

and stick it in string #

ID

, overwriting its contents.
readattackname
get attack name
read attack name (ID, attack)
read attack name
This command will take the name of

attack

and stick it in string #

ID

, overwriting its contents. Use the

atk:name

constants from your HSI file.

If you want to use this command with attack ID numbers, you must add 1 to the ID number.

This command replaces the old

get attack name

which required you to use

atk:name -- 2

or the attack id number

-- 1

get global string (ID, global)
get global string
This command will take the name of global string #

global

and stick it in string #

ID

, overwriting its contents. Global strings include every text string in the game, such as prompts and messages. See the Global String Editor in CUSTOM for a list of all of them. Due to the way global strings are stored internally, not all values of #

global

will produce valid results.
input string (ID, maxlength, use current, center, position x, position y)
input string
Allows the player to type in a string. Returns false if they press ESC to cancel. All arguments are optional:

ID

is the string you want to use, default is string #0.

maxlen

is the length of input, if left blank the limit will be set to 40 (max visible onscreen length).

use current

is whether you want to add to the existing string, or clear the string before typing. The default is to clear the string before typing, valid arguments are true or false.

center

centers the string input at position x/y. If left blank the string will use its current positioning. Otherwise, valid arguments are true or false. If the string is not visible, then it will automatically be placed onscreen (centered if not specified) and hidden when done.

position x

and

position y

are optional, and are the position at which the string will be shown as it is being typed. The default values are 160,110.
show string at (ID, x, y)
show string at
Displays string #

ID

on the screen, positioning its top left corner at the given (

x

,

y

) coordinates. Unlike showstring, changes to the string will be displayed in real-time.
center string at (ID, x, y)
center string at
Displays string #

ID

on the screen, positioning its top-middle at the given (

x

,

y

) coordinates. Unlike showstring, changes to the string will be displayed in real-time.

The string is not re-centered automatically if its length changes. If you change the string and want to keep it centered, call showstringat again. Otherwise, its topleft corner will stay fixed.

hide string (ID)
hide string
Makes a string previously displayed with showstringat or centerstringat disappear. Has no effect on strings displayed with showstring
string is visible (ID)
string is visible
Returns true if a string is being displayed by showstringat or centerstringat. Otherwise, returns false. Is not effected by showstring
string style (ID, style)
string style
Changes the appearance of a string previously displayed with showstringat or centerstringat. Choice of

style

is string:outline and string:flat. string:outline is the style of string you are familiar with in textboxes: they are outlined with colour 0 (black). string:flat have not outline but can have a solid background of any colour behind the string.
string color (ID, foreground color, background color)
string color
Changes the color of a string previously displayed with showstringat or centerstringat. Foreground color is the colour of the text itself. Background color has no meaning for style:outline strings (the outline is always black). For style:flat strings, it is the color of the solid background if 1 to 255, or causes no background if 0. If you ommit

background color

, the background will be transparent.
positionstring (ID, x, y)
position string
Positions the top left corner of string #

ID

at the given

x

,

y

coordinates. Unlike showstringat, this command will not affect the visibility of a string.
string X (ID)
string X
Returns the horizontal X position of the top left corner of string #

ID

string Y (ID)
string Y
Returns the vertical Y position of the top left corner of string #

ID

get song name (ID, song)
get song name
Gets the name of song #

song

and puts it in string #

ID

.
search string (ID1, ID2, start)
search string
Searches the string for a specified string, returns the position at which the string was found.

start

is the position at which you want to start looking, default is 1.

ID1

is the the string you want to search,

ID2

is the string expression you want to find. Returns false if the string wasn't found
trim string (ID, start, length)
trim string
Cuts the string to the specified length, OR removes blank space from the beginning and ends of the string.

ID

is the string you want to be cut. If you wish to cut

ID

to a certain length, you must specify

start

and

length

.

start

is the position at which you want to start cutting, anything to the left of this number will be deleted in a string.

length

is the size of the string you want to preserve, anything to the right of this number will be deleted in a string. If you leave these parameters blank, it will trim whitespace from the beginning and ends of

ID

.
string from textbox (ID, textbox, line, expand)
string from textbox
Loads text from the

line

in a

textbox

into a string

ID

. The command automatically erases white spaces from the begining of the string and end of the string. Valid numbers for

line

are 0-7. If

expand

is true, then codes like ${H1} in the string will be substituted automatically.
expandstring
expand string(ID)
expand string
Expands codes in

ID

like ${H1}. This does the same thing that textboxes do automatically.

# Menu Functions

open menu (ID, allow duplicate)
open menu
Opens the menu specified by

ID

. You can also use the constants defined in your HSI file in the form menu:name. The menu will be opened on top of any menus that are already open. The optional second argument

allow duplicates

can be true if you want to be able to open more than one copy of the same menu at the same time. The return value is a menu handle that you should store in a variable for use with other menu-related commands.
create menu
create menu
Create a new empty menu. You can add menu items to it with the addmenuitem command. The return value is a menu handle that you should save in a variable for use with other menu related commands. Menus created with this command have the "Allow gameplay" bitset turned on by default.
close menu(menu handle)
close menu
Close a menu. The argument is a

menu handle

(for example, the one returned by openmenu or topmenu)
top menu
top menu
Return a menu handle for the topmost menu. Returns false if no menus are open
bottom menu
bottom menu
Return a menu handle for the bottom menu (the menu underneath all other open menus). Returns false if no menus are open
previous menu(menu handle)
previous menu
Return a menu handle for the menu beneath the one specified by

menu handle

, or false if there is no menu underneath
variable(menu) menu := topmenu while(menu) do, begin # do things to each menu menu := previous menu(menu) end
next menu(menu handle)
next menu
Return a menu handle for the menu on top of the one specified by

menu handle

, or false if there is no menu on top
variable(menu) menu := bottom menu while(menu) do, begin # do things to each menu menu := next menu(menu) end
bring menu forward(menu handle)
bring menu forward
Given a

menu handle

(for example, the one return by bottommenu), move the menu to the top of all other open menus
find menu ID(menu ID)
find menu ID
Given a

menu ID

number or a constant in the form of

menu:name

, Check to see if it is already open, and return a menu handle to it.
menu is open(menu handle)
menu is open
Given a

menu handle

(for example, the one returned by

open menu

), Check to see if it is already open, and return true if it is, or false if it is not
add menu item(menu handle)
add menu item
Given a

menu handle

(for example, the one returned by createmenu), Add a new menu item to the end of the menu. Returns a menu item handle, which you can store in a variable for use with commands like setmenuitemcaption or setmenuitemtype.
delete menu item(menu item handle)
delete menu item
Given a

menu item handle

(for example, the one returned by addmenuitem or selectedmenuitem), delete the menu item from the menu.
select menu item(menu item handle)
select menu item
Given a

menu item handle

(for example, the one returned by addmenuitem), Move the menu selection cursor to point to that menu item
selected menu item(menu handle)
selected menu item
Returns the handle for the selected menu item in the topmost menu, false if no menus are open, or, when given an optional

menu handle

(for example, the one returned by openmenu) returns the selected item in that menu.
use menu item(menu item handle)
use menu item
Given a

menu item handle

(for example, the one returned by selectedmenuitem), activate the menu item. This will cause whatever actions (text box, menu, script, tag changes) that have been configured for this menu item to be triggered.
first menu item(menu handle)
first menu item
Given a

menu handle

(for example, the one returned by openmenu), Return a menu item handle for the menu item at the top of the menu.
menu item by slot(menu handle, slot, visible only)
menu item by slot
Given a

menu handle

(for example, the one returned by openmenu), Return a menu item handle for the menu item at the position specified by

slot

. The first slot in the menu is 0. You can optionally include invisible items by using the optional argument

visible only

, which defaults to true. Note that invisible menu items are always at the end of the menu, after the last visible menu item
menuitemslot
menu item slot(menu item handle)
menu item slot
Given a

menu item handle

(for example, the one returned by addmenuitem), return a the slot number of the menu item. The first slot in the menu is 0.
menuitembyslot
next menu item(menu item handle, visible only)
next menu item
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Return a menu item handle for the menu item below the specified one, or false there is no next menu item. You can optionally include invisible items by using the optional argument

visible only

, which defaults to true. Note that invisible menu items are always at the end of the menu, after the last visible menu item
variable(mi) mi := first menu item while(mi) do, begin # do things to each menu item mi := next menu item(mi) end
previous menu item(menu item handle, visible only)
previous menu item
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Return a menu item handle for the menu item above the specified one, or false there is no previous menu item. You can optionally include invisible items by using the optional argument

visible only

, which defaults to true. Note that invisible menu items are always at the end of the menu, after the last visible menu item
variable(m) m := previous menu item(selected menu item)
find menu item caption(menu handle, string ID, search after handle, visible only)
find menu item caption
Given a

menu handle

(for example, the one returned by openmenu), and a string identified by

string ID

, Search the menu for a menu item with a label that is the same as the string, and return a handle to the matching menu item. The optional third argument

search after handle

is a menu item handle to start searching after instead of searching from the top of the menu. The optional fourth argument

visible only

is a true or false value that determines whether or not to include hidden items. It defaults to true.
variable(menu, mi) menu := open menu(menu:test menu) $0="Puppies" mi := find menu item caption(menu, 0) while(mi) do, begin # do something to each menu item labelled "Puppies" mi := find menu item(menu, 0, mi) end
get menu item caption(menu item handle, string ID)
get menu item caption
Given a

menu item handle

(for example, the one returned by selectedmenuitem), take the caption and copy it into the string identified by

string ID

set menu item caption(menu item handle, string ID)
set menu item caption
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Replace the caption with the string identified by

string ID

get menu item type(menu item handle)
get menu item type
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Return the type of the menu item
set menu item type(menu item handle, new type)
set menu item type
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Change the type of the menu item to

new type

. Available constants are:

menutype:label

,

menutype:special

,

menutype:menu

,

menutype:textbox

, and

menutype:script

get menu item subtype(menu item handle)
get menu item subtype
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Return the subtype of the menu item. The meaning of the subtype varies depending on the type.
setmenuitemsubtype
set menu item subtype(menu item handle, new subtype)
set menu item subtype
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Change the subtype of the menu item to

new subtype

. The meaning of the subtype varies depending on the type of the menu item. For menutype:special you can use constants like:

menuspecial:items

,

menuspecial:spells

,

menuspecial:status

,

menuspecial:equip

,

menuspecial:order

,

menuspecial:team

,

menuspecial:orderteam

,

menuspecial:map

,

menuspecial:save

,

menuspecial:load

,

menuspecial:quit

, and

menuspecial:volume

. For menutype:textbox you can use the textbox's ID number. For menutype:menu you can use the menu's ID number or a menu:name constant from your HSI file. For menutype:script you can use script references in the form @scriptname
get menu item tag(menu item handle, whichtag)
get menu item tag
Given a

menu item handle

(for example, the one returned by selectedmenuitem), and a tag number

whichtag

which can be 1 or 2, Return the a tag required for the menu item to be available. The tag number will be positive if the tag needs to be ON, or negative if the tag needs to be OFF
set menu item tag(menu item handle, new tag, whichtag)
set menu item tag
Given a

menu item handle

(for example, the one returned by selectedmenuitem), and a tag number

whichtag

which can be 1 or 2, Set the tag required for the menu item to

new tag

. Use a positive number if the tag needs to be turned ON, and a negative number if the tag needs to be turned OFF
get menu item settag(menu item handle)
get menu item settag
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Return the number of the tag that will be set when the menu item is selected. The tag number will be positive if the tag will be set ON, or negative if the tag will be set OFF
set menu item settag(menu item handle, new settag)
set menu item settag
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Change the tag that will be set when the menu item is selected. Use a positive number if the tag should be turned ON, and a negative number if the tag should be turned OFF
get menu item togtag(menu item handle)
get menu item togtag
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Return the number of the tag that will be toggled when the menu item is selected. (The tag number will always be a positive number)
set menu item togtag(menu item handle, new settag)
set menu item togtag
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Change the tag that will be toggled when the menu item is selected. (the tag number will always be positive)
get menu item bit(menu item handle, bit)
get menu item bit
Given a

menu item handle

(for example, the one returned by selectedmenuitem), and bit number

bit

, Return true if the bitset is ON, and false if the bitset is OFF. You can use constants for the

bit

bit number in the form of

menu item bit:Hide when disabled

and

menu item bit:Close menu if selected

set menu item bit(menu item handle, bit, value)
set menu item bit
Given a

menu item handle

(for example, the one returned by selectedmenuitem), and bit number

bit

, Set the bitset is ON or OFF depending on

value

. You can use constants for the

bit

bit number in the form of

menu item bit:Hide when disabled

and

menu item bit:close menu when selected

get menu item extra(menu item handle, extra)
get menu item extra
Given a

menu item handle

(for example, the one returned by selectedmenuitem), and an

extra

data number which can be 0, 1, or 2, return the the number stored in the extra data space. This extra data has no meaning of its own, and is just useful for advanced menu scripting.
set menu item extra(menu item handle, extra, num)
set menu item extra
Given a

menu item handle

(for example, the one returned by selectedmenuitem), and an

extra

data number which can be 0, 1, or 2, change the number stored in the extra data space to

num

. This extra data has no meaning of its own, and is just useful for advanced menu scripting.
get menu bit(menu handle, bit)
get menu bit
Given a

menu handle

(for example, the one returned by topmenu), and bit number

bit

, returns true if the bitset is ON, and false if the bitset is OFF. For the

bit

bit number you should use one of the constants:

- menubit:translucent box
- menubit:never show scrollbar
- menubit:allow gameplay
- menubit:suspend player even if gameplay allowed
- menubit:no box
- menubit:no close
- menubit:no controls
- menubit:prevent main menu

set menu bit(menu handle, bit, value)
set menu bit
Given a

menu handle

(for example, the one returned by topmenu), and bit number

bit

, sets the bitset is ON or OFF depending on

value

. For the

bit

bit number you should use one of the constants:

- menubit:translucent box
- menubit:never show scrollbar
- menubit:allow gameplay
- menubit:suspend player even if gameplay allowed
- menubit:no box
- menubit:no close
- menubit:no controls
- menubit:prevent main menu

parent menu(menu item handle)
parent menu
Given a

menu item handle

(for example, the one returned by selectedmenuitem), Return a menu handle for the menu that the menu item belongs to.
get menu ID(menu handle)
get menu ID
Given a

menu handle

(for example, the one returned by parentmenu), Return a the ID number of the menu, or -1 if the men was created with the createmenu command.
swap menu items(handle1, handle2)
swap menu items
Given two menu item handles (for example, the ones returned by selectedmenuitem and nextmenuitem) switch the positions of the two menu items. Note that this works both to rearrange menu items within one menu, or to move menu items between different menus
get menu boxstyle(menu handle)
get menu boxstyle
Given a

menu handle

(for example, the one returned by openmenu), Return a the boxstyle of the menu. This will be a number from 0 to 15
set menu boxstyle(menu handle, new box style)
set menu boxstyle
Given a

menu handle

(for example, the one returned by openmenu), Change the boxstyle of the menu.

new box style

will be a number from 0 to 15
get menu textcolor(menu handle)
get menu textcolor
Given a

menu handle

(for example, the one returned by openmenu), Return a the text color of the menu. This will be a number from 0 to 255
set menu textcolor(menu handle, new textcolor)
set menu textcolor
Given a

menu handle

(for example, the one returned by openmenu), Change the text color of the menu.

new textcolor

will be a number from 0 to 255. 0 is the default color.
get menu max rows(menu handle)
get menu max rows
Given a

menu handle

(for example, the one returned by openmenu), Return a max rows to display of the menu, or 0 if the menu is auto-sizing. If the actual number of menu items is larger than the max rows, the menu will be scrollable.
set menu max rows(menu handle, new max rows)
set menu max rows
Given a

menu handle

(for example, the one returned by openmenu), Change the max rows to display of the menu to

new max rows

. Use 0 if you want the menu to be auto-sizing. If the actual number of menu items is larger than the max rows, the menu will be scrollable.
get menu offset x(menu handle)
get menu offset x
Given a

menu handle

(for example, the one returned by openmenu), Return the x offset position of the menu in pixels relative to the center of the screen.
getmenuoffsety
setmenuoffsetx
setmenuoffsety
get menu offset y(menu handle)
get menu offset y
Given a

menu handle

(for example, the one returned by openmenu), Return the y offset position of the menu in pixels relative to the center of the screen.
getmenuoffsetx
setmenuoffsetx
setmenuoffsety
set menu offset x(menu handle, new x)
set menu offset x
Given a

menu handle

(for example, the one returned by openmenu), Change the x offset position of the menu in pixels relative to the center of the screen.
getmenuoffsetx
getmenuoffsety
setmenuoffsety
set menu offset y(menu handle, new y)
set menu offset y
Given a

menu handle

(for example, the one returned by openmenu), Change the y offset position of the menu in pixels relative to the center of the screen.
getmenuoffsetx
getmenuoffsety
setmenuoffsetx
get menu anchor x(menu handle)
get menu anchor x
Given a

menu handle

(for example, the one returned by openmenu), Return the x anchor position of the menu. The return value will be

align:center

,

align:left

or

align:right

getmenuanchory
setmenuanchorx
setmenuanchory
get menu anchor y(menu handle)
get menu anchor y
Given a

menu handle

(for example, the one returned by openmenu), Return the y anchor position of the menu. The return value will be

align:center

,

align:top

or

align:bottom

getmenuanchorx
setmenuanchorx
setmenuanchory
set menu anchor x(menu handle, new anchor)
set menu anchor x
Given a

menu handle

(for example, the one returned by openmenu), Change the horizontal x anchor position of the menu. The

new anchor

can be

align:center

,

align:left

or

align:right

getmenuanchorx
getmenuanchory
setmenuanchory
set menu anchor y(menu handle, new anchor)
set menu anchor y
Given a

menu handle

(for example, the one returned by openmenu), Change the vertical y anchor position of the menu. Change the horizontal x anchor position of the menu. The

new anchor

can be

align:center

,

align:top

or

align:bottom

getmenuanchorx
getmenuanchory
setmenuanchorx
get menu text align(menu handle)
get menu text align
Given a

menu handle

(for example, the one returned by openmenu), Return the text alignment of the menu. The return value will be

align:center

,

align:left

or

align:right

setmenutextalign
set menu text align(menu handle, new align)
set menu text align
Given a

menu handle

(for example, the one returned by openmenu), Change the text alingment of the menu. The

new align

can be

align:center

,

align:left

or

align:right

getmenutextalign
get menu min chars(menu handle)
get menu min chars
Given a

menu handle

(for example, the one returned by openmenu), Return the minimum width of the menu in chars, or 0 for menus that have their width autodetected.
setmenuminchars
set menu min chars(menu handle, new min)
set menu min chars
Given a

menu handle

(for example, the one returned by openmenu), Change the minimum width of the menu in chars, or use 0 to make the menu width autodetected.
getmenuminchars
get menu max chars(menu handle)
get menu max chars
Given a

menu handle

(for example, the one returned by openmenu), Return the maximum width of the menu in chars, or 0 for menus that do not have a maximum.
setmenumaxchars
set menu max chars(menu handle, new max)
set menu max chars
Given a

menu handle

(for example, the one returned by openmenu), Change the maximum width of the menu in chars, or use 0 for no maximum
getmenumaxchars
get menu border(menu handle)
get menu border
Given a

menu handle

(for example, the one returned by openmenu), Return the border thickness of the menu in pixels. Positive numbers indicate a thicker border. Negative numbers indicate a thinner border.
setmenuborder
set menu border(menu handle, new border)
set menu border
Given a

menu handle

(for example, the one returned by openmenu), Change the border thickness of the menu in pixels. Positive numbers will result in a thicker border. Negative numbers will result in a thinner border.
getmenuborder
get menu on close script(menu handle)
get menu on close script
Given a

menu handle

(for example, the one returned by openmenu), Return a script id for the script that will be run when the menu is closed, or

false

if there is none. This command is only useful with scripts that have the

allow gameplay and scripts

bitset turned on.
variable(m, s) m := open menu(5) s := get menu on close script(m) run script by id(s)
runscriptbyid
setmenuonclosescript
set menu on close script(menu handle, script id)
set menu on close script
Given a

menu handle

(for example, the one returned by openmenu), Assign script id that will be run when the menu is closed, or

false

to disable any on-close script that has already been set. The script trigger only takes effect the next time you close the menu. If you re-open the menu again, you will need to re-set the on-close script again. This command is only useful with scripts that have the

allow gameplay and scripts

bitset turned on.
variable(m, s) m := open menu(5) set menu on close script(m, @my menu exit handler)
runscriptbyid
setmenuonclosescript

# Sprite Functions

load hero sprite (num, palette)
load hero sprite
Loads hero battle sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replaceherosprite!
replaceherosprite
freesprite
replace hero sprite (handle, num, palette)
replace hero sprite
Loads hero battle sprite #

num

with palette

palette

into sprite

handle

. As with loadherosprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadherosprite.

loadherosprite
freesprite
load walkabout sprite (num, palette)
load walkabout sprite
Loads walkabout sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replacewalkaboutsprite!
replacewalkaboutsprite
freesprite
replace walkabout sprite (handle, num, palette)
replace walkabout sprite
Loads walkabout sprite #

num

with palette

palette

into sprite

handle

. As with loadwalkaboutsprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadwalkaboutsprite.

loadwalkaboutsprite
freesprite
load small enemy sprite (num, palette)
load small enemy sprite
Loads small enemy sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replacesmallenemysprite!
replacesmallenemysprite
freesprite
replace small enemy sprite (handle, num, palette)
replace small enemy sprite
Loads small enemy sprite #

num

with palette

palette

into sprite

handle

. As with loadsmallenemysprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadsmallenemysprite.

loadsmallenemysprite
freesprite
load medium enemy sprite (num, palette)
load medium enemy sprite
Loads medium enemy sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replacemediumenemysprite!
replacemediumenemysprite
freesprite
replace medium enemy sprite (handle, num, palette)
replace medium enemy sprite
Loads medium enemy sprite #

num

with palette

palette

into sprite

handle

. As with loadmediumenemysprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadmediumenemysprite.

loadmediumenemysprite
freesprite
load large enemy sprite (num, palette)
load large enemy sprite
Loads large enemy sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replacelargeenemysprite!
replacelargeenemysprite
freesprite
replace large enemy sprite (handle, num, palette)
replace large enemy sprite
Loads large enemy sprite #

num

with palette

palette

into sprite

handle

. As with loadlargeenemysprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadlargeenemysprite.

loadlargeenemysprite
freesprite
load attack sprite (num, palette)
load attack sprite
Loads attack battle sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replaceattacksprite!
replaceattacksprite
freesprite
replace attack sprite (handle, num, palette)
replace attack sprite
Loads attack battle sprite #

num

with palette

palette

into sprite

handle

. As with loadattacksprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadattacksprite.

loadattacksprite
freesprite
load weapon sprite (num, palette)
load weapon sprite
Loads weapon battle sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replaceweaponsprite!
replaceweaponsprite
freesprite
replace weapon sprite (handle, num, palette)
replace weapon sprite
Loads weapon battle sprite #

num

with palette

palette

into sprite

handle

. As with loadweaponsprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadweaponsprite.

loadweaponsprite
freesprite
load border sprite (num, palette)
load border sprite
Loads border battle sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replacebordersprite!
replacebordersprite
freesprite
replace border sprite (handle, num, palette)
replace border sprite
Loads border battle sprite #

num

with palette

palette

into sprite

handle

. As with loadbordersprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadbordersprite.

loadbordersprite
freesprite
load portrait sprite (num, palette)
load portrait sprite
Loads portrait battle sprite #

num

with palette

palette

, and returns a handle. You may omit

palette

, in which case the default palette for that sprite will be loaded. You must free it with freesprite when you are done.Do not load a sprite onto another sprite that has not been freed. Either use freesprite first, or use replaceportraitsprite!
replaceportraitsprite
freesprite
replace portrait sprite (handle, num, palette)
replace portrait sprite
Loads portrait battle sprite #

num

with palette

palette

into sprite

handle

. As with loadportraitsprite, you may omit

palette

, in which case the default palette for that sprite will be loaded. This function is used when you merely wish to change the sprite, but not move it or anything. You must free it with freesprite when you are done.

You may use this on any sprite, not just ones loaded with loadportraitsprite.

loadportraitsprite
freesprite
free sprite (handle)
free sprite
Unloads a sprite loaded by any of the "load x sprite" functions. This removes the sprite from the screen and removes it from memory. It is a good idea to free sprites when you are completely done with them. Unlike freeslice, this command only works on sprites, but it will still also free any children of the sprite it is freeing regardless of what kind of children they are. The only purpose of this command is additional error checking.
freeslice
loadherosprite
clone sprite (handle)
clone sprite
Returns a new handle to a duplicate of a sprite. If you clone a sprite, remember that you will need to call freesprite on both the original and the clone.
loadherosprite
freesprite
put sprite (handle, x, y)
put sprite
Moves sprite

handle

to position (

x

,

y

). This can only be used on sprites, use putslice in general.
putsprite
place sprite
get sprite type (handle)
get sprite type
Gets the type of sprite slice

handle

, or returns -1 if the slice is not a sprite. You can compare the result with the following constants:

- spritetype:hero
- spritetype:small enemy
- spritetype:medium enemy
- spritetype:large enemy
- spritetype:walkabout
- spritetype:weapon
- spritetype:attack
- spritetype:border
- spritetype:portrait

getspritesetnumber
getspritepalette
getspriteframe
get sprite set number (handle)
get sprite set number
Gets the number of the spriteset of a slice sprite

handle

.
getspritetype
getspritepalette
getspriteframe
set sprite palette (handle, num)
set sprite palette
Changes the palette of sprite

handle

to be

num

. If

num

is -1 or omitted, the default palette for that sprite is loaded.
getspritepalette
get sprite palette (handle)
get sprite palette
Returns the palette of sprite

handle

.
getspritetype
getspritesetnumber
getspriteframe
set sprite frame (handle, num)
set sprite frame
Changes the frame of sprite

handle

to be

num

. If

num

is less than 0, or greater than or equal to the number of frames, nothing will change.
getspriteframe
get sprite frame (handle)
get sprite frame
Returns the current frame number of sprite

handle

.
getspritetype
getspritepalette
getspritesetnumber
sprite frame count (handle)
sprite frame count
Returns the total number of available frames for a given sprite

handle

.
sprite layer
sprite layer
Returns a slice handle for the layer which contains slices created with commands such as loadherosprite, createrect and others. You can use this together with firstchild if you want to loop through all your slices without knowing their handles. This is the default parent of all new slices.
variable(sl) sl := first child(sprite layer) while (sl) do, begin if (slice is sprite(sl)) then, begin # do an operation on each sprite end sl := next sibling(sl) end
horiz flip sprite (handle, flip)
horiz flip sprite
Flips a sprite

handle

horizontally. You can also unflip a previously flipped sprite using

horiz flip sprite(handle, false)

vertflipsprite
spriteishorizflipped
vert flip sprite (handle, flip)
vert flip sprite
Flips a sprite

handle

vertically. You can also unflip a previously flipped sprite using

vert flip sprite(handle, false)

horizflipsprite
spriteisvertflipped
sprite is horiz flipped (handle)
sprite is horiz flipped
Returns true if a sprite

handle

is flipped horizontally, or false if it is not.
horizflipsprite
spriteisvertflipped
sprite is vert flipped (handle)
sprite is vert flipped
Returns true if a sprite

handle

is flipped vertically, or false if it is not.
vertflipsprite
spriteishorizflipped

# Slice Functions

load slice collection (id)
load slice collection
Loads a collection of slices that you have defined in the slice collection editor. The argument is the

id

number of the collection. The return value is a handle to the container that holds the loaded collection.
lookup slice (lookup code, start slice)
lookup slice
Search for an important slice using a lookup code, and return a handle to it, or 0 if it is not found. User defined slice lookup codes are defined in the slice collection editor. You will find them as constants in your .hsi file with sli: prefixes. There are also some special slice lookup codes with names that start with sl: prefixes. You can optionally specify a slice for the

lookup slice

command to start searching from, but if you do not, the whole slice tree will be searched.

Although the user-defined slice lookup codes are always safe to use for any purpose, There is a lot of potential mischief that you can do with a handle to a special slice. If you do anything dubious, like reordering, reparenting, or god forbid freeing the special slice, don't expect your scripts to work in later versions of the engine, which are likely to impose stricter restrictions! You may parent your own slices to these special slices, but moving special slices around is definitely a bad idea.

Be aware that when there is more than one slice with the same lookup code, the

lookup slice

command will only return the first one it finds in a depth-first search. If you need to find multiple slices with the same lookup code, you must search manually using getslicelookup. You may setparent a slice to a map layer to make it move with the camera just like heros and NPCs do.
# this example loads a saved slice collection, # and gets a handle to a slice in it that you # have marked with a slice lookup code name. variable(collection, sl) collection := load slice collection(5) sl := lookup slice(sli:my special slice, collection)
# this example gets a handle to the portrait of the currently displaying # text box (if any) and allows you to manipulate it. variable(portrait) protrait = lookup slice(sl:textbox portrait) if(portrait) then( replace portrait sprite(portrait, 5) )

# This is a list of special slice lookup codes lookup slice(sl:textbox text) lookup slice(sl:textbox portrait) lookup slice(sl:textbox choice0) lookup slice(sl:textbox choice1) lookup slice(sl:script layer) lookup slice(sl:textbox layer) lookup slice(sl:string layer) lookup slice(sl:maproot) lookup slice(sl:map layer0) lookup slice(sl:map layer1) lookup slice(sl:map layer2) lookup slice(sl:map layer3) lookup slice(sl:map layer4) lookup slice(sl:map layer5) lookup slice(sl:map layer6) lookup slice(sl:map layer7)
setslicelookup
getslicelookup
get slice lookup (handle)
get slice lookup
Returns the lookup code of a slice, or false if it has none. You can compare the result with the

sli:

slice lookup values in your hsi file, or with the

sl:

special lookup values in plotscr.hsd
lookupslice
setslicelookup
set slice lookup (handle, code)
set slice lookup
Changes the lookup code of a slice. The first argument is the slice handle, the second is the new lookup code. You can pass false as the second argument to remove a slice's lookup code. This command works with the

sli:

slice lookup values in your hsi file. It does not work with the

sl:

special lookup values in plotscr.hsd, nor can it modify the lookup code of slices that already have special lookup codes. Only user-defined lookup codes can be changed. Built-in special lookup codes cannot.
lookupslice
getslicelookup
create container (width, height)
create container
Create a new container slice and return a handle to it. Containers are invisible slices used only for grouping other slices. You can optionaly specify a

width

and

height

for the container.
variable(holder, sl) holder := create container(200,100) sl := load hero sprite(0) set parent(sl, holder) set horiz align(sl, edge:left) sl := load hero sprite(1) set parent(sl, holder) set horiz align(sl, edge:right)
The example above creates a container and then puts two hero sprites inside it, one aligned left and one aligned right. If you move or resize the container, the sprites inside it will also be moved.
create rect (width, height, style)
create rect
Create a new rectangle slice and return a handle to it. You can provide an optional

width

and

height

, and an optional

style

. The style is text box style number from 0 to 14, or -1 for an unstyled box. The default is box style 0. Like all slice types, a rect slice can be used as a container for other slices with setparent
slice is valid (id)
slice is valid
Returns true if the given

id

is a valid sprite handle. The main use of this command is to check whether a slice has been deleted, avoiding a script error.
slice is sprite (handle)
slice is sprite
Returns true if the given slice

handle

is a sprite.
slice is container (handle)
slice is container
Returns true if the given slice

handle

is a container.
slice is rect (handle)
slice is rect
Returns true if the given slice

handle

is a rect.
slice is text (handle)
slice is text
Returns true if the given slice

handle

is a text slice.
slice x (handle)
slice x
Returns the x position of any slice, for example a sprite. This position is relative to the slice's parent, and may depend upon the slice's Align settings.
slicey
setslicex
slicescreenx
slice y (handle)
slice y
Returns the y position of any slice, for example a sprite. This position is relative to the slice's parent, and may depend upon the slice's Align settings.
slicex
setslicey
slicescreeny
put slice (handle, X, Y)
put slice
Changes the position of any slice, for example a sprite. This position is relative to the slice's parent, and may depend upon the slice's Align settings.
putsprite
putslicescreen
set slice x (handle, X)
set slice x
Changes the x position of any slice, for example a sprite. This position is relative to the slice's parent, and may depend upon the slice's Align settings.
putslice
slicex
setslicey
set slice y (handle, Y)
set slice y
Changes the y position of any slice, for example a sprite. This position is relative to the slice's parent, and may depend upon the slice's Align settings.
putslice
slicey
setslicex
slice screen x (handle)
slice screen x
Returns the screen X position of any slice. This position is relative to the screen, so it is calculated based on not only the slice's X position, but also its alignment, and the position and size of its parents.
slicescreeny
slicex
slice screen y (handle)
slice screen y
Returns the screen Y position of any slice. This position is relative to the screen, so it is calculated based on not only the slice's Y position, but also its alignment, and the position and size of its parents.
slicescreenx
slicey
put slice screen (handle, x, y)
put slice screen
Change the screen position of any slice. The position of the slice relative to its parent will automatically be corrected. Alignment and anchor will not be changed. Note that this does not work when a slice is filling its parent.
putslice
slicescreenx
setslicescreeny
set slice screen x (handle, x)
set slice screen x
Change the screen X position of any slice. The position of the slice relative to its parent will automatically be corrected. Alignment and anchor will not be changed. Note that this does not work when a slice is filling its parent.
putslicescreen
slicescreenx
setslicescreeny
set slice screen y (handle, y)
set slice screen y
Change the screen Y position of any slice. The position of the slice relative to its parent will automatically be corrected. Alignment and anchor will not be changed. Note that this does not work when a slice is filling its parent.
putslicescreen
slicescreeny
setslicescreenx
slice width (handle)
slice width
Returns the width of any slice, for example a sprite.
sliceheight
setslicewidth
slice height (handle)
slice height
Returns the height of any slice, for example a sprite.
slicewidth
setsliceheight
set slice width (handle, width)
set slice width
Changes the width of a container slice or a rect slice. This command does not work on sprite slices because they have a fixed width.
slicewidth
setsliceheight
set slice height (handle, height)
set slice height
Changes the height of a container slice or a rect slice. This command does not work on sprite slices because they have a fixed height.
sliceheight
setslicewidth
slice edge x (handle, edge)
slice edge x
Returns the x position of a particular edge of a slice. use the constants

edge:left

,

edge:center

,

edge:right

sliceedgey
setsliceedgex
setsliceedgey
slice edge y (handle, edge)
slice edge y
Returns the y position of a particular edge of a slice. use the constants

edge:top

,

edge:middle

,

edge:bottom

sliceedgex
setsliceedgex
setsliceedgey
set slice edge x (handle, edge, value)
set slice edge x
Changes the x position of a specific edge of a slice. This is like setslicex, except that you can set by any edge regardless of the slice's anchor. Use the constants

edge:left

,

edge:center

,

edge:right

sliceedgex
sliceedgey
setsliceedgey
set slice edge y (handle, edge, value)
set slice edge y
Changes the x position of a specific edge of a slice. This is like setslicey, except that you can set by any edge regardless of the slice's anchor. use the constants

edge:top

,

edge:middle

,

edge:bottom

sliceedgex
sliceedgey
setsliceedgex
set horiz align (handle, edge)
set horiz align
Changes the horizontal alignment of any slice relative to its parent. The available edges are

edge:left

,

edge:center

,

edge:right

. The default value is edge:left.
setvertalign
sethorizanchor
setvertanchor
set vert align (handle, edge)
set vert align
Changes the vertical alignment of any slice relative to its parent. The available edges are

edge:top

,

edge:middle

,

edge:bottom

. The default value is edge:top.
sethorizalign
sethorizanchor
setvertanchor
set horiz anchor (handle, edge)
set horiz anchor
Changes the horizontal anchor of any slice. The available anchor values are

edge:left

,

edge:center

,

edge:right

. The default value is edge:left.
setvertalign
sethorizalign
setvertanchor
set vert anchor (handle, edge)
set vert anchor
Changes the vertical anchor of any slice. The available anchor values are

edge:top

,

edge:middle

,

edge:bottom

. The default value is edge:top.
setvertalign
sethorizalign
sethorizanchor
realign slice (handle, horiz align, vert align, horiz anchor, vert anchor)
realign slice
A quick way to set the alignment and optionally the anchor of a slice with a single command. If you leave out the arguments for the anchor then only the alignment will be changed.
sethorizalign
setvertalign
sethorizanchor
setvertanchor
center slice (handle)
center slice
A quick way to center the alignment and the anchor of a slice with a single command.
sethorizalign
setvertalign
sethorizanchor
setvertanchor
set slice visible (handle, vis)
set slice visible
Makes slice

handle

invisible or visible, according to

vis

. Slices are automatically visible when you load them, but you can make them invisible with

set slice visible(handle, off)

. If the slice has children, they will become invisible too.
setslicevisible
set sprite visible
get slice visible (handle)
get slice visible
Returns the visibilty setting for slice

handle

. This is true for visible, or false for invisible. Note that this only tells you if the slice is set to be invisible, it will not tell you if the slice is invisible for some other reason, such as if it is offscreen, or if it is the child of an invisible parent or grandparent.
set slice clipping (handle, clip)
set slice clipping
Changes whether or not a slice will clip its children if they overflow its edges. The first argument is a slice

handle

. The second argument is true to make the slice clip, or false to allow its children to overflow. (newly created slices do not clip by default)
get slice clipping (handle)
set slice clipping
Returns true if the slice

handle

is set to clip drawing its children, or false if child slices are allowed to be drawn overflowing its edges.
free slice (handle)
free slice
Unloads a slice and any child slices. This works on any type of slice. This removes the slice from the screen and removes it from memory. You should free your slices after you are completely done with them.
script, simple example, begin variable(sl) sl := load hero sprite(0) wait(20) free slice(sl) end

script, example with children, begin variable(box, sl)

# create a box box := create rect(100, 60)

# center a hero as a child of the box sl := load hero sprite(0) set parent(sl, box) center slice(sl)

wait(20)

# when you free the box, the hero will be freed too free slice(box)

# The sprite is gone now, so if you use the handle that used to point # to it, you will get an error message in your g_debug.txt file position sprite(sl, 25, 25) end

script, wrong way to free in a loop, begin # this loop is the WRONG way to remove all sprites that show frame number 1 # because removing a slice inside a loop will interfere with the "next sibling" # command causing the loop to end early variable(sl) sl := first child(sprite layer) while(sl) do, begin if(slice is sprite(sl)) then, begin if(get sprite frame(sl) == 1) then(free slice(sl)) end sl := next sibling(sl) end end

script, right way to free in a loop, begin # this loop is the right way to remove all sprites that show frame number 1 # by waiting until AFTER the "next sibling" command, we can free the slice # without ending the loop early variable(sl, deleteme) sl := first child(sprite layer) while(sl) do, begin deleteme := 0 if(slice is sprite(sl)) then, begin if(get sprite frame(sl) == 1) then(deleteme := sl) end sl := next sibling(sl) if(deleteme) then(free slice(deleteme)) end end
freesprite
freeslicechildren
free slice children (handle)
free slice children
Frees all the children of a slice, but not the slice itself. See freeslice for more details.
freeslice
slice child (handle, number)
slice child
Returns a handle for the nth child of a slice, counting from 0. Returns

false

if

number

is too large (

last child(handle)

is equivalent to

slice child(handle, child count(handle) -- 1)

). Note that you will need to use firstchild and nextsibling to iterate over the children of a slice, rather than this command, when you are moving the children around.
childcount
parentslice
firstchild
lastchild
first child(handle)
first child
Returns a slice handle for the first child of a given slice

handle

. Returns

false

if the slice has no children. You can use this to loop through all the children of a slice.
variable(sl) sl := first child(sprite layer) while (sl) do, begin if (slice is sprite(sl)) then, begin # do an operation on each sprite end sl := next sibling(sl) end
slicechild
firstspritechild
firstrectchild
firstcontainerchild
lastchild
childcount
last child(handle)
last child
Returns a slice handle for the last child of a given slice

handle

. Returns

false

if the slice has no children.
slicechild
firstchild
childcount
next sibling(handle)
next sibling
Returns a slice handle for the next sibling of a given slice

handle

. Returns

false

if the given slice is the last sibling of its parent. This is useful when looping through slices.
variable(sl) sl := first child(sprite layer) while (sl) do, begin if (slice is sprite(sl)) then, begin # do an operation on each sprite end sl := next sibling(sl) end
previoussibling
nextspritesibling
nextrectsibling
nextcontainersibling
slicechild
freeslice
slicetofront
slicetoback
movesliceabove
moveslicebelow
previous sibling(handle)
previous sibling
Returns a slice handle for the previous sibling of a given slice

handle

, the inverse of nextsibling . Returns

false

if the given slice is the first sibling of its parent. This is useful when looping through slices.
nextsibling
slicechild
freeslice
slicetofront
slicetoback
movesliceabove
moveslicebelow
first sprite child(handle)
first sprite child
Returns a slice handle for the first sprite child of a given slice

handle

. Returns

false

if the slice has no sprite children. Children of other types will be ignored. This is useful when looping through sprites.
firstchild
nextspritesibling
next sprite sibling(handle)
next sprite sibling
Returns a slice handle for the next sprite sibling of a given slice

handle

. Returns

false

if the given slice is the last sprite sibling of its parent. Slices of other types will be ignored. This is useful when looping through sprites.
firstspritechild
nextsibling
first rect child(handle)
first rect child
Returns a slice handle for the first rect child of a given slice

handle

. Returns

false

if the slice has no rect children. Children of other types will be ignored. This is useful when looping through rects.
firstchild
nextrectsibling
next rect sibling(handle)
next rect sibling
Returns a slice handle for the next rect sibling of a given slice

handle

. Returns

false

if the given slice is the last rect sibling of its parent. Slices of other types will be ignored. This is useful when looping through rects.
firstrectchild
nextsibling
first container child(handle)
first container child
Returns a slice handle for the first container child of a given slice

handle

. Returns

false

if the slice has no container children. Children of other types will be ignored. This is useful when looping through containers.
firstchild
nextcontainersibling
next container sibling(handle)
next container sibling
Returns a slice handle for the next container sibling of a given slice

handle

. Returns

false

if the given slice is the last container sibling of its parent. Slices of other types will be ignored. This is useful when looping through containers.
firstcontainerchild
nextsibling
parent slice (handle)
parent slice
Returns a slice handle for the parent of slice

handle

, or 0 if

handle

is the root slice.
setparent
checkparentage
slicechild
set parent (handle, parent handle)
set parent
Moves a slice

handle

to a different

parent handle

. A slice is connected to its parent, and is positioned based on its parent's position. When you move a slice to a new parent, it will become that parent's last child, meaning it will be drawn on top of any other children that the parent already had.
parentslice
checkparentage
slicechild
check parentage (handle, parent handle)
check parentage
Checks to see if

handle

is a child (or grandchild, or great-grandchild, etc...) of

parent handle

. Returns true or false.
parentslice
child count (handle)
child count
Returns the number of children that slice

handle

has.
slicechild
firstchild
slice to front (handle)
slice to front
Sort a slice

handle

so that it is drawn in front of other slices with the same parent. This is done by moving it to the end of its parent's child list. If you use this command inside a loop that iterates through slices using nextsibling be careful not to accidentally create an endless loop.
script, simple example, begin # As long as you are not looping with the "next sibling" command # then "slice to front" is safe and easy to use. variable(sl) sl := first child(sprite layer) slice to front(sl) end

script, dangerous sorting, begin # this is an example of the WRONG way to move all rect slices to the # front in a loop. Because moving a slice to the front adds it to the # end of the list, the loop will go on forever. variable(sl) sl := first child(sprite layer) while(sl) do, begin if(slice is rect(sl)) then, begin slice to front(sl) end sl := next sibling(sl) end end

script, safe sorting, begin # This is an example of the right way to move all rect slices to the # front in a loop. By remembering which slice was last before the # loop starts (or by using "previous sibling") it is safe to move slices # to the end of the sibling list. # We also ensure the rects stay in the same relative order by writing # the loop so that we move the last slice to front if it is a rect. variable(sl, last, prev) last := last child(sprite layer) sl := first child(sprite layer) while(sl && sl <> last) do, begin prev := sl sl := next sibling(sl) if(slice is rect(prev)) then(slice to front(prev)) end end

script, easier safe sorting, begin # If you need to sort slices in a loop, you might find it easier # to avoid the "slice to front" command and use "set sort order" # and "sort children" instead. variable(sl) sl := first child(sprite layer) while(sl) do, begin if(slice is rect(sl)) then, begin set sort order(sl, 1) end sl := next sibling(sl) end sort children(sprite layer) end
slicetoback
movesliceabove
slice to back (handle)
slice to back
Sort a slice

handle

so it will be drawn behind other slices with the same parent. If you use this command inside a loop, be careful not to accidentally create an endless loop. Moving a slice to the back also moves it to the first position of its parent's sibling list.
script, simple example, begin # As long as you are not looping with the "next sibling" command # then "slice to back" is safe and easy to use. variable(sl) sl := load hero sprite(0) slice to back(sl) end

script, dangerous sorting, begin # This is an example of the WRONG way to move all rect slices to the # back in a loop. Because moving a slice to the back moves it to the # top of the list, the loop will be restarted each time variable(sl) sl := first child(sprite layer) while(sl) do, begin if(slice is rect(sl)) then, begin slice to back(sl) end sl := next sibling(sl) end end

script, safe but incorrect sorting, begin # This is an example of a safe way to move all the rect slices to the # back. HOWEVER the order in which all the rects will be drawn will # be reversed! That might be alright for your need. # By moving the slice AFTER using the "next sibling" command we avoid # re-starting the loop. variable(sl, moveme) sl := first child(sprite layer) while(sl) do, begin moveme := 0 if(slice is rect(sl)) then, begin moveme := sl end sl := next sibling(sl) if(moveme) then(slice to back(moveme)) end end

script, correct sorting, begin # This is an example of one right way to move all rect slices to the # back with a loop and preservw relative ordering between the rects. # Note that we ensure the rects stay in the same relative order by writing # the loop so that we also move the 'first' slice to back if it is a rect. variable(sl, first, prev) first := first child(sprite layer) sl := last child(sprite layer) while(sl && sl <> first) do, begin prev := sl sl := previous sibling(sl) if(slice is rect(prev)) then(slice to back(prev)) end end

script, easier safe sorting, begin # If you need to sort slices in a loop, you might find it easier # to avoid the "slice to back" command and use "set sort order" # and "sort children" instead. variable(sl) sl := first child(sprite layer) while(sl) do, begin if(slice is rect(sl)) then, begin set sort order(sl, -1) end sl := next sibling(sl) end sort children(sprite layer) end
slicetofront
moveslicebelow
move slice above (handle, above what handle)
move slice above
Given a slice

handle

, move it so that it is the next sibling of another slice given by

above what handle

(changing its parent if necessary). This will cause it to be drawn immediately after that slice.
moveslicebelow
slicetofront
slicetoback
nextsibling
move slice below (handle, below what handle)
move slice below
Given a slice

handle

, move it so that it is the previous sibling of another slice given by

below what handle

(changing its parent if necessary). This will cause it to be drawn immediately before that slice.
movesliceabove
slicetofront
slicetoback
previoussibling
Y sort children (handle)
Y sort children
Given a slice

handle

, sort all of its children according to their Y position. This means that sibling slices lower on the screen will be drawn over siblings higher on the screen.
sortchildren
set sort order (handle, order)
set sort order
Assign a sort order value to a slice

handle

. This can be any arbitrary number that will be used to sort the slice relative to its sibling slices the next time that sortchildren is called. Give a slice a low number to sort it to the back or a high number to sort it to the front. This means it functions like (or can be used as) a z-depth. If you give two sibling slices the same sort order number they will be sorted to the same depth, and they will remain in their original order in relation to one another.
getsortorder
get sort order (handle)
get sort order
Retrieve the sort order value previously set on a slice

handle

with getsortorder. Note that calling sortchildren by default resets all the sort order values to zero, unless false is passed as

wipe

.
sort children (handle, wipe)
sort children
Given a slice

handle

, sort all of its children according to the sort order that you previously set with the setsortorder command. If no sort order values have been set then no changes will be made to the order of the slices.

wipe

is an optional argument, defaulting to true, which specifies whether to zero out the sort order value for each slice after they have been sorted. This zeroing out behaviour is intended to let you use temporary sort values to perform some sorting operation on sibling slices (see especially the examples to slicetofront and slicetoback).
plotscript, reverse Y sort, begin variable(sl) sl := first child(sprite layer) while(sl) then, begin set sort order(sl, slice y(sl) * -1) sl := next sibling(sl) end sort children(sprite layer) end
setsortorder
getsortorder
ysortchildren
set slice extra (handle, extra, value)
set slice extra
Sets one of three extra data variables that every slice has, on the slice

handle

.

extra

is a number from 0 to 2 which indicates which extra data field to write (you may also use the constants

extra 0

,

extra 1

,

extra 2

). The extra data has no meaning to the slice, it is only for use by scripts.
getsliceextra
get slice extra (handle, extra)
get slice extra
Retrieve an extra data value previously set on a slice

handle

with setsliceextra.

extra

is a number from 0 to 2 which indicates which extra data field to read.
get rect style (handle)
get rect style
Given a rect slice

handle

, return the style it is using. This will be a number from 0 to 14 representing a text box style, or a -1 if the rect is not using a standard style.
setrectstyle
set rect style (handle, style)
set rect style
Given a rect slice

handle

, change the style it uses. The

style

should be a number from 0 to 14 representing a text box style.
getrectstyle
get rect bgcol (handle)
get rect bgcol
Given a rect slice

handle

, return the background color it is using. This will be a number from 0 to 255 representing a color from the master palette.
setrectbgcol
getrectfgcol
set rect bgcol (handle, color)
set rect bgcol
Given a rect slice

handle

, change the background color it uses. The

color

should be a number from 0 to 255 representing a color from the master palette.
getrectbgcol
setrectfgcol
get rect fgcol (handle)
get rect fgcol
Given a rect slice

handle

, return the foreground color it uses for its simple border. This only matters when the rect has no graphical border, or when the graphical border allows the simple border to show through. This will be a number from 0 to 255 representing a color from the master palette.
setrectfgcol
getrectbgcol
set rect fgcol (handle, color)
set rect fgcol
Given a rect slice

handle

, change the foreground color it uses for its simple border. This only matters when the rect has no graphical border, or when the graphical border allows the simple border to show through. The

color

should be a number from 0 to 255 representing a color from the master palette.
getrectfgcol
setrectbgcol
get rect border (handle)
get rect border
Given a rect slice

handle

, return the graphical border it uses. This will be a number from 0 to 14 representing a text box border style, or

border:line

for the old simple line border only, or

border:none

for no border at all.
setrectborder
set rect border (handle, border)
set rect border
Given a rect slice

handle

, change the graphical border it uses. The

border

should be a number from 0 to 14 representing a text box border style, or

border:line

for the old simple line border only, or

border:none

for no border at all.
getrectborder
get rect trans (handle)
get rect trans
Given a rect slice

handle

, returns one of: the constant

trans:fuzzy

if it is drawn semi-transparent,

trans:hollow

if it is fully transparent, or

trans:solid

(equal to false) if it is drawn solid.
setrecttrans
set rect trans (handle, transparency setting)
set rect trans
Given a rect slice

handle

, change how transparently it is drawn. For

transparency setting

, pass in one of the constants

trans:fuzzy

for semi-transparency (checkered),

trans:hollow

for fully transparent (the border drawn only), or

trans:solid

(equal to false) for solid.
getrecttrans
create text
create text
Creates a new blank text slice and returns a handle to it. A text slice holds a string of text, but it can be positioned and handled just like any other slice. Use the setslicetext command to copy a string into the text slice.
setslicetext
set slice text(handle, string id)
set slice text
Copy a string specified by

string id

into the text slice specified by

handle

.
createtext
get text color(handle)
get text color
Given a text slice

handle

, returns the current color of the text.
settextcolor
set text color(handle, color)
set text color
Given a text slice

handle

, change

color

used to display the text.
gettextcolor
get text bg(handle)
get text bg
Given a text slice

handle

, returns the current background color of the text. Note that this only matters if the text slice is not displaying an outline.
gettextcolor
settextbg
set text bg(handle, color)
set text bg
Given a text slice

handle

, change the background

color

used to display the text. This only matters if the text slice is set to not use an outline.
gettextbg
settextcolor
get outline(handle)
get outline
Given a text slice

handle

,

true

if the text slice is configured to display an outline, or

false

if it is configured not to display and outline.
setoutline
set outline(handle, outline)
set outline
Given a text slice

handle

, change whether or not it will be displayed with an outline. If the second argument is omitted or

true

, change the slice to show an outline, if the second argument is

false

change the slice to show no outline.
getoutline
get wrap(handle)
get wrap
Given a text slice

handle

,

true

if the text slice is configured to wrap, or

false

if it is configured not to wrap.
setwrap
set wrap(handle, wrap)
set wrap
Given a text slice

handle

, change whether or not it will wrap. If the second argument is omitted or

true

, change the slice to wrap-mode, if the second argument is

false

change the slice into non-wrapping mode.
getwrap
create grid (width, height, rows, columns)
create grid
Creates a new grid slice, and returns an handle to it. Grid slices are special containers that automatically arrange their children into rows and columns. No manual child positioning is required. The first two arguments are the width and height of the whole grid. The next two arguments are the number of rows and columns that should appear in the grid. If rows or columns are left out, the grid with be a boring 1x1.
slice is grid (handle)
slice is grid
Return true if the

handle

is a grid slice, or false if it is any other type of slice.
set grid columns (handle, columns)
set grid columns
Changes the number of columns in a grid slice. Child slices will be automatically repositioned.
getgridcolumns
setgridrows
getgridrows
get grid columns (handle)
get grid columns
Returns the number of columns in a grid slice.
setgridcolumns
setgridrows
getgridrows
set grid rows (handle, rows)
set grid rows
Changes the number of rows in a grid slice. Child slices will be automatically repositioned.
setgridcolumns
getgridcolumns
getgridrows
get grid rows (handle)
get grid rows
Returns the number of rows in a grid slice.
setgridcolumns
getgridcolumns
setgridrows
show grid (handle, shown)
show grid
Grid slices are normally invisible, but they can optionally display gridlines. This command takes a grid slice

handle

and a true or false value. This command has no effect on the visibility of the grid's children. Don't confuse this command with setslicevisible.
gridisshown
grid is shown (handle)
grid is shown
This command takes a grid slice

handle

and returns true if the grid is showing its optional grid lines. If the grid is in its normal invisible state, this command returns false. Don't confuse this command with getslicevisible.
gridisshown
slice collide point (handle, x, y)
slice collide point
Return true if a given

x

and

y

coordinate point collides with a slice

handle

's screen position.

x

and

y

are pixel coordinates relative to the screen, such as the ones returned by mousepixelx and mousepixely
slicecollide
slice collide (handle1, handle2)
slice collide
Given a pair of slice handles, return true if they collide with one another. Parent/child relationships have nothing to do with this test; it does not matter if the slices are related.
slicecollidepoint
slicecontains
slice contains (handle1, handle2)
slice contains
Return true if the screen position of slice

handle2

is completely inside slice

handle1

. Parent/child relationships have nothing to do with this test; it does not matter if the slices are related.
slicecollide
slice at pixel (parent, x, y, number, check descendants)
slice at pixel
Searches through all the descendants of

parent

for slices containing the given

x

,

y

pixel screen position. To search all your slices, you can normally use spritelayer as

parent

.

number

is an optional argument indicating which slice to return if there is more than one at that point; the bottom most one (returned by default) is number 0. slice at pixel returns 0 if you pass too high a

number

. If you pass getcount as

number

the number of slices at that pixel is returned instead.

check descendants

is an optional argument defaulting to true. If false, then only

parent

's children will be checked, not all its descendants. This command never returns Special slices, such as the sprite layer slice.
slicecollidepoint
findcollidingslice
find colliding slice (parent, slice, number, check descendants)
find colliding slice
Searches through all the descendants of

parent

for slices colliding with the given

slice

(by screen position). To search all your slices, you can normally use spritelayer as

parent

.

number

is an optional argument indicating which slice to return if there is more than one at that point; the bottom most one (returned by default) is number 0. slice at pixel returns 0 if you pass too high a

number

. If you pass getcount as

number

the number of slices at that pixel is returned instead.

check descendants

is an optional argument defaulting to true. If false, then only

parent

's children will be checked, not all its descendants. This command never returns Special slices, such as the sprite layer slice, and ignores collisions with the children of

slice

.
sliceatpixel
slicecollide
clamp slice (handle1, handle2)
clamp slice
Try to move the slice

handle1

so that its screen position will be inside the screen position of slice

handle2

. The size of the slices will not be changed. It does not matter if the slices are related.
slicecontains
set padding (handle, pixels)
set padding
Sets the padding value in pixels for all the edges of a slice

handle

. This is a positive number to move children attached to the edges towards the center of the slice, or a negative number to move attached children further from the center.
settoppadding
setleftpadding
setrightpadding
setbottompadding
get top padding (handle)
get top padding
Get the padding value in pixels for the top edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
settoppadding
getleftpadding
getrightpadding
getbottompadding
set top padding (handle, pixels)
set top padding
Set the padding value in pixels for the top edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
gettoppadding
setleftpadding
setrightpadding
setbottompadding
get left padding (handle)
get left padding
Get the padding value in pixels for the left edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
setleftpadding
gettoppadding
getrightpadding
getbottompadding
set left padding (handle, pixels)
set left padding
Set the padding value in pixels for the left edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
getleftpadding
settoppadding
setrightpadding
setbottompadding
get right padding (handle)
get right padding
Get the padding value in pixels for the right edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
setrightpadding
gettoppadding
getleftpadding
getbottompadding
set right padding (handle, pixels)
set right padding
Set the padding value in pixels for the right edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
getrightpadding
settoppadding
setleftpadding
setbottompadding
get bottom padding (handle)
get bottom padding
Get the padding value in pixels for the bottom edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
setbottompadding
gettoppadding
getleftpadding
getrightpadding
set bottom padding (handle, pixels)
set bottom padding
Set the padding value in pixels for the bottom edge of a slice

handle

. This is a positive number to move children attached to this edge towards the center of the slice, or a negative number to move attached children further from the center.
getbottompadding
settoppadding
setleftpadding
setrightpadding
fill parent (handle, true_or_false)
fill parent
Make a slice

handle

automatically fill its parent. This will change the position and size of the slice so that it completely fills the parent (minus the parent's padding). You can also disable filling with this command by passing

false

as the second argument, such as

fill parent(handle, false)

. If a slice is filling its parent, then any commands which modify the width or height of the slice will fail. You should resize the parent instead. This command only works on rects and containers. It will not work on sprites because they cannot change size.
isfillingparent
is filling parent (handle)
is filling parent
Returns true if a slice

handle

is set to automatically fill its parent, or false if it is not. This command always returns false for sprite slice handles because sprites cannot be set to fill parent.
fillparent

# Zone Functions

write zone (zone id, x, y, value)
write zone
Sets whether the tile at (

x,y

) is part of the specified zone.

zone id

is an ID number from 1 to 9999, and

value

is intrepreted as either

true

(non-zero) or

false

(zero).

Only up to 15 zones may overlap at each tile. If you try to place 16 zones at one tile, write zone will fail, returning false. Normally it returns true. If you choose to "Show all warnings" in General Game Settings in Custom, you will also get a warning message.

readzone
read zone (zone id, x, y)
read zone
Returns true if the tile at (

x,y

) is part of the specified zone.

zone id

is an ID number from 1 to 9999.
writezone
zoneatspot
zone at spot (x, y, count)
zone at spot
Used to get the set of all IDs of zones that contain the tile at (

x,y

). Since zones may overlap,

count

is used to specify which zone ID to return: 0 is the first, 1 the second, and so on.

count

may also be the constant getcount, in which case the total number of zones which overlap there is returned. If

count

is too large, 0 (false) is returned.

The order in which the ID numbers are returned is completely arbitrary.

readzone
zone number of tiles (zone id)
zone number of tiles
Given a

zone id

(from 1 to 9999), returns the number of tiles that the zone contains.

# Misc Functions

random (lownumber, highnumber)
random
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
seed random (new seed)
seedrandom
Reseeds the random number generator. If called with no argument, this will reseed the random number generator to a new random sequence. If you pass in a number (other than 0), the random number generator will be seeded with that number, allowing for repeatable random sequences.
random
item in slot (slot)
item in slot
Return a the item ID number at a specific slot in your inventory. If the inventory slot is empty, it will return -1. Slots are numbered from 0 to getinventorysize-1.
setiteminslot
itemcountinslot
setitemcountinslot
getinventorysize
set item in slot (slot, item)
set item in slot
Change the item ID number at a specific slot in your inventory. The

slot

argument is the position in your inventory screen, and the

item

argument is the item ID number, or one of the

item:name

constants defined in your .hsi file. If you want to erase and item slot, use -1 as the item ID
iteminslot
itemcountinslot
setitemcountinslot
getinventorysize
item count in slot (slot)
item count in slot
Return a the count of items at a specific slot in your inventory, or 0 if that slot is empty. Slots are numbered from 0 to getinventorysize-1.
iteminslot
setiteminslot
setitemcountinslot
getinventorysize
set item count in slot (slot, count)
set item count in slot
Change the count of items at a specific slot in your inventory. The

count

argument is the new number of items from 1 to 99, or 0 if you want to delete any items currently in the slot. If the slot is empty, this command will fail.
iteminslot
setiteminslot
setitemcountinslot
getinventorysize
inventory (item)
inventory
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
get inventory size
get inventory size
Returns the number of inventory slots.
set inventory size (new size)
set inventory size
Changes the number of inventory slots that are available. Use the constant

inv:max

to restore the maximum value. The number you give will be rounded up to the nearest multiple of 3.
leader
leader
Returns the hero ID number (as given in the Edit Hero Stats menu) of the current caterpillar party leader.
hero X (who)
hero X
Returns the specified hero's X position in tiles. Note that a hero's tile is the tile its top left corner is on.
hero Y (who)
hero Y
Returns the specified hero's Y position in tiles. Note that a hero's tile is the tile its top left corner is on.
NPC X (who)
NPC X
Returns the specified NPC's X position in tiles. Note that an NPC's tile is the tile its top left corner is on.
npcatspot
NPC Y (who)
NPC Y
Returns the specified NPC's Y position in tiles. Note that an NPC's tile is the tile its top left corner is on.
npcatspot
hero direction (who)
hero direction
Returns the specified hero's direction.
hero frame (who)
hero frame
Returns the walking frame (0 or 1) of the specified hero.
get hero speed (who)
get hero speed
Returns the walking speed of the specified hero, in pixels per tick.
setherospeed
NPC direction (who)
NPC direction
Returns the specified NPC's direction.
NPC frame (who)
NPC frame
Returns the walking frame (0 or 1) of the specified NPC.
NPC extra (who, which)
NPC extra
Returns the npc instance-specific extra data field requested in

which

, a number from 0 to 2. You may use the constants

extra 0

,

extra 1

and

extra 2

to refer to them. If you use an NPC ID for

who

, the first instance's data will be used.
setnpcextra
set NPC extra (who, which, value)
set NPC extra
Sets the npc instance-specific extra data field requested in

which

, a number from 0 to 2. You may use the constants

extra 0

,

extra 1

and

extra 2

to refer to them. If you use an NPC ID for

who

, the first instance's data will be used.

Unlike other NPC instance data, the extra data for NPCs on the current map is not saved in save games! However, it is saved in mapstate NPC saves (see savemapstate)

npcextra
room in active party
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
current map
Returns the number of the current map.
map width
map width
Returns the width of the map in tiles.
map height
map height
Returns the height of the map in tiles.
get map tileset
get map tileset
Returns the ID number of the default tileset for the map. loadtileset does not affect the value returned by this function, but changetileset does. Use layertileset instead to find the actual currently in-use tileset(s).
layer tileset (layer)
layer tileset
Returns the ID number of the tileset that a certain tilemap layer is currently using.
changetileset
getmaptileset
days of play
days of play
Returns the number of days that the game has been played
set days of play (days)
set days of play
Sets the number of days that the game has been "played" to

days

, as long as

days

is greater than 0. Useful if there are times that shouldn't count towards the play time, or for penalizing bad players >:)
hours of play
hours of play
Returns the number of hours that the game has been played, 0 to 23
set hours of play (hours)
set hours of play
Sets the number of hours that the game has been "played" to

hours

, as long as

hours

is within the 0-23 range.
minutes of play
minutes of play
Returns the number of minutes that the game has been played, 0 to 59
set minutes of play (min)
set minutes of play
Sets the number of minutes that the game has been "played" to

min

, as long as

min

is within the 0-59 range.
seconds of play
seconds of play
Returns the number of seconds that the game has been played, 0 to 59
set seconds of play (sec)
set seconds of play
Sets the number of seconds that the game has been "played" to

sec

, as long as

sec

is within the 0-59 range.
system year
system year
Returns the current real-world year
system month
system month
Returns the current real-world month, 1 to 12
system day
system day
Returns the current real-world day, 1 to 31
system hour
system hour
Returns the current real-world hour, 0 to 23
system minute
system minute
Returns the current real-world minute, 0 to 59
system second
system second
Returns the current real-world second, 0 to 59
key is pressed (scancode)
key is pressed
Returns true if the keyboard key with the specified scancode is being pressed (either held down or pressed since last tick), or false if it is not. The argument is a scancode, NOT the upkey, downkey, etc used with waitforkey. I have provided an extra include file, SCANCODE.HSI that you can use to define friendly names for all the scancodes. Keyboard scan codes:

- 00
- 01 ESC
- 02 1
- 03 2
- 04 3
- 05 4
- 06 5
- 07 6
- 08 7
- 09 8
- 10 9
- 11 0
- 12 - _
- 13 = +
- 14 BACKSPACE
- 15 TAB
- 16 Q
- 17 W
- 18 E
- 19 R
- 20 T
- 21 Y
- 22 U
- 23 I
- 24 O
- 25 P
- 26 [ {
- 27 ] }
- 28 ENTER
- 29 CTRL
- 30 A
- 31 S
- 32 D
- 33 F
- 34 G
- 35 H
- 36 J
- 37 K
- 38 L
- 39 ; :
- 40 " '
- 41 ` ~
- 42 LEFT SHIFT
- 43 \ |
- 44 Z
- 45 X
- 46 C
- 47 V
- 48 B
- 49 N
- 50 M
- 51 , <
- 52 . >
- 53 / ?
- 54 RIGHT SHIFT
- 55 PRINT SCREEN *
- 56 ALT
- 57 SPACE
- 58 CAPSLOCK
- 59 F1
- 60 F2
- 61 F3
- 62 F4
- 63 F5
- 64 F6
- 65 F7
- 66 F8
- 67 F9
- 68 F10
- 69 NUMLOCK
- 70 SCROLL LOCK
- 71 HOME 7
- 72 UP 8
- 73 PAGEUP 9
- 74 KEYPAD -
- 75 LEFT 4
- 76 KEYPAD 5
- 77 RIGHT 6
- 78 KEYPAD +
- 79 END 1
- 80 DOWN 2
- 81 PAGEDOWN 3
- 82 INSERT 0
- 83 DEL .
- 84
- 85
- 86
- 87 F11
- 88 F12
- 89
- 90
- 91 L WIN LOGO
- 92 R WIN LOGO
- 93 CONTEXT

Joystick scan codes:

- 128 BUTTON 1
- 129 BUTTON 2
- 130-143 BUTTON 3-16
- 144 X LEFT
- 145 X RIGHT
- 146 Y UP
- 147 Y DOWN

You can NOT wait for the player to press a key by continually polling

key is pressed

unless you stick a wait in your do loop. That's because

key is pressed

does not return real time data, but the state of the keyboard at the beginning of the current game tick.
keyval
keyval (scancode)
keyval
Returns a bitmask for the state of the specified key. The argument is a scancode, see keyispressed. The first (least significant) bit is whether the key was depressed at the beginning of the current tick. The second bit is whether the key was pushed down by the player since the start of the previous tick (or when the key starts to repeatedly trigger after being held down for a while). It can therefore return 0, 1, 2 or 3: 0 = not pressed1 = key held down since last tick, but is not a new press2 = the player pressed the key and released it, all in the same tick3 = new keypress (or typematic repeat) Just like keyispressed, this command does not return real time data, but the situation at the beginning of the current game tick.

The joystick scancodes described in keyispressed do not work in this command.

keyispressed
last ascii
last ascii
Returns the ascii code of any currently pressed key. If more than one key corresponding to an ascii character is being pressed, then only one can be returned.
joystick button (button,joystick)
joystick button
Returns true or false depending on whether button #

button

on joystick #

joystick

is pressed.

button

can be from 1-16 (assuming the joystick has that many buttons), and

joystick

can be from 0-7. Most of the time, you will want to use joystick #0, so that is what

joystick

defaults to.
joystick axis (axis,multiplier,joystick)
joystick axis
Returns the position of the joystick along the X or Y axis on joystick #

joystick

.

axis

can be one of the constants xaxis or yaxis.

multiplier

is slightly complicated: The position of the joystick is actually a decimal between -1 and 1. Since plotscripting can't handle decimals, this position must be multiplied and rounded off until it is within plotscripting's capabilities. By default, it is 100 (so it will return -100 - 100).

joystick

can be from 0-7. Most of the time, you will want to use joystick #0, so that is what

joystick

defaults to.
hero pixel X (who)
hero pixel X
Returns the hero's X position on the map in pixels. To find the hero's position in tiles, use the herox function instead.
hero pixel Y (who)
hero pixel Y
Returns the hero's Y position on the map in pixels. To find the hero's position in tiles, use the heroy function instead.
NPC pixel X (who)
NPC pixel X
Returns the NPC's X position on the map in pixels. The argument is an npcreference or an NPC ID number. To find the NPC's position in tiles, use the npcx function instead.
NPC pixel Y (who)
NPC pixel Y
Returns the NPC's Y position on the map in pixels. The argument is an npcreference or an NPC ID number. To find the NPC's position in tiles, use the npcy function instead.
camera pixel X
camera pixel X
Returns the X position of the top left corner of the screen in pixels.
camera pixel Y
camera pixel Y
Returns the Y position of the top left corner of the screen in pixels.
pick hero
pick hero
Pops up a hero-picker box that lets you choose one of the heroes in your active party. The return value is the position in the party of the hero you picked, or -1 if the player cancelled.
rename hero(who)
rename hero
Pops up a name-editing box that allows you to change a hero's name. The argument is the hero's ID number, or name in the format hero:name
rename hero by slot(who)
rename hero by slot
Pops up a name-editing box that allows you to change a hero's name. The argument is the hero's position in the party as returned by findhero
last save slot
last save slot
Returns the last save slot saved to using the save menu, or the save slot the game was loaded from, or false if the game has not been saved yet. Save slots are numbered starting at 1. saveinslot does not change the value returned! If you need it to, you need to track it with a global variable.
saveinslot
savemenu
save slot used (slot)
save slot used
Returns whether a game has been saved in the save slot. Use if you, for example, don't want to overwrite a saved game with saveinslot.
hero levelled (who)
hero levelled
Returns the number of levels the specified hero gained.

who

is the hero's position in the battle party. If you want to use

hero:Name

you should use findhero. This command only applies to the most recent battle or giveexperience, setherolevel or setexperience command that targetted this hero (or the active battle party if the hero is in it) - levels gained from previous battles or commands are forgotten. If the hero lost levels, the result is negative. In other words, this does not return true or false, but can be be used in an if statement like:
give experience (party, 50) if (herolevelled (find hero (hero: Bob))) then ( $31="Bob gained " append number(31, hero levelled (find hero (hero: Bob))) $31+" level(s)!" show textbox (233) # ${S31} :show string 31 )
total experience (who)
total experience
Returns a hero's total experience. The argument is the position of the hero you want to check in your party as as returned by findhero.
setexperience
experience to next level (who)
experience to next level
Returns experience required by a hero to reach the next level. The argument is the position of the hero you want to check in your party as as returned by findhero.
experience to level (level)
experience to level
Returns the total experience required to reach a specified level from level 0.
set timer (id, count, speed, trigger, string, flags)
set timer
Changes the settings for a given timer, and starts it.

id

is the number of a timer -- by default, there are 16 timers, numbered 0 to 15, but you can change the number of available timers with allocatetimers. All other parameters are optional, or you can pass timer:default as any of them. This will leave the parameter unchanged (from the last time you set it or from the default initial value), it will NOT cause that timer setting to be reset to the default initial value.

Count

is the length of the timer. While it's running, the count will go down by one every

speed

game ticks (frames). I.e., if you set speed to 18, it will count down once every 18 ticks, close to one second. Use a speed of 1 to count down in ticks. Changing the timer's

count

(as opposed to passing

timer:default

as the second argument) will cause the timer to restart from the new value.

trigger

is what happens when the timer runs out. You can use the constant timer:gameover to indicate that the game should end, or specify a plotscript (in the form "@my script") to have that run. A plotscript will get passed the id of the timer that triggered it as its first argument, if it has one. If the timer runs out during a battle then the effect happens after the battle ends. You can bind a timer to a string using the

string

parameter to create a countdown that shows up on screen. Pass it the id of a string, and that string will be updated every time the timer counts down. You are responsible for displaying and positioning the string. A timer also has a few other options in the form of

flags

. You can pass any combination of these flags (by oring or adding them together):

- timerflag:battle
  to have it count down during battles (not including menus which pause the battle)
- timerflag:menu
  to have it count down even while the player is in a menu which pauses the game (e.g. the status menu), the in-battle pause button doesn't count
- timerflag:critical
  to have the timer end a battle or exit a menu if it runs out during it

Timers start counting down not from the current game 'tick', but from next one. So if you want to trigger something next tick (eg. run a script every frame) you need to pass

count

as 0 and

speed

as 1. A timer count set to 1 would counter-intuitively trigger in 2 ticks time.

Timer settings are not saved in game saves.

stoptimer
readtimer
systemsecond
secondsofplay
milliseconds
runscriptbyid
#this starts a 300 second (5 minute) timer that counts down once every 18 ticks (a second). If #it runs out during battle, the battle won't end but a game-over will happen afterwards. set timer (0, 300, 18, timer: game over, 0, timerflag: battle)
stop timer (id)
stop timer
Stops a timer by setting its speed to 0. All of its other settings remain the same.
settimer
allocate timers (number)
allocate timers
Changes the number of available timers. The range of valid timer IDs becomes 0 to

number

-1. You can reduce the number of timers down to zero, and increase it up to 100000 (not recommended, each timer must be processed continuously). All existing timers that are not removed continue to run. The default number of timers is 16.
read timer (id)
read timer
Returns the count of a given timer.
settimer

# Enemy and Formation Functions

get enemy stat(enemy, stat)
get enemy stat
Returns the selected stat from the selected enemy. The first argument is the number of the enemy whose stats you want to check. The second argument is the name of the stat that you want to check. The names of the stats are also defined in your HSI file in the form stat:name.
setenemystat
getherostat
setherostat
set enemy stat(enemy, stat, value)
set enemy stat
Sets the selected stat of the selected enemy to the value you supply. The first argument is the number of the enemy whose stats you want to set. The second argument is the name of the stat that you want to set. The names of the stats are also defined in your HSI file in the form stat:name. The third is the new value of the stat.

Enemy stat changes are temporary. They are not saved in the game save.

getenemystat
getherostat
setherostat
get enemy name (enemyid, stringid)
get enemy name
Lets you use the enemy name in a string. The first argument is the number of the enemy you want to get the name from, second argument is the number of the string that you want to store the name of the enemy.
setenemyname
set enemy name (enemyid, stringid)
set enemy name
Lets you set the enemy name from a string, the string length cannot be more then 16 characters, if it is more then 16 the name will be truncated. The first argument is the number of the enemy's name you want to change, second argument is the number of the string that you supply the name of the enemy from.

Enemy name changes are temporary. They are not saved in the game save.

getenemyname
get enemy appearance (enemyid, appearance)
get enemy appearance
Returns data on the appearance of a enemy. Enemyid is the enemy number that you want to return the appearance of, appearance is either picture, palette, or size. You can use the following constants for appearance:

- enemy:picture
- enemy:palette
- enemy:picturesize

You can compare the values returned from enemy:picturesize with the constants enemysize:small, enemysize:medium and enemysize:large
setenemyappearance
set enemy appearance (enemyid, appearance,value)
set enemy appearance
Lets you change an enemy's appearance. Enemyid is the number of the enemy's appearance that you want to change, appearance is one of the constants given in getenemyappearance. Value can is the new number that you want to assign, constants enemysize:small, enemysize:medium, or enemysize:large when changing picture size, or palette number when changing palette.

Enemy appearance changes are temporary. They are not saved in the save game.

getenemyappearance
read enemy data (enemyid, data)
read enemy data
Returns the enemy's reward values. Enemyid is the number of enemy, data is a predefined constant defining the data you want returned. Use the following constants:

- enemy:gold
- enemy:experience
- enemy:item
- enemy:itempercent
- enemy:rareitem
- enemy:rareitempercent
- stealability
- stealableitem
- stealableitemchance
- stealablerareitem
- stealablerareitemchance

writeenemydata
write enemy data (enemyid, data, value)
write enemy data
Lets you set items of an enemy's data. Enemyid is the number of enemy, data is a predefined constant for the data you want to change. Value is the new value given to that setting. Use the same constants as are given at readenemydata.

Enemy data changes are temporary. They are not saved in saved games.

readenemydata
add enemy to formation (formation, enemy id, x, y, slot)
add enemy to formation
Adds an enemy with given

enemy id

(use the constants of the form

enemy:name

in your exported .hsi file) to the specified

formation

.

x

(up to 230) and

y

(up to 199) give the position of the center of the bottom edge of the enemy - approximately where it appears to stand.

slot

(0 to 7) is an optional argument, if given then the enemy is created in the suggested slot if empty. Otherwise it's put in the first empty slot. The actual slot number used is returned, or -1 if the enemy couldn't be added.

Changes to enemy formations are temporary: they are not saved in save files.

deleteenemyfromformation
delete enemy from formation (formation, slot)
delete enemy from formation
Deletes an enemy in the given

slot

(as returned by findenemyinformation for example) in the

formation

.

Changes to enemy formations are temporary: they are not saved in save files.

addenemytoformation
find enemy in formation (formation, enemy id, copy number)
find enemy in formation
Searchs for an enemy in a formation, returning the slot number, or -1 if not found.

copy number

is optional, use 0 or greater specify which enemy to return if there is more than one, or the constant getcount. The first (searching the slots sequentially) enemy copy is number 0. The number of specified enemies in the formation is returned if the constant get count is used.

enemy id

can be either an enemy id, or the constant

any enemy

, which searches for any enemy (the first enemy in the formation by default), or the total number of enemies with getcount.
plotscript, look at formation, formation, begin # In this example, we'll pick a random enemy from a formation, and check if there are any plips. # You'll need an enemy named plip to try this out, or change the "enemy:plip" constant below to something else variable (number of enemies, random enemy slot)

# The total number of enemies number of enemies := find enemy in formation (formation, any enemy, get count) # Pick an enemy at random random enemy slot := find enemy in formation (formation, any enemy, random(0, number of enemies -- 1))

$30 = "There is a " # Here we append the enemy's name to string 30 get enemy name (formation slot enemy (formation, random enemy slot), 30) $30 + " in this formation" show string (30)

# Let's check whether there is at least one plip in this formation variable (number, plip slot) number := find enemy in formation (formation, enemy:plip, get count) if (number >> 0) then ( # We'll put a string onscreen where the plip appears in battle $31 = "Plip!" plip slot := find enemy in formation (formation, enemy:plip) center string at (31, formation slot x (formation, plip slot), formation slot y (formation, plip slot) -- 20) ) end
deleteenemyfromformation
formationslotenemy
formationslotx
formationsloty
formation slot enemy (formation, slot)
formation slot enemy
Returns the ID number of the enemy in the specified formation slot (0 to 7), or -1 if the slot is empty.
findenemyinformation
formation slot x (formation, slot)
formation slot x
Returns the x position of the center of the enemy in the specified formation slot (0 to 7). An enemies position is the center of the bottom edge of the enemy - approximately where it appears to stand.
findenemyinformation
formation slot y (formation, slot)
formation slot y
Returns the y position of the bottom edge of the enemy sprite in the specified formation slot (0 to 7). An enemies position is the center of the bottom edge of the enemy - approximately where it appears to stand.
findenemyinformation
set formation background (formation, background, animation frames, animation ticks)
set formation background
Sets the background and the background animation for a

formation

. The animation arguments do not need to be given, producing a static background.

animation frames

, optional, is the number of frames (1 to 50) to use for the background animation. 1 is non-animating.

animation ticks

, also optional, is the number of ticks to display each backdrop for. The engine normally (but not reliably) runs at 18 ticks per second.

Changes to enemy formations are temporary: they are not saved in save files.

getformationbackground
get formation background (formation, background)
get formation background
Gets the background used by a

formation

. If the backdrop is animated, this returns the ID of the first backdrop (the one set in Custom).
setformationbackground
set formation song (formation, song)
set formation song
Changes an enemy formation to use

song

as its music. Use the constants of the form

song:songname

from your exported .hsi file, or the special constants song:silence or song:sameasmap

Changes to enemy formations are temporary: they are not saved in save files.

getformationsong
get formation song (formation)
get formation song
Returns the song associated with

formation

. Compare the result with the constants of the form

song:songname

from your exported .hsi file, or the special constants song:silence or song:sameasmap.
setformationsong
last formation
last formation
Returns the last formation fought. If the player hasn't fought any formations yet (since starting or loading the game), it returns -1.
random formation (formation set)
random formation
Picks a formation randomly from the given

formation set

(1 to 255).
formationprobability
formation set frequency (formation set)
formation set frequency
Returns the formation frequency (from 0 to 99) of a

formation set

(1 to 255). Note that the frequency is not actually a probability (as a percentage) of a battle occuring each step, but is roughly the number of battles per 80 steps, spaced semi-randomly.
randomformation
formation probability (formation set, formation)
formation probability
Returns the probability of a particular

formation

in a

formation set

being fought, as a percentage from 0 to 100. This does take the number of times the formation appears in the formation set into account.
randomformation
random

# Tweaking Maps

read map block (x,y,layer)
read map block
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. The optional layer can be 0, 1, or 2. The bottom layer will be read by default.
currentdisplaytile
write map block (x,y,value,layer)
write map block
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. The optional layer argument can be 0, 1, or 2. The bottom layer will be written to by default
read pass block (x,y)
read pass block
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 = northwall bit 2 = eastwall bit 4 = southwall bit 8 = westwall bit 16 = vehiclea bit 32 = vehicleb bit 64 = harmtile bit 128 = overheadtile To check the value of a specific bit, use the and operator. For example:
variable (pass) 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)
write pass block
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 = northwall bit 2 = eastwall bit 4 = southwall bit 8 = westwall bit 16 = vehiclea bit 32 = vehicleb bit 64 = harmtile bit 128 = overheadtile You can add the constants together. For example:
variable (pass) pass := northwall+southwall+eastwall+westwall write pass block(15,3,pass) # this makes the fifteenth tile in the third column # impassable on all directions
load tileset (tileset, layer)
load tileset
Temporarily loads a different default or layer tileset for the currently displaying map.Use

load tileset

(with no arguments) to restore the old tilesets after using load tileset (this has no effect after changetileset).Use

load tileset (tileset)

to load a new default tileset.

tileset

is the ID number of the tileset to load. This affects tilesets for all layers that are set to 'Tileset: default'. This effectively changes the map's tileset if you haven't done anything fancy with layer tilesets.Use

load tileset (tileset, layer)

to load in a new a tileset for a single layer.

layer

is the layer number (0-2) to target.

This command has a temporary effect: even if the map state is saved, the new tilesets will not persist if you leave the map and come back. changetileset is a more powerful command for this.

getmaptileset
layertileset
change tileset (tileset, layer)
change tileset
An alternative to loadtileset: Changes and loads in the default or a map layer tileset for the current map. Unlike load tileset, this command's effects last to the next time you come back to this map if you save the map state (in General Map Settings, or mapstate:mapsettings with savemapstate). To undo the effects, you'll need to use resetmapstate.

tileset

is the ID number of the tileset to load. You can use the constant

tileset:default

to set a layer to use the default tileset.

layer

is the layer number (0-2) to change, or the constant

tileset:default

which changes the default tileset. It defaults to

tileset:default

if omitted.

change tileset

with no arguments restores the set tilesets after using load tileset.
getmaptileset
layertileset
current display tile (tile number, layer)
current display tile
Returns the tile number from the tileset, in the range 0-159, that a given tile (read with readmapblock, which returns a value greater than 159 for animated tiles) is currently displayed as, taking the tile animation patterns into account. Because different layers can have different tilesets, you might need to specify the layer the tile is from; otherwise layer 0 is assumed.
animation start tile (tile number, layer)
animation start tile
Returns the tile number on the tileset (in the range 0-159) that this tile is displayed as at the start of its animation pattern (offset 0) if it is animated, else just returns the tile number. The

tile number

argument is typically returned from readmapblock. In effect, the result is what the tile number would be if you had not set the tile as animated in the tilemap editor. Because different layers can have different tilesets, you might need to specify the layer the tile is from; otherwise layer 0 is assumed.
currentdisplaytile

# Working with Tags

set tag (tag,value)
set tag
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)
check 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

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.You should normally set variables by writing

variable := value

but for backwards compatability, you can also use the old form

set variable(variable, value)

increment (variable,amount)
increment
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.You can also increment variables by writing variable += amount
decrement (variable,amount)
decrement
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.You can also decrement variables by writing variable -= amount

# 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
add
Adds two values together and returns the result. This can also be written as add(number,number)
number -- number
subtract
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 subtract(number,number)
number * number
multiply
Multiplies two values together and returns the result. This can also be written as multiply(number,number)
number / number
divide
Divides the second number into the first number and returns the result. The result is rounded down to an integer. This can also be written as divide(number,number)
number,mod,number
mod
Divides the second number into the first number and returns the remainder. This can also be written as modulus(number,number)
number ^ power
^
Raises a number to a power and returns the result. (If the result is too large and overflows no error occurs: the value is simply wrapped around a 32 bit signed integer.) This can also be written as exponent(number,power)
abs (number)
abs
Returns the absolute value of a value. That is, negative values are made positive and others are unchanged: abs(-14) is 14, and abs(14) is 14.
sign (number)
sign
Returns -1 if

number

is negative, 0 if it is 0, and 1 if

number

is positive.
sqrt (number)
sqrt
Returns the squareroot of a number, rounded to the nearest integer.
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 equal(number,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 not equal(number,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 less than(number,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 greater than(number,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 less than or equal to(number,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 greater than or equal to(number,number)
value,and,value
and
Returns the bitwise AND of both values. In other words, for each bit in each value, they are compared to see if they are both "1". If they are, the result bit is set to 1. Otherwise, it's set to 0.
logicaland
value,or,value
or
Returns the bitwise OR of both values. In other words, for each bit in each value, they are compared to see if either bit is "1". If one is, the result bit is set to 1. Otherwise, it's set to 0.
logicalor
value,xor,value
xor
Returns the bitwise AND of both values. In other words, for each bit in each value, they are compared to see if either (but not both!) bit is "1". If ONE is, the result bit is set to 1. Otherwise, it's set to 0.
logicalxor
value && value
&&
Returns true if both of the values are true (non-zero). If either of them is false, and returns false. This command uses shortcut evaluation: if the first argument is false, the second argument is never evaluated.
value || 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. This command uses shortcut evaluation: if the first argument is true, the second argument is never evaluated.
value ^^ 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, ^^ returns false.
not (value)
not
Returns the logical complement/negation of a value. That is, it returns true (1) if the value is false (0), or false (0) if the value is true (non-zero).

# Flow Control

begin,other commands,end
begin
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)) then (show text box (5),wait for text box)
if (check tag(2)) then begin show text box (5) wait for text box end
begin
end
if(condition) then(commands) else(commands)
if
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 equal or notequal, or it is a checktag 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
if
then
if
else
while(condition) do(commands)
while
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 equal or notequal, or it is a check tag command.
do
do
while
for
for(counter,start,finish,step) do(commands)
for
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
return(value)
return
Sets the value to be returned by the script. This is only useful when the script has been called as a function from another script. It is irrelevant to scripts called directly from your RPG, for example, text box scripts or menu scripts. This command only matters when you are calling one script from another script. This command does NOT cause the script to terminate, it just sets the return value. If you never use the

return

command, the script will return a zero. If return is used more than once in the same script, only the last one executed matters. script, key wait, ticks, begin # Returns true if the wait was cancelled by a keypress. # or false (0) if the wait finished uninterrupted. variable(i) for(i, 1, ticks) do, begin wait(1) if(key is pressed(key:ENTER)) then(return(true)) if(key is pressed(key:SPACE)) then(return(true)) if(key is pressed(key:CTRL)) then(return(true)) if(key is pressed(key:ALT)) then(return(true)) if(key is pressed(key:ESC)) then(return(true)) if(key is pressed(joy:button 1)) then(return(true)) if(key is pressed(joy:button 2)) then(return(true)) end end plotscript, usage example, begin show text box(5) # let all volunteers take one step forward! if(key wait(40)) then( walk hero(me, north, 1) wait for hero(me) show text box(6) # You there! I saw you move! You volunteer! )else( show text box(7) # a bunch of lily livered cowards, eh? ) end
exitreturning
exit returning(value)
exit returning
ubersetzung
Sets the value to be returned by the script, and exits the script. This is only useful when the script has been called as a function from another script. script, key wait, ticks, begin # Returns true if the wait was cancelled by a keypress. variable(i) for(i, 1, ticks) do, begin wait(1) if(key is pressed(key:ENTER)) then(exit returning(true)) if(key is pressed(key:SPACE)) then(exit returning(true)) if(key is pressed(key:CTRL)) then(exit returning(true)) if(key is pressed(key:ALT)) then(exit returning(true)) if(key is pressed(key:ESC)) then(exit returning(true)) if(key is pressed(joy:button 1)) then(exit returning(true)) if(key is pressed(joy:button 2)) then(exit returning(true)) end exit returning(false) end plotscript, usage example, begin show text box(5) # let all volunteers take one step forward! if(key wait(40)) then( walk hero(me, north, 1) wait for hero(me) show text box(6) # You there! I saw you move! You volunteer! )else( show text box(7) # a bunch of lily livered cowards, eh? ) end The

exit returning

command works exactly the same as the return command followed immediately by exit script. Whether you decide to use return or

exit returning

to set your script's return value is often just a matter of style and taste.
return
exitscript
exit script
exit script
ubersetzung
Causes the script to end immediately
exitreturning
break
break
ubersetzung
breaks out of a for or while command and continue the script after the end of the do block.
continue
continue
ubersetzung
When used inside the do block of a for or while command, continue skips the rest of the do block and continues on to the next loop. When used inside a switch statement, continue flows on to the next case block
switch(expression)
switch
ubersetzung
select between a number of case statements based on the value of an expression. switch(v) do( case(0) do( do foo ) case(1) do( do bar ) case(2) do( do baz ) case(3) do( do something else ) case(10) do( do yet another thing ) ) The select command is an alternative to a big block of nested if/then/else commands that all check the same value. Switch can be easier to read than a lot of if's. The example below shows how the same switch stattement would be written with if/then/else if(v == 0) then( do foo )else( if(v == 1) then( do bar )else( if(v == 2) then( do baz )else( if(v == 3) then( do something else )else( if(v == 10) then( do yet another thing ) ) ) ) ) Besides readability, there is one other important difference between these two examples. The switch command only checks the value of v once. the if/the/else method checks v repeatedly, so it could be slower, and could be suceptible to errors if you accidentally change the value of v somewhere in the middle.
case
case(value)
case
ubersetzung
The case command is used to enclose a block of commands for one possible result of a switch command. See switch for more details.

# Advanced Commands

set hero picture (who,picture,type)
set hero picture
Permanently changes a hero's picture. The first argument is the hero's position in the party. (Use findhero if you want refer to the hero by name.) The second argument is the index number of the picture to use, and the last argument is a constant insidebattle or outsidebattle, which determines if you are changing the hero's battle picture or their walkabout picture. If the last argument is left out, outsidebattle is assumed.
resetheropicture
set hero palette (who,palette,type)
set hero palette
Permanently changes a hero's 16-color palette. The first argument is the hero's position in the party. (Use findhero if you want refer to the hero by name.) The second argument is the index number of the 16-color palette to use, and the last argument is a constant insidebattle or outsidebattle, which determines if you are changing the hero's battle palette or their walkabout palette. If the last argument is left out, outsidebattle is assumed.
resetheropalette
get hero picture (who,type)
get hero picture
A function that returns the index number of a hero's picture. The first argument is the hero's position in the party as returned by findhero. The second argument is a constant insidebattle or outsidebattle, which determines if you are checking the hero's battle picture or their walkabout picture. If the second argument is left out, outsidebattle is assumed.
get hero palette (who,type)
get hero palette
A function that returns the index number of a hero's 16-color palette. The first argument is the hero's position in the party as returned by findhero. The second argument is a constant insidebattle or outsidebattle, which determines if you are checking the hero's battle palette or their walkabout palette. If the second argument is left out, outsidebattle is assumed.
reset hero picture (who,type)
reset hero picture
Resets a hero's picture that was previously changed with setheropicture back to the default picture. The first argument is the hero's position in the party. (use findhero if you want refer to the hero by name). The second argument is a constant insidebattle or outsidebattle, which determines if you are changing the hero's battle picture or their walkabout picture. If the last argument is left out, outsidebattle is assumed.
setheropicture
reset hero palette (who,type)
reset hero palette
Resets a hero's palette that was previously changed with setheropalette back to the default palette. The first argument is the hero's position in the party. (Use findhero if you want refer to the hero by name.) The second argument is a constant insidebattle or outsidebattle, which determines if you are changing the hero's battle palette or their walkabout palette. If the last argument is left out, outsidebattle is assumed.
setheropicture
alter NPC (who,NPCstat,value)
alter NPC
Changes the stats of an NPC type. Constants for this command have been included in PLOTSCR.HSD. Alter NPC can be used for many purposes.

- Alter NPC (who,NPCstat:picture,picture number)
- Alter NPC (who,NPCstat:palette,palette number)
- Alter NPC (who,NPCstat:move type,move type code)Available move types
  - NPCmovetype:standstill
  - NPCmovetype:wander
  - NPCmovetype:pace
  - NPCmovetype:rightturns
  - NPCmovetype:leftturns
  - NPCmovetype:randomturns
  - NPCmovetype:chaseyou
  - NPCmovetype:avoidyou
  - NPCmovetype:walkinplace
- Alter NPC (who,NPCstat:move speed,speed)
- Alter NPC (who,NPCstat:display text,text box number)
- Alter NPC (who,NPCstat:when activated,when activated code)Available when activated codes
  - NPCwhenactivated:changedirection
  - NPCwhenactivated:faceplayer
  - NPCwhenactivated:donotfaceplayer
- Alter NPC (who,NPCstat:give item,item number + 1) ... Note that the item number is offset + 1. A zero means no item.
- Alter NPC (who,NPCstat:pushability,pushability code)Available pushability codes
  - NPCpush:off
  - NPCpush:full
  - NPCpush:horizontal
  - NPCpush:vertical
  - NPCpush:uponly
  - NPCpush:rightonly
  - NPCpush:downonly
  - NPCpush:leftonly
- Alter NPC (who,NPCstat:activation,activation code)Available activation codes
  - NPCactivation:use
  - NPCactivation:touch
  - NPCactivation:stepon
- Alter NPC (who,NPCstat:script,script ID)
- Alter NPC (who,NPCstat:script argument,number)
- Alter NPC (who,NPCstat:vehicle,vehicle ID+1)

Normally you would only give an NPC ID number to alter NPC, but if you want to use an npcreference it will still work. Just remember that alter NPC changes every copy of the NPC on the map, not just the specific one you referenced.A good way to make use of Alter NPC is to wrap it in your own script. For example: # Example AlterNPC wrapper for changing NPC appearance plotscript,change NPC,who=0,picture=0,palette=0,begin Alter NPC(who,NPCstat:picture,picture) Alter NPC(who,NPCstat:palette,palette) end

If you want to change an NPC's palette back to the default, you can use

Alter NPC(who, NPCstat:palette, -1)

setnpcusable
setnpcmoves
setnpcignoreswalls
setnpcobstructs
read NPC (who,NPCstat)
read NPC
Returns data such as picture, palette, walking speed, text box, etc. for an NPC. Use the same constants as alternpc.

If you use this command to read the give item number, the result is offset + 1. A zero means no item.

alternpc
set NPC ignores walls (who, value)
set NPC ignores walls
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), set whether that NPC can walk through walls.

value

should be true or false.
getnpcignoreswalls
get NPC ignores walls (who)
get NPC ignores walls
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), returns whether that NPC can walk through walls.
setnpcignoreswalls
set NPC moves (who, value)
set NPC moves
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), set whether that NPC moves according to its move-type, or whether it stands still.

value

should be true or false.
getnpcmoves
suspendnpcs
alternpc
get NPC moves (who)
get NPC moves
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), returns true or false indicating whether that NPC moves according to its move-type, or whether it is suspended. This is always true, even for "Stand Still" NPCs unless setnpcmoves has been used.
setnpcmoves
readnpc
set NPC obstructs (who, value)
set NPC obstructs
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), set whether the NPC should be an obstruction to heroes and other NPCS. If set to false, the NPC can move through heroes and other NPCs and vice-versa. Heroes can always pass through Step-on NPCs.

value

should be true or false.
getnpcobstructs
suspendobstruction
get NPC obstructs (who)
get NPC obstructs
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), returns false if that NPC's obstruction has been suspended with setnpcobstructs (and is always true otherwise).
setnpcobstructs
set NPC usable (who, value)
set NPC usable
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), set whether the NPC can be activated by the player as normal (as defined in the NPC ID data). usenpc will still work on the NPC.

value

should be true or false.
getnpcusable
alternpc
get NPC usable (who)
get NPC usable
Given an NPC reference or NPC ID (in which case the first NPC with that ID is used), returns false if normal activation of that NPC has been suspended with setnpcusable. This is always true otherwise, even for NPC types which are not activateable.
setnpcusable
set death script (id)
set death script
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.
get death script
get death script
Returns the ID number of script that is run when you die in battle.
set load script (id)
set load script
Changes the script that is run when you load a saved game. The argument is the script's ID number, NOT the script's name. Calling set load script with no argument disables the load script.
get load script
get load script
Returns the ID number of script that is run when you load a saved game.
set on keypress script (id)
set on keypress script
Changes the script that is run when you press a key. The argument is the script's name preceded by an @ sign. You can also use the ID number for old-style scripts. Calling set on keypress script with no argument disables the keypress script. The effect goes away if you change maps or fight a battle.
set on keypress script(@keyhandlerscript)
get on keypress script
get on keypress script
Returns the ID number of script that is run when you press a key.
set each step script (id)
set each step script
Changes the script that is run when you take a step. The argument is the script's ID number, NOT the script's name. Calling set each step script with no argument disables the each step script. The effect goes away if you change maps or fight a battle.
get each step script
get each step script
Returns the ID number of script that is run when you take a step.
set instead of battle script (id)
set instead of battle script
Changes the script that is run instead of a battle when one is triggered. The argument is the script's ID number, NOT the script's name. Calling set instead of battle script with no argument disables the instead of battle script. The effect goes away if you change maps or fight a battle.
get instead of battle script
get instead of battle script
Returns the ID number of script that is run instead of battles.
set harm tile damage (amount)
set harm tile damage
Sets the amount of damage taken when you step on a harm tile. The effect goes away if you change maps or fight a battle.
set harm tile flash (color)
set harm tile flash
Sets the color (from the master palette) which the screen flashs when you step on a harm tile. Call with no argument to disable the flash. The effect goes away if you change maps or fight a battle.
set foot offset (offset)
set foot offset
Sets the foot offset in pixels, the vertical displacement of npc and hero sprites from the base of the tiles on which they stand. The effect goes away if you change maps or fight a battle.
get foot offset
get foot offset
Returns the map's foot offset.
draw NPCs above heroes (setting)
draw NPCs above heroes
Sets whether NPCs are drawn above heroes or the default of beneath. The effect goes away if you change maps or fight a battle.
set map edge mode (mode, default tile)
set map edge mode
Sets the behaviour at the edge of the map. Use the constants crop, wrap and defaulttile. When the behaviour is default tile, you should give a second argument specifying which tile should be displayed off the boundaries of the map, otherwise ignore the second argument. The effect goes away if you change maps or fight a battle.
get map edge mode
get map edge mode
Returns the map's edge mode. Use the constants crop, wrap and defaulttile to compare with the value returned.
find hero (who)
find hero
Searches through your (battle) 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. The position in the party is needed by most commands operating on heroes. You can use the names defined in your HSI file in the format hero:name for the ID number of the hero (as it has in the Edit Hero Stats menu). 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, and 4 or higher if the hero is in the reserve. Note that position in the battle party is not the same as position in the caterpillar: the leader is not necessarily hero 0. The opposite to find hero is herobyslot.
rankincaterpillar
hero by slot (where)
hero by slot
This command is the reverse of findhero. Given a position in your party, it will tell you which hero is in that slot, or -1 if no hero is in that slot. The number returned can be compared with the names defined in your HSI file in the format hero:name.
rank in caterpillar (who)
rank in caterpillar
Searches through your active party to see if the specified hero is there, and returns the position int the walkabout caterpillar 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. This is particularaly useful if you need to use a command like walk hero but you are not sure which position the hero is in.
findhero
hero by rank (where)
hero by rank
This command is the reverse of rankincaterpillar. Given a position in your walkabout party, it will tell you which hero is in that position, or -1 if no hero is in that position. The number returned can be compared with the names defined in your HSI file in the format hero:name.
get hero stat (who,stat,type)
get hero stat
A function that returns one of a hero's stats. The first argument is the position of the hero you want to check in your party as as returned by findhero. 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 currentstat or maximumstat. If you leave the last argument blank, currentstat will be assumed.
setherostat
setenemystat
getenemystat
set hero stat (who,stat,value,type)
set hero stat
A command that changes one of a hero's stats. The first argument is the position of the hero you want to change in your party as returned by find hero. 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 currentstat or maximumstat. If you leave the last argument blank, currentstat will be assumed.
getherostat
setenemystat
getenemystat
set capped hero stat (who,stat,value,type)
set capped hero stat
A command that changes one of a hero's stats. The first argument is the position of the hero you want to change in your party as returned by find hero. 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 currentstat or maximumstat. If you leave the last argument blank, currentstat will be assumed. Unlike setherostat, this command is not allowed to exceed the stat caps.
setherostat
getherostatcap
get hero stat cap (stat)
get hero stat cap
A function that returns the maximum allowed value for a hero stat. The argument is the stat you want to check, either as a number or using the stat:name constants defined in your HSI file. If the return value is 0 or false there is no stat cap for that stat.
setcappedherostat
get hero level (who)
get hero level
A function that returns a hero's current level. The argument is the position of the hero you want to check in your party as as returned by findhero. The return value with be your current level, from 0 to 99
setherolevel
totalexperience
set hero level (who, level, forgetspells)
set hero level
A command that sets a hero's current level. The first argument is the position of the hero you want to change in your party as as returned by findhero. You can specify any hero in the active or reserve party and any (non-negative) level. Unlike old workarounds, this command teachs the hero any spells they would have learnt by that level and correctly sets the experience to next levelup (experience gained to the current next level is lost). You can also decrease the hero's level, which will cause spells to be forgotten, unless the optional 3rd argument (defaulting to true) is set as false.
getherolevel
herolevelled
spellslearnt
setexperience
set experience (who, experience, allowforget)
set experience
Sets a hero's total experience and updates their experience level, stats and spell list. The argument is the position of the hero you want to check in your party as as returned by findhero. To decrease a hero's level without forgetting spells which are learnt at a certain experience level, pass false as the optional third argument.
setherolevel
totalexperience
herolevelled
spellslearnt
get level MP (who, mp level slot)
get level MP
Returns a hero's level MP (FF1-style MP). The argument

who

is the hero's position in the party, as returned by findhero. The argument

mp level slot

is a number from 0 to 7 that represents a row of spells in the hero's spell list.
set level MP (who, mp level slot, new value)
get level MP
Changes a hero's level MP (FF1-style MP). The argument

who

is the hero's position in the party, as returned by findhero. The argument

mp level slot

is a number from 0 to 7 that represents a row of spells in the hero's spell list. The argument

new value

is the new number of level MP points. Each point represents one spell from that row.
read global (id)
read global
A function that returns the value of a global variable using its ID number instead of its name. Why would you want to do a silly thing like that? Because it allows you to simulate simple fake arrays, in the old C-pointer style.
writeglobal
write global (id,value)
write global
A function that writes a value into a global variable using its ID number instead of its name. Why would you want to do a silly thing like that? Because it allows you to simulate simple fake arrays, in the old C-pointer style
readglobal
set battle wait mode (state)
set battle wait mode
Set whether or not battles pause on spell and item menus. If the argument is off then enemies continue to attack while menus are up, if the argument is on then enemies wait while menus are up.
set caterpillar mode (state)
set caterpillar mode
Sets whether or not to display the whole party in "caterpillar" style. If the argument is off then only the leader will be displayed. If the argument is on then the whole party will be displayed. (do not confuse this with the suspendcaterpillar and resumecaterpillar commands, which only apply when caterpillar mode is ON)
set no HP level up restore (state)
set no HP level up restore
Sets whether or not a hero regains full HP after a levelup. If the argument is off then HP is restored on a levelup. If the argument is on then the hero's HP is not restored on a levelup.
set no MP level up restore (state)
set no MP level up restore
Sets whether or not a hero regains full MP after a levelup. If the argument is off then MP is restored on a levelup. If the argument is on then the hero's MP is not restored on a levelup.
set inn no revive mode (state)
set inn no revive mode
Sets whether or not inns restore dead heroes to life. If the argument is off then dead heroes are restored by inns. If the argument is on then dead heroes remain dead in inns.
set full hero swap mode (state)
set full hero swap mode
Sets whether or not you can swap heroes in and out of your active party from the menu. If the argument is off then the "Order" menu will be available. If the argument is on then the "Team" menu will be available.
hide battle ready meter (state)
hide battle ready meter
Sets whether or not the ready meter appears in battle. If the argument is off then the ready meter appears. If the argument is on then the ready meter will be hidden.
hide battle health meter (state)
hide battle health meter
Sets whether or not the health meter appears in battle. If the argument is off then the health meter appears. If the argument is on then the health meter will be hidden.
set debug keys disable (state)
set debug keys disable
Sets whether or not the debugging keys are allowed. If the argument is off then debugging keys are allowed. If the argument is on then debugging keys are disabled.
set dead heroes gain experience (state)
set dead heroes gain experience
Sets whether or not dead heroes gain experience from battles. If the argument is off then only living heroes gain experience. If the argument is on then dead heroes get it too.
allow minimap (setting)
allow minimap
Sets whether the Map option appears in the menu. Give no argument or true to enable, or false to disable. The effect goes away if you change maps or fight a battle.
showminimap
allow save anywhere (setting)
allow save anywhere
Sets whether the Save option appears in the menu. Give no argument or true to enable, or false to disable. The effect goes away if you change maps or fight a battle.
savemenu
autosave
autosave
Transparently saves the game to the last save slot saved to in the save menu, or if the game has not been saved yet, calls savemenu. Returns the number of the last save slot, or if the user cancelled the save menu, returns false.
lastsaveslot
save in slot (slot)
save in slot
Saves in the specified save slot (1 to 32, where only 1 to 4 are visible on the save and load menus). If a saved game already exists in the slot, it will be overwritten. If you want to make sure that no save game will be overwritten, use saveslotused. To display the save game menu instead, use savemenu.
load from slot (slot)
load from slot
Loads a saved game from a save slot (where

slot

is a slot number from 1 to 32, slots 5-32 are hidden) as if it had been loaded from the load game menu. This command will end the current game if it successfully loads. If the load fails because the slot has never been saved in, the script will continue.
delete save (slot)
delete save
Deletes a saved game in the specified save slot (1 to 32, only 1 to 4 appear on the builtin menus). The save will no longer be visible on the load game menu or loadable with loadfromslot. However, importglobals can still be used to read globals out of the slot.
saveinslot
import globals (slot, first, last)
import globals
and

import globals (slot, id)

Loads a range of globals from a saved game, overwriting the current globals in that range.

slot

is the save slot number, from 1 to 32. Note that only slots 1-4 appear on the save/load menus.

first

and

last

are the id numbers of the globals at the beginning and end of the range. If you leave out both of

first

and

last

all global variables will be imported. To read a single global from a save slot without modifying any of your globals, use the form 'var := import globals (slot, id)'This is NOT the same thing as 'import globals (slot, id, id)', which does modify the global variable.import globals and exportglobals can be used to save and retrieve info about a saved game without loading it, and also to store variables that any game the player starts can use, like in the following example:
global variable (100, game completed) global variable (101, hours to complete) global variable (102, minutes to complete)

plotscript, game finished, begin game complete := true hours to complete := hours of play minutes to complete := minutes of play export globals (5, 100, 102) #special slot that the player can not load, which we can use for anything end

plotscript, check game finished, begin import globals (5, 100, 102) #copy saved values into globals 100, 101, 102 if (game completed) then ( show textbox (105) #"you have previously finished this game in ${V101} hours and ${V102} minutes" ) else ( show textbox (106) #"you have yet to complete the game!" ) wait for textbox end
exportglobals
readglobal
export globals (slot, first, last)
export globals
Writes a range of globals to a save game slot, overwriting the saved game's globals.

slot

is the save slot number, from 1 to 32. Note that only slots 1-4 appear on the save/load menus.

first

and

last

are the id numbers of the globals at the beginning and end of the range.

first

defaults to 0, and

last

defaults to 4095. Therefore, if you pass no range, all the globals will be written.

You can export globals to an empty slot! This doesn't create a visible save game that the player can load, however you will still be able to read them with importglobals.

Unlike importglobals, 'export globals (slot, first)' does NOT export a single global variable!

importglobals
writeglobal
run script by ID (id, argument1, argument2, argument3...)
run script by ID
The

run script by id

allows you to run a script using its ID. The advantage of this as opposed to just calling the script directly is that the ID may be stored in a variable, or it could be the function return value of another script. Arguments after the ID will be passed to the script. The script can also return a value as normal. A runtime error is displayed and -1 is returned if the script does not exist. You can pass up to 31 arguments to the script.

No check on the correct number of arguments can be performed, so default arguments are not used.

plotscript,scriptcallingtest,begin show value (run script by id (@sum, 1, 2, 3)) end

script,sum,a,b,c,begin return(a+b+c) end
get damage cap
get damage cap
Returns the current damage cap, or 0 if none
set damage cap (cap)
set damage cap
Sets the current damage cap to

cap

. Use 0 for no cap.
trace (string)
trace
Writes string #

string

to "g_debug.txt", located in the same directory as the RPG file or game.exe. For debugging you will nearly always use tracevalue instead, which is much easier.
variable (i) i := random (1, 1000) $1 = "i = " append number (1, i) # string 1 is "i = ????" trace (1) # writes "TRACE: i = ????" to g_debug.txt
trace value (expression, ...)
trace value
Prints one or more expressions and their values to "g_debug.txt". The number of arguments to this command is variable; each is printed as source text along with its value. You can't print strings with this command; use trace instead.
variable(i) i := random (1, 1000) trace value (i) # writes "TRACE: i = ????" to g_debug.txt

# This writes something like "TRACE: hero X (me) = 14, hero Y (me) = 53" to g_debug.txt trace value (hero X (me), hero Y (me))
save map state (whichdata, customid)
save map state
Saves the state of the current map to a temporary file which will be loaded (unless the map is set to ignore that particular data) when you reenter the current map, in the same way as a map set to save (remember) NPC or tile data: the saved state will be used instead of the map data in the RPG file. Both arguments are optional and are only for advanced uses. Map state is not saved in saved games, and the temporary files will be deleted when you load or start a new a game!

whichdata

is an or'd combination of the following constants, which specify exactly what you want to save:

- mapstate:all = mapstate:mapsettings, or, mapstate:npcs, or, mapstate:tiles
- mapstate:npcs = mapstate:npclocations, or, mapstate:npcdefinitions
- mapstate:tiles = mapstate:tilemap, or, mapstate:passmap, or, mapstate:zonemap
- mapstate:mapsettings
- mapstate:npclocations
- mapstate:npcdefinitions
- mapstate:tilemap
- mapstate:passmap
- mapstate:zonemap

The default is mapstate:all. If

customid

is passed, it is used to save the state in a separate state file with an id number of

customid

which can only be loaded with loadmapstate. There are 32 available slots for use: 0 - 31.Note that mapstate:mapsettings (also saved by mapstate:all) is special in that if you save it, it will always be loaded when the map is loaded regardless of settings. It saves all the settings found in the General Map Settings menu like the ambient music, footoffset, map trigger scripts, and so forth, and also the tileset for each layer.
plotscript, generic menu screen, begin variable (remember map, remember x, remember y) remember map := current map remember x := hero x remember y := hero y # we want NPCs and things to stay in the same place after we come back from the menu save map state

fade screen out wait teleport to map (map:generic menu) fade screen in wait

# menu code here #... #...

fade screen out wait teleport to map (remember map, remember x, remember y) # assume the map is set to load state only, the default (otherwise, use load map state) fade screen in wait

# we want the map to go back to resetting whenever you enter/exit it (like normal) delete map state end
load map state (whichdata, customid)
load map state
Load temporary map state data previously saved either by savemapstate or when leaving a map set to remember state. The two arguments are optional and for advanced use.

whichdata

is a set of bits in the savemapstate format to determine what exactly to load. The default is mapstate:all.

customid

is a number between 0 and 31 of a slot in which a custom save was made. Data from a different map can be loaded, but only tile data from a map of the same size! If you attempt to load state data which has not been saved then it will be loaded from the game files instead, unless you are using

customid

, in which case nothing will be loaded.
reset map state (whichdata)
reset map state
Reloads original unaltered map data from the RPG file.

whichdata

is a set of bits in the savemapstate format to determine what exactly to load. It is optional and the default is mapstate:all. This does not remove temp state files for the map, so they could still be loaded instead when you next enter the map, use deletemapstate to remove them if wanted.
delete map state (whichdata)
delete map state
Deletes temporary map state files for the current map, so that if the map is set to load NPC or tile data it will load the original data from the game files when it is entered.

whichdata

is a set of bits in the savemapstate format to determine what exactly to delete. The default is mapstate:all.
get tile animation offset (animation pattern, layer)
get tile animation offset
Returns the offset from the starting tile that the

animation pattern

(either 0 or 1) of the tileset in use by the

layer

(0 to 2) is currently at. For example, if the pattern has stepped 1 to the right, the offset is 1, if it has moved down 2 and 1 to the left, it is 31 (2 * 16 - 1). Because different layers can have different tilesets, you might need to specify the layer with the tileset to examine; otherwise layer 0 is assumed.

Layers that use the same tileset do NOT have different copies of the tileset. Layers with the same tileset will always have the same tile animation offsets.

readmapblock
animationstarttile
set tile animation offset (animation pattern, offset, layer)
set tile animation offset
Sets the offset from the starting tile that an

animation pattern

(either 0 or 1) of a tileset in use by a

layer

(0 to 2) is currently at. If there is a pattern defined, it will continue to step left, right, up and down from the offset you give it, until the end of the animation is reached, when the offset is reset to 0. Because different layers can have different tilesets, you might need to specify the layer with the tileset to examine; otherwise layer 0 is assumed.

Layers that use the same tileset do NOT have different copies of the tileset. Layers with the same tileset will always have the same tile animation offsets, you can not change them independently.

milliseconds
milliseconds
Use to measure time intervals accurately. Subtract two values returned by milliseconds at different times to find the number of ms (1000ths of a second) elapsed in between. A single value is useless (the computer's uptime or any random value).

# Predefined Constants

Numeric Constants
Numeric Constants
PLOTSCR.HSD defines constants for the numbers from 0 to 10. you can use these constants to make your scripts look friendly :)zero, one, two, three, four, five, six, seven, eight, nine, ten
numericconstants
zero
numericconstants
one
numericconstants
two
numericconstants
three
numericconstants
four
numericconstants
five
numericconstants
six
numericconstants
seven
numericconstants
eight
numericconstants
nine
numericconstants
nine
Key Constants
Key Constants
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 waitforkey command.any key, up key, down key, left key, right key, use key, menu key, cancel key
keyconstants
any key
keyconstants
up key
keyconstants
down key
keyconstants
left key
keyconstants
right key
keyconstants
use key
keyconstants
menu key
keyconstants
cancel key
Boolean Constants
Boolean Constants
PLOTSCR.HSD defines constants for true and false, and for ON and OFF. These are useful for checking and setting the values of tags, and in conditional statements.true, false, on, off
booleanconstants
true
booleanconstants
false
booleanconstants
on
booleanconstants
off
Direction Constants
Direction Constants
PLOTSCR.HSD defines constants for each of the four directions. These constants are useful for commands such as walkhero and walknpc, which take a direction as an argument.north, south, east, west, up, down, right, left
directionconstants
north
directionconstants
south
directionconstants
east
directionconstants
west
directionconstants
up
directionconstants
down
directionconstants
right
directionconstants
left
me
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
none is a constant that means the same as zero.
autonumber
autonumber
ubersetzung
autonumber is a constant that is used as the ID number in old-style definescript commands. This is not needed anymore. Use script instead.
current stat
current stat
A constant for use with the getherostat and setherostat commands.
maximum stat
maximum stat
A constant for use with the getherostat and setherostat commands.
inside battle
inside battle
A constant used in the getheropicture, setheropicture, getheropalette, setheropalette, resetheropicture and resetheropalette commands to represent the battle graphics.
outside battle
outside battle
A constant used in the getheropicture, setheropicture, getheropalette, setheropalette, resetheropicture and resetheropalette commands to represent the walkabout graphics.
Color Constants
Color Constants
PLOTSCR.HSD defines constants for each of the three primary colors. These are used in commands like readcolor or writecolor color:red, color:green, color:blue
colorconstants
color:red
colorconstants
color:green
colorconstants
color:blue
Mouse Constants
Mouse Constants
PLOTSCR.HSD defines constants for use with the mouse functions. They're used the mousebutton command.left button, right button
mouseconstants
left button
mouseconstants
right button
get count
get count
When passed to npcatpixel, npcatspot, sliceatpixel, findcollidingslice or zoneatspot they return the number of NPCs, slices or zones at that spot. With spellslearnt returns the number of spells a hero learnt. With findenemyinformation, returns the number of enemies, or the number of some kind of enemy in the formation.
Tile Constants
Tile Constants
PLOTSCR.HSD defines constants for use with functions like readpassblock or writepassblock.north wall, east wall, south wall, west wall, vehicle A, vehicle B, harm tile, overhead tile
tileconstants
north wall
tileconstants
east wall
tileconstants
west wall
tileconstants
south wall
tileconstants
vehicle A
tileconstants
vehicle B
tileconstants
harm tile
tileconstants
overhead tile
crop
crop
A constant used in setmapedgemode which makes the edges of the map impassible and prevents the camera from scrolling off them.
wrap
wrap
A constant used in setmapedgemode which lets the player walk over the edge of the map around to the opposite side.
default tile
default tile
A constant used in setmapedgemode which makes the edges of the map impassible and displays a specified tile everywhere off the edge of the map.
party
party
Pass as first argument to giveexperience to divide the experience between all the live heroes in the battle (active) party.
x axis
x axis
Pass to joystickaxis to specify the X axis (left and right).
y axis
y axis
Pass to joystickaxis to specify the Y axis (up and down).
timer: default
timer: default
Pass to settimer to leave one of the parameters at its default setting. Valid for any parameter except

id

timer: game over
timer: game over
Pass to settimer in the

trigger

field to have the game end when the timer runs out.
timer flag: critical
timer flag: critical
Pass to settimer in the

flags

field to indicate that if the timer runs out during a battle, it should end the battle immediately.
timer flag: battle
timer flag: battle
Pass to settimer in the

flags

field to indicate that the timer should run during battle. Otherwise, the timer will be paused during battle.
timer flag: menu
timer flag: menu
Pass to settimer in the

flags

field to indicate that the timer should run while the player is in the menu. Otherwise, it will be paused while the player is in the main menu.
song: silence
song: silence
Used with setformationsong and getformationsong to indicate an enemy formation without music. Used by setambientmusic and getambientmusic for a silent map.
song: same as last map
song: same as last map
Used with setformationsong and getformationsong to indicate an enemy formation which uses the same music as the map. Used by setambientmusic and getambientmusic for a map that continues with the last map's music.
song:sameaslastmap
song: same as map