forked from project-ethea/After_the_Storm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base-variables.cfg
179 lines (152 loc) · 3.95 KB
/
base-variables.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#textdomain wesnoth-After_the_Storm
#define VARIABLE_FROM_STRLEN VAR_ID RVALUE
{VARIABLE_OP {VAR_ID} string_length {RVALUE} }
#enddef
#define VARIABLE_RANDOM VAR_ID RVALUE
{VARIABLE_OP ({VAR_ID}) rand ({RVALUE}) }
#enddef
#define VARIABLE_EVAL_CONDITIONAL VAR_ID COND
[set_conditional_variable]
name={VAR_ID}
[condition]
{COND}
[/condition]
[/set_conditional_variable]
#enddef
#define VARIABLE_LEXICAL_EQUALS VAR_ID RVALUE
[variable]
name={VAR_ID}
equals={RVALUE}
[/variable]
#enddef
#define VARIABLE_LEXICAL_NOT_EQUALS VAR_ID RVALUE
[variable]
name={VAR_ID}
not_equals={RVALUE}
[/variable]
#enddef
# Requires Wesnoth 1.3.10
#define VARIABLE_LEXICAL_CONTAINS VAR_ID RVALUE
[variable]
name={VAR_ID}
contains={RVALUE}
[/variable]
#enddef
# Requires Wesnoth 1.3.2
#define VARIABLE_BOOLEAN_EQUALS VAR_ID RVALUE
[variable]
name={VAR_ID}
boolean_equals={RVALUE}
[/variable]
#enddef
# Requires Wesnoth 1.5.0+svn
#define VARIABLE_BOOLEAN_NOT_EQUALS VAR_ID RVALUE
[variable]
name={VAR_ID}
boolean_not_equals={RVALUE}
[/variable]
#enddef
#define BREAK VAR
# Macro to break out of a FOREACH loop.
# NOTE: the number used here is meant to be greater than or equa
# to game_config::max_loop!
{VARIABLE {VAR} 99999}
#enddef
# wmllint: unbalanced-on
# wmlindent: start ignoring
#define REVERSE_FOREACH ARRAY_VALUE VAR
# Macro to begin a WML clause that iterates over an array in reverse.
{VARIABLE {VAR} "$(${ARRAY_VALUE}.length - 1)"}
[while]
[variable]
name={VAR}
greater_than_equal_to=0
[/variable]
[do]
#enddef
#define REVERSE_NEXT VAR
# Macro to end a WML clause that iterates over an array in reverse.
[set_variable]
name={VAR}
sub=1
[/set_variable]
[/do]
[/while]
{CLEAR_VARIABLE {VAR}}
#enddef
# wmlindent: stop ignoring
#define REVERSE_BREAK VAR
# Macro to break out of a REVERSE_FOREACH loop.
{VARIABLE {VAR} -1}
#enddef
# wmlindent: start ignoring
#ifver WESNOTH_VERSION > 1.13.1
#define FOR VAR INITIAL LAST
[for]
variable={VAR}
start,end={INITIAL},{LAST}
[do]
#enddef
# wmlxgettext: [/do]
# wmlxgettext: [/for]
#else
#define FOR VAR INITIAL LAST
{VARIABLE {VAR} {INITIAL} }
[while]
[variable]
name={VAR}
numerical_not_equals="$(1 + "+{LAST}+")"
[/variable]
[do]
#enddef
#endif
# wmlindent: stop ignoring
# wmlxgettext: [/do]
# wmlxgettext: [/while]
# wmllint: unbalanced-off
# wmlindent: opener "{REVERSE_FOREACH "
# wmlindent: opener "{FOR "
# wmlindent: closer "{REVERSE_NEXT "
#
# ConditionalWML that always yields a true value.
#
#define TRUE
[true][/true]
#enddef
#
# ConditionalWML that always yields a false value.
#
#define FALSE
[false][/false]
#enddef
# NOTE: there's apparently a problem with subnamespaces creating an
# empty [variables] node that causes crashes or memory corruption
# when writing or reading variables in some systems; this is why
# we use "Project_Y_After_the_Storm" as namespace instead of
# "Project_Y.After_the_Storm" here.
#define ATS_GLOBAL_VAR_NAMESPACE
namespace="Project_Y_After_the_Storm"
#enddef
#define SET_GLOBAL TO_VAR_ID FROM_VAR_ID
[set_global_variable]
{ATS_GLOBAL_VAR_NAMESPACE}
to_global={TO_VAR_ID}
from_local={FROM_VAR_ID}
immediate=yes
[/set_global_variable]
#enddef
#define GET_GLOBAL FROM_VAR_ID TO_VAR_ID
[get_global_variable]
{ATS_GLOBAL_VAR_NAMESPACE}
from_global={FROM_VAR_ID}
to_local={TO_VAR_ID}
[/get_global_variable]
#enddef
#define CLEAR_GLOBAL VAR_ID
[clear_global_variable]
{ATS_GLOBAL_VAR_NAMESPACE}
global={VAR_ID}
immediate=yes
[/clear_global_variable]
#enddef
# kate: indent-mode normal; encoding utf-8; space-indent on;