onload/action:

each tile has two scripts; one for when the map is entered (onload), and one for when the tile is touched by the player (action). The tile definition starts in onload mode, and can switch back and forth using "onload" and "action". There are two elements that need to be in the onload section; "pix", and "walk". Putting a few "if" statements in would also work. Commands like info, on the other hand, are a bad idea.

xy

The "xy" command will switch from defining types of tiles, to specific tiles. For example, you could fill an area with grass, then add something to some of the grass squares. Use ":x, y" to give data for a certain xy coord. (again, the tile starts out in onload mode, and can move to/from action) and the "tiles" command to move back. THIS MAY NOT CURRENTLY WORK.

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 for working examples of these commands.

\

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

~Action~ embedded commands

info ~5~
(will print 5)
Also not a real command, but dialog, info, and question commands, when given two "~" characters with a command between them, will interpret the command, and print the returned data. Stat and Var commands work well with this. As a side note, use ~~ to print the "~" symbol once.

battle_bg=filename

battle_bg=underground.png
Note that this only goes between :def and the first tile definition. It specifies which picture to use for the background when in battle. Subdirectories should work, in the same way as tiles. All filenames are relative to images/backgrounds/.

hero_bg=String

hero_bg=_raft
Note that this only goes between :def and the first tile definition. If given, then instead of using people/hero_n.png (for example) as the hero picture, people/hero_nString.png will be used. In the _raft example, the file people/hero_n_raft.png would be used whenever the hero moves north.

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. Also note that the tile "1" will be used for off-map portions.

Number

3
returns the given number. Useful for if statements.

action

Switch to defining the action scripting, which is called when the player moves into or over the tile. Also see onload.

addpix Filename

addpix potion.png
Places the given picture on top of the current tile. It is recommended to use a tile with transparent areas; otherwise, pix would give the same power with better performance. The same restrictions as the pix command apply.

addskill String

addskill Rage
Gives the player the specified skill. Returns 1 on success, or 0 on failure. (Either through the player already having the skill, or the skill not existing.) Use Rage, Sneak Away, Dismember, or Frenzy.

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. Returns 1 if the player won, 0 if the player ran, or ends the script and calls endgame.txt if the player loses.

damage_monster OR damage_monster Command

damage_monster
damage_monster stat attack
Only works in battle. In battle, it attacks the opposing monster, asking the player to select a monster if needed, either with the power of the currently held weapon (as if the player hit the "attack" button in-battle), or at a specified (Command) power. Returns 1 if the attack went through, or 0 if the player canceled/no enemy exists to attack. It differs from hurt_monster in that it is not reduced by armor.

delpix Filename

delpix items/light_healing_potion.png
Removes the given picture from the tile. Returns 1 if the picture existed, and 0 if the picture did not.

dialog String

dialog This message will popup.
This displays a message in a dialog box. Useful when giving a lot of information to a user, or when dealing with story information. This command can use ~Action~ embedded commands.

die

Die. This kills the player, and calls endgame.txt. Automatically called upon hp reaching 0.

end

End processing the script. Note that this not only ends processing the script, but when attached to an item or something for sale in a store, prevents the item from being destroyed on use/paid for.

find "String" String

find "light healing potion" a
find "gold" 30
Asks the player if they want to pick up the item. Returns 1 if the item was picked up, or 0 if it failed. The item either needs to be defined in items.txt, or be gold. If gold, list the amount of gold. Otherwise, list either a or an as the second argument.
Example:
pix grass.png
if var gold_1 | pass | addpix items/gold.png
walk 1
Action
if var gold_1 | end | pass
if find "gold" 5 | set gold_1 = 1 | end
delpix items/gold.png


give String Action

give maxhp 5
give gold rng 9 9
Adjust stats; possible values for String: name, hp, ep, maxhp, maxep, attack, defense, gold, exp, skillpoints. Note that Number can be either positive or negative, and can be any number or command.
(rng works best, though)
The exception is name, which is interpreted literally. However, ~Action~ commands work with name.

hero Filename minus .png extension

hero people/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. This lasts until the player moves.

hurt Action

hurt 10
hurt rng 5 5
Injure the player for Number or Action points, reduced by armor.

hurt_monster OR hurt_monster Command

