Commands
// for program execution:
set flagname; sets a flag to true
unset flagname; sets a flag to false
if ( flag) operation; the operation will only be executed wenn flag is true
else operation; executes an operation wenn flag was false
for (init-op; flag; incr-op) operation; executes , then while flag is true <operation;incr-op>
while ( flag) operation; repeats the operation while flag is true
break ends a loop and continues with the script that follows to the loop
continue jumps to the beginning of the loop (next loop round)
function funcname() { operations; } defines a function, can be called with funcname()
return ends the function immediatelly and returns to the function caller
sleep seconds; pauses the script execution for the specified time
setarray var,size; initializes var as an array of the specified size
setstring varname,value; creates a string variable ‘varname’ with the given value
timereverywhere; allows timeouts on this machine even if the player didn’t entered the level first
addstring list,text; adds a string to a string list (saved as flag)
insertstring list,index,text; inserts a string into a string list at the specified index
replacestring list,index,text; replaces the string at position ‘index’ with ‘text’
removestring list,text; removes all occurences of a string
deletestring list,index; deletes string list entry at position ‘index’
// simple npc manipulation:
setimg filename; changes the npc’s image
setimgpart filename,x,y,width,height; changes the npc’s image and only displays the rectangle (x,y,width,height) of it
hide; hides the npc
show; shows an hidden npc
dontblock; lets the npc don’t block the player anymore
drawoverplayer; draws the npc over the player
drawunderplayer; draws the npc under the player
drawaslight; draws the npc above day/night
blockagain; turns off the three previous flags
canbecarried; the npc can now be lifted and carried by the player
cannotbecarried; turns off the previous flag
canbepushed; the npc can now be pushed by the player
cannotbepushed; turns off the previous flag
canbepulled; the npc can now be pulled by the player
cannotbepulled; turns off the previous flag
// complex npc operations:
move dx,dy,time,options; moves the npc, options: cachtype(0,1,2)+blockcheck(4)+eventwhendone(8)+applydir(16)
say signindex; displays signs
say2 text; displays text as sign
lay itemname; lays an item
lay2 itemname,x,y; lays an item to the specified position
take itemname; takes an item if available
take2 index; takes the item with the specified index
message text; displays a text message over the npc
timershow; lets the npc’s timeout be shown
showcharacter; displays a player character instead of the npc image
setcharprop messagecode,string; sets string properties of the character
setcharani ganifile; sets the animation for the npc
setchargender gender; sets the gender of the npc (male/female)
triggeraction x,y,action,params; triggers a ‘if (action)…’ on the objects on (x,y)
putnpc imgname,scriptname,x,y; creates a npc, scriptname is the name of a textfile containing the npc script
callnpc index,eventflag; calls the script of another npc (not immediatelly)
callweapon index,eventflag; calls the script of a weapon (used together with the variable selectedweapon)
destroy; deletes the npc
carryobject carryobjectname; the character carries an object
throwcarry; throws the carried object
followplayer; lets the npc follow the player; the action script keeps running; set x/y to leave the player
toinventory flag; puts the npc into the player’s inventory until the flag is unset
toweapons weaponname; adds this npc to the players weapon list
seteffect red,green,blue,alpha; sets the day/night effect (default 0,0,0,0)
setcoloreffect red,green,blue,alpha; sets the color / alpha blending effect of the npc (default 1,1,1,1)
setzoomeffect zoomfactor; sets the zoom factor (default 1)
showimg index,filename,x,y; shows an image at the given position
hideimg index; removes the image with the specified index
changeimgpart index,x,y,width,height; changes the visible part of the showimg
changeimgvis index,drawingheight; changes the drawing height of the showimg (0,1,2,3,4)
changeimgcolors index,red,green,blue,alpha; sets color / alpha blending for the showimg (default 1,1,1,1)
changeimgzoom index,zoomfactor; sets zoom factor for the the showimg (default 1)
shootarrow direction; shoots an arrow
shootfireball direction; shoots a firewall
shootfireblast direction; shoots a fireblast
shootnuke direction; shoots an nukeshot
shootball; shoots a ball directly to the player
hitplayer index,halfhearts,fromx,fromy; hurts a player
hitnpc index,halfhearts,fromx,fromy; hurts an npc (changes hearts, hurtdx, hurtdy)
hidelocal; hides the npc (only for the current player)
showlocal; shows an hidden npc (only for the current player)
dontblocklocal; lets the npc don’t block the player anymore (only for the current player)
blockagainlocal; turns off the three block flags (only for the current player)
takehorse index; takes the horse with the specified index (only works in combination with ‘showcharacter’ )
tokenize str; divides str into words (tokens) which can be read with #t(index)
tokenize2 delims,str; divides str into tokens, using ‘delims’ as additional delimiters
setshape type,width,height; sets the shape of the npc: type=1 means rectangle (width,height in pixels)
setshape2 width,height,{tiletypes…}; sets the shape of the npc to a rectangle of tiles
// player manipulation:
setlevel filename; warps the player (URLs not supported)
setlevel2 filename,x,y; warps the player to the specified level and position
seturllevel URL; warps the player to an URL (without the leading http://!)
setbody filename; sets the body image for the player
sethead filename; sets the head image for the player
setsword imgname,power; changes the players sword (-20 £ power £ 20)
setshield imgname,power; changes the players shield (0 £ power £ 10)
setani ganifile; sets the animation for the player
setplayerdir direction; sets the player looking direction
setgender gender; sets the gender of the player (male/female)
setskincolor colorname; changes the player skin
setcoatcolor colorname; changes the player coat
setsleevecolor colorname; changes the player sleeves
setshoecolor colorname; changes the player shoes
setbeltcolor colorname; changes the player belt
setplayerprop messagecode,string; sets string properties of the player (except the nickname&guildcode)
takeplayercarry; removes the object carried by the player
takeplayerhorse; removes the player’s horse
disableweapons; disables the player’s sword+bombs+darts
enableweapons; enables the player weapons
freezeplayer seconds; the player can’t move for the given time
hideplayer seconds; hides the player for the specified time
hidesword seconds; hides the player’s sword for the specified time
hurt halfhearts; hurts the player
disabledefmovement; disables the normal player movement
enabledefmovement; enables it again
replaceani ani,newani; replaces a default animation
attachplayertoobj type,id; attachs the player to an npc (type=0)
detachplayer; detachs the player from the npc
// level/game manipulation:
hitobjects power,x,y; hurts all players/npcs/baddies on that position
updateboard x,y,width,height; makes level board modifies visible
putobject objectname,x,y; puts an object onto the board
putbomb power,x,y; puts a bomb on the board
putexplosion radius,x,y; puts an explosion on the board
putexplosion2 power,radius,x,y; puts an explosion on the board (power=1 -> normal, 3 -> jolt bomb)
putleaps leaptype,x,y; procduces an object ‘explosion’ (0-bush,1-swamp,2-stone,3-sign,4-ball,5-water)
puthorse imgname,x,y; puts a horse (or boat) on the board
setbackpal filename; the background gets the color palette of the specified image
setletters filename; signs will be displayed using the specified image instead of letters.png
setmap imgname,levelnamesfile,x,y; changes the map, the player will be placed on (x,y)
setminimap imgname,levelnamesfile,x,y; changes the minimap, the player will be placed on (x,y)
showstats bitflag; shows/hides parts of the stats bar (1-ASD,2-icons,4-rupees,8-bombs,16-arrows,32-hearts,64-ap,128-mp,256-minimap,512-inv,1024-player)
noplayerkilling; disables hurting with sword/npc weapons
removebomb index; removes the bomb with the specified index
removearrow index; removes the arrow with the specified index
removeitem index; removes the item with the specified index
removeexplo index; removes the explosion with the specified index
removehorse index; removes the horse with the specified index
explodebomb index; explodes the bomb with the specified index
reflectarrow index; reflects the arrow with the specified index (like a mirror shield)
addtiledef image,levelstart,type; specifys the tiles images for all levels that start with ‘levelstart’ (0-standard type,1-new order)
addtiledef2 image,levelstart,x,y; replaces parts of the tiles image
disableselectweapons; disables the weapon select screen
enableselectweapons; enables it again
// baddy manipulation:
putcomp baddyname,x,y; puts a new baddy on the board
putnewcomp baddyname,x,y,imgname,power; puts a baddy on the board (with the specified image and power)
hitcompu index,decrpower,fromx,fromy; hurts a baddy
removecompus; removes all baddies
// file operations:
play filename; plays a sound/music file or whatever can be played with ‘Windows Media Player’
play2 filename,x,y,volume; plays a sound/music at x,y with the specified volume (1=default volume)
playlooped filename; plays a sound file (.wav) looped
stopsound filename; stops playing a sound file (.wav)
stopmidi; stops playing the currently running midi file
setmusicvolume left,right; changes the volume for music (0…1)
openurl URL; opens the given URL in the default web browser (without the leading http://!)
openurl2 URL,width,height; opens the given URL in a webbrower window of the specified size (url without http://!)
showfile filename; opens the file with the program associated with the file extension
Special Symbols
! not
&& and
|| or
== equals
- addition
- substraction
- multiplication
/ division
% mod; a%b = a - int(a/b)*b;
^ power; a^0.5 = squareroot(a)
in tests if an array/range contains a variable (e.g. 2 in {1,2,3}; x,y in |0,64|)
= assigment
a += b a = a+b
a -= b a = a-b
a = b a = ab
a ++ a = a+1
a – a = a-1
this. variables that start with ‘this.’ are only accessible for the npc itself
Built-in Flags true when:
canspin the player has spin power (for sword)
carrying the player carries something
carriesblackstone the player carries a blackstone
carriesbush the player carries a bush
carriessign the player carries a sign
carriesstone the player carries a stone
carriesvase the player carries a vase
compsdead there is no living baddy
compusdied all baddies died
exploded the npc was exploded by a bomb
firedonhorse this npc weapon is fired while riding on horse
followsplayer the npc currently follows the player
hasweapon( name ) the player has the weapon specified with ‘name’
isleader the player entered the level first (of all players in the same room)
isonmap the player is on an outside level
issparringzone the player is in a sparring level
isweapon this npc is a weapon
keydown( key ) the specified key is pressed (0…10: up,left,down,right,S,A,D,M,tab,Q,P)
lighteffectsenabled the player can see light effects
nopkzone the player is in a level where you can’t hurt other players
onmapx( level ) x-position of the level on the current map
onmapy( level ) y-position of the level on the current map
onwall( x, y ) the specified field is blocked
onwater( x, y ) the specified field is water
playeronline the game is in online mode
peltwithblackstone the npc was pelt with a blackstone
peltwithbush the npc was pelt with a bush
peltwithnpc the npc was pelt with another npc
peltwithsign the npc was pelt with a sign
peltwithstone the npc was pelt with a stone
peltwithvase the npc was pelt with a vase
playerchats the player says something
playerdies the player died
playerendsreading the player finished reading
playerenters the layer enters the room
playerhurt the player has been hurt
playerisfemale the player is female
playerismale the player is male (specified in headsconfig.txt)
playerlaysitem somebody layed an item
playeronhorse the player rides on a horse (or boat)
playerreading the player is reading a sign
playerswimming the player is swimming
playertouchsme the layer touchs the npc
playertouchsother the player touchs another npc
playerattached the player is attached to this npc
shotbybaddy the npc was shot by a computer opponent
shotbyplayer the npc was shot by the player
startswith( partstr, str ) str starts with partstr
strcontains( str, partstr ) str contains partstr
strequals( str1, str2 ) str1=str2 (both strings can contain message codes)
timeout the npc’s timeout counter runs to 0
visible the npc is visible
washit the npc was slayed with a sword or axe
waspelt the npc was pelt
wasshot the npc was shot with arrows
wasthrown the npc was carried and then thrown
weaponfired this npc is used as weapon, ‘D’ (or joybutton1) is pressed
weaponsenabled the player weapons are enabled
Built-in Variables / Functions
x the npc’s horizontal position
y the npc’s vertical position (top=0)
timeout the npc’s timeout counter (seconds)
rupees the npc’s rupees count
bombs the npc’s bombs count
darts the npc’s darts count
hearts the npc’s hearts count
glovepower the npc’s glove power (1-glove1,2-glove2)
swordpower the npc’s sword power (1-normal sword,2-axe,3-lizardsword,4-golden sword)
shieldpower the npc’s shield power (1-normal sword,2-mirror shield,3-lizard shield)
dir the direction of the character
sprite the sprite of the character
ap the alignment points of the character
hurtdx will be set when the player uses the sword/npc weapon on the npc
hurtdy (x/y difference, >=-1, <=1)
save[0],…,save[9] built-in variables that work in online mode (integer values >=0, <=220)
npcscount the npcs count
npcs[index].id the server id of the npc
npcs[index].x an horses’s horizontal position
npcs[index].y an horses’s vertical position
npcs[index].width the width of the npc (in fields)
npcs[index].height the height of the npc (in fields)
npcs[index].timeout the timeout counter of the npc
npcs[index].rupees the rupees count of the npc
npcs[index].bombs the bombs count of the npc
npcs[index].darts the darts count of the npc
npcs[index].hearts the hearts count of the npc
npcs[index].glovepower the glove power of the npc
npcs[index].swordpower the sword power of the npc
npcs[index].shieldpower the shield power of the npc
npcs[index].dir the direction of the npc (if it’s a ‘showcharacter’)
npcs[index].sprite the sprite of the npc (if it’s a ‘showcharacter’)
npcs[index].ap the alignment of the npc (if it’s a ‘showcharacter’)
npcs[index].hurtdx will be set when the player hurts the npc (or
npcs[index].hurtdy (hitplayer/hitpnc is called) -> push away difference
npcs[index].save[0],…,save[9] built-in variables that work in online mode (integer values >=0, <=220)
playerscount the player count
players[index].x a player’s horizontal position
players[index].y a player’s vertical position
players[index].rupees a player’s rupees count
players[index].bombs a player’s bombs count
players[index].darts a player’s darts count
players[index].mp a player’s magic points (0…100)
players[index].ap a player’s alignment points (0…100)
players[index].hearts a player’s hearts count
players[index].fullhearts a player’s max hearts count
players[index].dir a player’s direction (0-up,1-left,2-down,3-right)
players[index].glovepower a player’s glove power (2-glove1,3-glove2)
players[index].swordpower a player’s sword power (1-normal sword,2-axe,3-lizardsword,4-golden sword)
players[index].shieldpower a player’s sield power (1-normal sword,2-mirror shield,3-lizard shield)
players[index].headset a player’s head sprites set (“head”+playerheadset+".gif")
players[index].sprite a player’s sprites set (0…40)
players[index].id a player’s id (=-1 for npc characters)
players[index].saysnumber the (index+1)th player says that number
players[index].id a player’s id (=-1 for npc characters)
players[index].attachid the player is attached to the npc with that id (<=0-> not attached)
players[index].attachtype the type of object the player is attached to
playerhurtdpower how much power the player lost when he was hurt last
playerhurtdx the horizontal hurting movement of the player
playerhurtdy the vertical hurting movement of the player
(playerx,playery,… = players[0].x,players[0].y,… = current players properties)
compuscount the baddy count
compus[index].x a baddy’s horizontal position
compus[index].y a baddy’s vertical position
compus[index].type a baddy’s type (0…9, see the baddy names list)
compus[index].dir a baddy’s body direction (0…3)
compus[index].headdir a baddy’s head direction (0…3)
compus[index].power a baddy’s power
compus[index].mode a baddy’s mode
bombscount the bombs count
bombs[index].x a bomb’s horizontal position
bombs[index].y a bomb’s vertical position
bombs[index].power the bomb’s power (1,2,3)
bombs[index].time the time left till explosion (3 … 0)
arrowscount the arrows count (arrows + balls)
arrows[index].x an arrow’s horizontal position
arrows[index].y an arrow’s vertical position
arrows[index].dx the horizontal speed per tick (0.05secs)
arrows[index].dy the vertical speed per tick (0.05secs)
arrows[index].dir the flying direction (0,1,2,3)
arrows[index].type the shottype (-1 -> ball, 0…3 -> arrow with power 1…4)
arrows[index].from the shooter (0 -> baddy, 1 -> current player)
itemscount the items count
items[index].x an item’s horizontal position
items[index].y an item’s vertical position
items[index].type the item type (0…24)
items[index].time the time left till the item disappears (8.2 … 0)
exploscount the explosions count (putexplosion produces 9 explosions of size 2x2!)
explos[index].x an explosion’s horizontal position
explos[index].y an explosion’s vertical position
explos[index].power the power of the bomb which produced this explosion
explos[index].time the time left till the explosion disappears
explos[index].dir the direction from the bomb which produced the explosion
horsescount the horses count
horses[index].x an horses’s horizontal position
horses[index].y an horses’s vertical position
horses[index].dir the direction of the horse
horses[index].bushes bushes eaten by the horse
horses[index].bombs bombs count in the horse’s mouth
horses[index].bombpower the power of the bombs on the horse’s mouth
horses[index].type the horse type (0 -> riding horse, 1 - boat)
signscount the signs count
signs[index].x a sign’s horizontal position
signs[index].y a sign’s vertical position
abs( var ) the absolute value
arctan( var ) the arcus tangens of var; (some maths: a = arctan( sin(a) / cos(a) ))
arraylen( var ) the size of an array
ascii( char ) the ascii code of a character
board[index] the level board (index = 0…6464-1)
cos( a ) the cosinus of a; a is an angle in the radiant system (0…3.14)
getangle( dx,dy ) the angle of vector (dx,dy) to the x coordinate (0…23.14)
graalversion current Graal version
indexof( partstr, str ) position of where partstr appears in str (-1 -> not in str)
int( var ) the integer value of a variable (truncates the floating point part)
levelorgx level origin (x), can be different to 0,0 if the player is attached to an npc
levelorgy level origin (y)
lindexof( str, list ) position of where the string appears in the string list
random( a, b ) a random floating point value, a<= value < b
sarraylen( list ) the size of a string list
screenheight screen height
screenwidth screen width (for the current player)
selectedweapon the index of the selected weapon of the player
sin( a ) the sinus of a; a is an angle in the radiant system (0…3.14)
strlen( str ) the length of the string
strtofloat( str ) the value of ‘str’ as number
testbomb( x, y ) the index of the bomb on position (x,y)
testcompu( x, y ) the index of the baddy on position (x,y)
testexplo( x, y ) the index of the explosion on position (x,y)
testhorse( x, y ) the index of the horse on position (x,y)
testitem( x, y ) the index of the item on position (x,y)
testnpc( x, y ) the index of the npc on position (x,y)
testplayer( x, y ) the index of the player on position (x,y)
testsign( x, y ) the index of the sign on position (x,y)
timevar a server-wide time variable which is increased by 1 all 5 seconds
tokenscount count of tokens produced with tokenize
vecx( dir ) vertical movement vector (0,-1,0,1)
vecy( dir ) horizontal movement vector (-1,0,1,0)
weaponscount count of weapons/items the player has
Itemname / item index
greenrupee 0
bluerupee 1
redrupee 2
bombs 3
darts 4
heart 5
glove1 6
bow 7
bomb 8
shield 9
sword 10
fullheart 11
superbomb 12
battleaxe 13
goldensword 14
mirrorshield 15
glove2 16
lizardshield 17
lizardsword 18
goldrupee 19
fireball 20
fireblast 21
nukeshot 22
joltbomb 23
spinattack 24
Carry object names
bush
sign
vase
stone
blackstone
bomb
hotbomb
superbomb
joltbomb
hotjoltbomb
none
Colornames
white
yellow
orange
pink
red
darkred
lightgreen
green
darkgreen
lightblue
blue
darkblue
brown
cynober
purple
darkpurple
lightgray
gray
black
transparent
Directions
up
left
down
right
(you can also use normal variables with values between 0 and 3)
Baddy names
graysoldier
bluesoldier
redsoldier
shootingsoldier
swampsoldier
frog
octopus <- spider, for compatibility
goldenwarrior
lizardon
dragon
Baddy modes
0 walking
1 looking
2 hunting
3 hurted
4 bumped
5 dying
6 shooting (swampsoldier)
7 jumping (frog)
8 shooting (spider)
9 dead
Player sprites
0 no movement, or not a default animation
1-8 walking
9-13 sword slaying
14-18 pushing
19-22 pulling
23 lifting
24 no movement, carrying something
25-32 walking, carrying something
33 shooting
34-36 riding
37 sitting
38 sleeping
39 hurted (can only be set on ‘showcharacter’-npcs)
40 dead (can only be set on ‘showcharacter’-npcs)
Message codes (for ‘message’, ‘strequals’, etc.)
#a the account name of the player
#b line break (for say2)
#C0, #C0(index) the skin color
#C1, #C1(index) the coat color
#C2, #C2(index) the sleeves color
#C3, #C3(index) the shoes color
#C4, #C4(index) the belt color
#c, #c(index) the current chat text of the player
#e(startindex,length,string) extracts a substring out of ‘string’ (length=-1 -> till the end)
#f the image filename of the npc
#g, #g(index) the guild name of the player
#I(list,index) gets a string of a string list
#i(imgname), #i(imgname,x,y,w,h) displays an image or a part of an image when used in a sign
#K(keyindex) the name of the specified key
#k(keyindex) the description of the specified key (in local language / key assignments)
#L the current level filename
#m, #m(index) the animation of the player
#n, #n(index) the nick name of the player (index=-1 -> npc character, 0 -> current player)
#P1, #P1(index) the gani attribute 1 (hat)
#P2, #P2(index) the gani attribute 2
#P3, #P3(index) the gani attribute 3
#P4, #P4(index) the gani attribute 4
#P5, #P5(index) the gani attribute 5
#p(index) action parameter of the specified index
#s(var) the value of the string variable ‘var’
#t(index) token of the specified index, produced with tokenize
#T(string) trims the string (removes spaces at the beginning and end)
#v(var) the value of ‘var’ as string
#W, #W(index) the filename of the weapon icon
#w,#w(index) the name of the current npc weapon of the player
#1, #1(index) the sword image filename of the player
#2, #2(index) the shield image filename of the player
#3, #3(index) the head image filename of the player
#5, #5(index) the image filename of the player’s horse
#6, #6(index) the image filename of the npc that is carried by the player
#8, #8(index) the body image filename of the player