#example map and command list.
#comments are marked with #, spaces/caps don't matter in the def section.

#This is the actual map. Use a fixed-width font to display/edit correctly.
#By tradition, 0 is rock, 1 is grass, but any letters, numbers, or symbols
#can be used. Case matters here, in order to give 24 extra tiles.

0200000
01111h0
0111000
0111350
0000000

#After the map comes the definitions section.
:def
#This gives the monsters that inhabit the area. They are defined in
#monster.txt
monster=Ant
monster=Rat

#This defines what the '0' character meant when used in the map.
:0
#Use the rock.png picture when displaying. Take a look at the
#images directory for the list of usable pictures.
pix=rock
#No, you can not walk on it. Use either 0 or 1. This is a bit
#backwards, but it's a bit too late to change it.
walk=1

:1
pix=grass
walk=0

:2
#Example of stairs.
pix=mine
walk=0
#This does the work, moving the player to map2.txt, xy coord. 5, 7
action=move map2.txt 5 7

:3
#example3.png does not exist.
pix=example3
walk=1
#if you have already attacked, let the player through.
action=if var have_attacked 1 | walk 0 | pass
#If you have already attacked, stop the script
action=if var have_attacked 1 | end | pass
#A dialog box will display this.
action=info Looks interesting.
#Ask the player to enter the hole. If they answer no, the script ends
#(without allowing them to move). If they answer yes, the script continues.
action=if question Enter this hole? | pass | end
#Attack the player with an Ant. If they run, the script ends. If they die,
#endgame.txt is processed. If they win, the script continues.
action=if attack Ant | pass | end
#set have_attacked, so it will only work once.
action=set have_attacked 1
#allow movement over this square after attacking.
walk 0

:h
pix=grass
walk=0
#run the tile "Find Gold"
action=if var get_gold 1 | info You find an empty chest | run Find Gold

#Note that tile names do not need to be just one character. While this tile
#cannot be displayed on the map, it can be called with the "run" command.
#This can be useful in building larger scripts.
:Find Gold
action=info You find some gold.
action=give gold 50
action=set get_gold 1

:5
pix=exit
walk=0
#Note the \. That continues the line. Rephased, it would be:
#action=info You Win
action=info \
You Win
#Call wingame.txt.
action=win

#Complete list of working commands:
#Each entry gives the syntax, then an example, then some comments on the
#command. Also see the files in the data directory.

#\
#action= info \
#Display line.
#Not a real command, but if a line ends with \, it can continue to the
#next line.

#monster=String
#monster=Cave Bear
#Note that this only goes between :def and the first tile definition.
#It specififies the monsters available on the map. Use a monster more than
#once to weight the listings. (ie, Ant, Ant, and Spider will give Ants twice
#as often as Spiders.)


#:Letter or Number
#:t
#Start defining a new tile. Note that case matters, and only use one digit.

#pix=Filename minus .png extension
#pix=grass
#Give the displayed picture. Only .png is supported, and the file must be in
#the images directory

#walk=Number
#walk=0
#Can the player walk on it? The only values accepted are 0 (can walk) and
# 1 (can not walk)

#action=String
#action=pass
#Scripting associated with the tile. The rest of this file describes
#possible strings. Prepend action= to anything listed from now on.


#Action Strings

#attack random Mapname OR attack String
#attack random level4.txt
#attack Ant
#Attack either a random monster from the map Mapname, or the monster
#given with String.

#die
#Die. This kills the player, and calls endgame.txt.

#end
#End processing the script. Note that this is only useful with If.

#give String Number
#give maxhp 5
#Adjust stats; possible values for String: hp, ep, maxhp, maxep, attack,
#defense, gold, exp, skillpoints. Note that Number can be either
#positive or negative.

#hero Filename minus .png extension
#hero hero_w
#Give a specific picture to the hero. While any picture can be used (that would
# work for pix=) it is recommended to use one of the hero_n (s, e, w) pictures.

#hurt Number
#hurt 10
#Injure the player for Number points, reduced by armor.

#if Action1 | Action2 | Action3
#if rng 1 5 | attack random 2 | pass
#Perform Action1. (This can be any action, though some are more useful
#than others) If it is successful, (action returned 1) perform Action2.
#Otherwise, perform Action3. End and Pass are useful for the 2nd/3rd places,
#and Attack, Item, Rng, Question, Var, and Take are useful for the 1st.
#For actions that may kill the player, (eg: Hurt, give hp -5) simply follow the
#action with others, and don't bother with If, as death ends the script anyway.
#For Attack, success is defined by destroying the monster, failure by
#running away. Death simply ends the script.

#info String
#info Hi there!
#Give the player a message box.

#item String
#item light healing potion
#Give the player the item specified. (case-insensitive) Fails if the
#inventory is full.

#lose
#Lose the game. Note that this does not call endgame.txt, differing it from
#die. Use die whenever possible.

#move mapname x y
#move town.txt 4 6
#Move the player to the given location. mapname is the complete filename of the
#map, (no need for path) and x and y are the xy coordinates inside the map.

#pass
#Do nothing. Only useful with If.

#pix Filename minus .png extension
#pix rock
#change the picture to the given file. Same rules as standard pix= apply.

#question String
#question Leave this area?
#This creates a dialog box with a body of String and yes/no buttons.
#Use with the If command.

#refresh
#Refresh the screen. This is useful if you want to move the player *then*
#show a dialog box. Leaves the player pointing to the west. If you don't like
#that, use the hero command after refreshing.

#rng Number1 Number2
#rng 4 9
#This creates a random number between 1 and Number2. (ie, if Number2 is 3, the
#possible values are 1, 2, or 3.) The number is then compared with Number1.
#If Number1 is higher or equal, 1 is returned. Otherwise, 0 is returned.
#This is meant to work with the If action.
#Note that the probability of 1 returning can be expressed as the fraction
#Number1/Number2. ie, rng 3 4 will return 1 3/4ths of the time.

#run String
#run Monster Attack
#This command runs the tile defined by String. Note that even through most
#tiles are only a single character, any string will work. The example runs
#the tile "Monster Attack".

#set String Number
#set have_entered 1
#set a variable. Use var String Number to compare. This information is
#saved when saving the game, and is useful for one-time actions.

#store Number
#store 3
#Enter a store. The possible values are 1 (Weapons store), 2 (General store),
#3 (Armory), and 4 (Training Hall).

#take String
#Take or drop an inventory item. When used with If, can implement keys and
#the like.

#var String Number
#var have_entered 1
#returns 1 if the value of String is Number. Use with If.

#walk Number
#walk 1
#Change the walkable status to the given number. Same rules as standard walk=

#win
#Call wingame.txt.