hurt_monster
hurt_monster stat attack
Only works in battle. In battle, it attacks the opposing monster, asking the player to select a monster if needed, either with the power of the currently held weapon (as if the player hit the "attack" button in-battle), or at a specified (Command) power. Returns 1 if the attack went through, or 0 if the player canceled/no enemy exists to attack. It differs from damage_monster in that it is reduced by armor.

if Action1 Comparison Action2
Action3
else
Action4
endif

if rng 4 5>2
attack random level1.txt
else
info A narrow escape
give exp 5
endif
Performs Action1 and Action2, (These can be any actions, though some are more useful than others) then compares them. (either use =, <, >, <=, or >=) If the comparison is true, then perform Action3. Otherwise, perform Action4. Attack, Item, Rng, Question, Var, and Take are useful for the 1st/2nd actions.
Note that actions 3 and 4 can actually be any number of commands, that beginning whitespace is ignored, the "else" portion does not need to be given, and If commands can be stacked indefinitely.
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. (And calls endgame.txt)

info String

info String ~Action~
info Hi there!
info Your random number is ~rng 5 5~
Put the given line into the message scroller. Note that if a line contains ~Action~, it will be replaced by the return value of the action.

is_equipped String

is_equipped Dagger
Checks to see if the given item is being worn, and, if so, returns 1. Otherwise returns 0.

item String

item light healing potion
Give the player the item specified. (case-insensitive) Fails if the inventory is full, so use with if to prevent trapping the player in an unwinable state.

lose

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

mapstat String String

mapstat addmonster Ant
mapstat delmonster Ant
mapstat hero_bg _raft
mapstat hero_bg
mapstat battle_bg underground.png
Adjust stats for the map. Allowed options for the first string are addmonster, delmonster, hero_bg, and battle_bg. The options for the second string are the same as the options for the relevant command mapstat enhances, with the addition that hero_bg works with an empty string.

move mapname x y

move town.txt 4 6
Move the player to the given location. mapname is the complete filename of the map, (subdirectories do not work) and x and y are the xy coordinates inside the map.

onload

Switch to defining the onload scripting, which is called when the player enters the map. Also see the action command. The tile starts in onload mode, so this command gives no extra power, but can help convenience.

pass

Do nothing. Only useful with If.

pix Filename

pix rock.png
Change the picture to the given file. Only .png is supported, and the file must be in the images/tiles directory. One of these in the onload section of a tile is highly recommended. Note that subdirectories are supported.

printvars

printvars
Used for debugging purposes. Prints out all the current variables to the console. Not pretty, but gives the needed information.

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. Yes returns 1, and No returns 0. This command can use ~Action~ embedded commands.

refresh

Refresh the screen. This is useful if you want to move the player *then* show a dialog box.

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, the random number is returned. Otherwise, 0 is returned. Note that the probability of >0 returning can be expressed as the fraction Number1/Number2. ie, rng 3 4 will return True 3/4ths of the time. Also note that rng 5 5 will return a random number between 1 and 5, which can be used in the give and hurt commands. Finally, note that rng 4 5 will give a random number between 0 and 4.

run mapname x y

run town.txt 4 6
This command runs the tile defined.

set String Operation Number

set have_entered=1
set num_attacked +1
set a variable. Use the var command to compare. This information is saved when saving the game, and is useful for one-time actions. Use either -, +, or = as the Operation.

stat String

stat maxhp
Returns the value of the stat String. Possible values for String: hp, ep, maxhp, maxep, attack, defense, gold, exp, skillpoints.

store String

store a Weapons Store
Enter a store. Check shops.txt for the possible values.

take String

Remove an item from the inventory. When used with If, can implement keys and the like. Returns 0 on failure, 1 on success.

var String

var have_entered
returns the current value of String, or 0 if String is unset. Use with If.

walk Number

walk 1
Set the ability for the player to walk on it. The only values accepted are 0 (can walk) and 1 (can not walk)

win

Call wingame.txt.

Other information:

When debugging, run the game from the command line. All errors are sent that direction.

To create your own module, create a directory in modules, called whatever you want. (Make it fairly descriptive, though.) Include the needed files (copy-paste from another module would be the easy way to do this, though note that the save/ directory is unneeded) and everything should work.

Note that subdirectories in the tiles/ directory will work.

When drawing buttons, it is possible to change some widths and heights. Make sure the buttons form a rectangle after assembly, and you should be fine.

This file may not be entirely accurate. Check action.py in the code directory for the code behind this file. Tell me about any documentation errors found.