tweak some mcro forms so the calls can be typechecked.

This commit is contained in:
Eric S. Raymond 2009-03-03 02:40:17 +00:00
parent d09b5ca22e
commit 52bdbab51d
6 changed files with 29 additions and 27 deletions

View file

@ -132,14 +132,14 @@
[/clear_variable]
#enddef
#define ROLE TYPE ROLE X Y
#define ROLE TYPE ROLE_VALUE X Y
[role]
type={TYPE}
side=1
role={ROLE}
role={ROLE_VALUE}
[/role]
[recall]
role={ROLE}
role={ROLE_VALUE}
x,y={X},{Y}
[/recall]
#enddef

View file

@ -1,12 +1,12 @@
#textdomain wesnoth-ei
# Macros for decorating the throneroom map.
#define THRONEROOM_GUARD TYPE X Y FACING
#define THRONEROOM_GUARD TYPE X Y FACING_VALUE
[unit]
side=2
x,y={X},{Y}
type={TYPE}
facing={FACING}
facing={FACING_VALUE}
[/unit]
#enddef

View file

@ -267,7 +267,7 @@ Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Goblin Spearman#enddef
# Thanks to Shadow Master for this macro
# !***Macro to random place unit within area***
#define RANDOM_PLACEMENT _X _Y _RADIUS _UNIT_WML_STRUCT
#define RANDOM_PLACEMENT _X _Y _RADIUS _WML
[store_locations]
x,y={_X},{_Y}
radius={_RADIUS}
@ -283,7 +283,7 @@ Orcish Archer, Orcish Assassin, Orcish Grunt, Wolf Rider, Goblin Spearman#enddef
{CLEAR_VARIABLE random_placement_locations}
{_UNIT_WML_STRUCT}
{_WML}
[+unit]
x,y=$random_placement_x,$random_placement_y

View file

@ -1,23 +1,23 @@
#textdomain wesnoth-tutorial
#define TEACHER MESSAGE
#define TEACHER MESSAGE_TEXT
[message]
speaker=Galdrad
message={MESSAGE}
message={MESSAGE_TEXT}
[/message]
#enddef
#define STUDENT MESSAGE
#define STUDENT MESSAGE_TEXT
[message]
speaker=student
message={MESSAGE}
message={MESSAGE_TEXT}
[/message]
#enddef
#define NARRATOR MESSAGE
#define NARRATOR MESSAGE_TEXT
[message]
speaker=narrator
message={MESSAGE}
message={MESSAGE_TEXT}
image=wesnoth-icon.png
[/message]
#enddef
@ -28,7 +28,7 @@ You can press 'u' to undo most things; useful for correcting mistakes.")}
[allow_undo][/allow_undo]
#enddef
#define TALK_ABOUT ID_STRING MESSAGE
#define TALK_ABOUT ID_STRING MESSAGE_TEXT
[scroll_to_unit]
id={ID_STRING}
[/scroll_to_unit]
@ -37,21 +37,21 @@ You can press 'u' to undo most things; useful for correcting mistakes.")}
speaker=narrator
image=portraits/elves/captain.png
message=_ "*Galdrad" + "
" + {MESSAGE}
" + {MESSAGE_TEXT}
[/message]
#enddef
#define TALK_NO_MOVE MESSAGE
#define TALK_NO_MOVE MESSAGE_TEXT
# Pretend this is narrator, since otherwise we scroll back.
[message]
speaker=narrator
image=portraits/elves/captain.png
message=_ "*Galdrad" + "
" + {MESSAGE}
" + {MESSAGE_TEXT}
[/message]
#enddef
#define TALK_ABOUT_LOC POSITION MESSAGE
#define TALK_ABOUT_LOC POSITION MESSAGE_TEXT
[scroll_to]
x,y={POSITION}
[/scroll_to]
@ -60,7 +60,7 @@ You can press 'u' to undo most things; useful for correcting mistakes.")}
speaker=narrator
image=portraits/elves/captain.png
message=_ "*Galdrad" + "
" + {MESSAGE}
" + {MESSAGE_TEXT}
[/message]
#enddef

View file

@ -135,13 +135,13 @@
[/if]
#enddef
#define ANL_RESCUE_TRAPPED_UNIT X Y X2 Y2
#define ANL_RESCUE_TRAPPED_UNIT MOVETO_X MOVETO_Y UNIT_X UNIT_Y
[event]
name=moveto
[filter]
side=1,2,3,4
x={X}
y={Y}
x={MOVETO_X}
y={MOVETO_Y}
[/filter]
[message]
@ -156,8 +156,8 @@
[store_unit]
[filter]
x={X2}
y={Y2}
x={UNIT_X}
y={UNIT_Y}
[/filter]
variable=critter
kill=no

View file

@ -126,7 +126,9 @@ def isresource(filename):
def formaltype(f):
# Deduce the expected type of the formal
if f in ("SIDE", "X", "Y", "RED", "GREEN", "BLUE", "TURN", "RADIUS") or f.endswith("NUMBER") or f.endswith("AMOUNT") or f.endswith("_X") or f.endswith("_Y"):
if f.startswith("_"):
f = f[1:]
if f in ("SIDE", "X", "Y", "RED", "GREEN", "BLUE", "TURN", "RADIUS") or f.endswith("NUMBER") or f.endswith("AMOUNT") or f.endswith("COST") or f.endswith("_X") or f.endswith("_Y"):
ftype = "numeric"
elif f in ("POSITION",):
ftype = "position"
@ -140,7 +142,7 @@ def formaltype(f):
ftype = "terrain_code"
elif f in ("NAME", "VAR", "IMAGESTEM", "ID") or f.endswith("_NAME"):
ftype = "name"
elif f in ("STRING", "TYPE", "TEXT"):
elif f in ("STRING", "TYPE", "TEXT") or f.endswith("_TEXT"):
ftype = "string"
elif f in ("ID_STRING", "NAME_STRING", "DESCRIPTION"):
ftype = "optional_string"
@ -150,7 +152,7 @@ def formaltype(f):
ftype = "sound"
elif f in ("FILTER",):
ftype = "filter"
elif f.endswith("_WML"):
elif f == "WML" or f.endswith("_WML"):
ftype = "wml"
elif f in ("AFFIX",):
ftype = "affix"