Added utility macros IF (finally!) and FLOATING_TEXT.

This commit is contained in:
Lari Nieminen 2007-04-28 09:32:11 +00:00
parent 6d009b4e82
commit bb7a976f6d
2 changed files with 45 additions and 1 deletions

View file

@ -3,6 +3,26 @@
# These don't depend on any other macros. Please don't change this.
# ! in comments is used in generating HTML documentation, ignore it otherwise.
#define IF VAR OP VAL CONTENTS
# Shortcut for IF statements testing the value of a variable. Need to write
# [then] and [else] tags manually.
# Use like this:
#! {IF some_variable equals yes (
#! [then]
#! ...
#! [/then]
#! )}
[if]
[variable]
name={VAR}
{OP}={VAL}
[/variable]
{CONTENTS}
[/if]
#enddef
#define IF_ALIVE PLAYER ACTION
# Condition triggering of ACTION om whether PLAYER has at least one unit left.
# For example, if the player 2 is still alive, kill all his units.
@ -45,7 +65,7 @@
#define IF_ALLIED PLAYER1 PLAYER2 ACTION
# Condition that triggers if PLAYER1 and PLAYER2 belong to the same team.
# NOTE: only works if leaders are alive, are the same leader as the game
# NOTE: only works if leaders are alive, are the same leader as the game
# started and haven't changed teams.
# For example, if player 3 and 4 is allied, steal 10 gold from each:
#! {IF_ALLIED 3 4 (

View file

@ -17,6 +17,30 @@
[/message]
#enddef
#define FLOATING_TEXT FILTER COLOUR TEXT
# Floats the given text above the given unit in the same manner as damage
# numbers are displayed in combat.
# For example when a unit steps on a hidden trap and is dealt 8 damage, let's
# show this to the player like all other damage is:
#! {FLOATING_TEXT x,y=$x1,$y1 255,0,0 "8"}
[store_unit]
[filter]
{FILTER}
[/filter]
kill=no
variable=FLOATING_TEXT_temp
[/store_unit]
[unstore_unit]
variable=FLOATING_TEXT_temp
find_vacant=no
red,green,blue={COLOUR}
text={TEXT}
[/unstore_unit]
{CLEAR_VARIABLE FLOATING_TEXT_temp}
#enddef
#define SET_LABEL X Y TEXT
# Puts TEXT on the map at X,Y. Strictly a syntactic shortcut.