Quantcast
Channel: The Battle for Wesnoth Forums
Viewing all articles
Browse latest Browse all 1943

WML Workshop • Enter array argument to macro

$
0
0
Hello! I have macro called spawner. It spawns by default walking corpse at a given x,y coordinate and the last argument is an array of turns to tell when should spawn. My code looks like that:

Code:

#define SPAWNER X Y TURNS    #arg CHILDS    ("Walking Corpse")#endarg    #arg SIDE    2#endarg    #debug purpose    [message]        message={TURNS}    [/message]    [for]        array={TURNS}        [do]            [event]                name=turn {TURNS}[$i]                                {RANDOM {CHILDS}}                {NOTRAIT_UNIT {SIDE} $random {X} {Y}}                {CLEAR_VARIABLE random}            [/event]        [/do]    [/for]#enddef
In use it looks like that:

Code:

{SPAWNER 1 1 (1, 6, 10, 13)}
However the logged message shows that TURNS is 1,6,10,13 and I get the following lua error:

Code:

20241128 17:08:33 error engine: Formula in WML string cannot be evaluated due to Could not parse expression--> "20241128 17:08:33 error scripting/lua: lua/wml-flow.lua:107: attempt to compare number with stringstack traceback:lua/wml-flow.lua:107: in local 'cmd'lua/wml-utils.lua:145: in field 'handle_event_commands'lua/wml-flow.lua:5: in function <lua/wml-flow.lua:4>[C]: in ?
I understand that (1, 6, 10, 13) can't be parsed into an array, but how can I resolve this? Is there any lua function that can split that string and later I can use that array?

Statistics: Posted by Samaximus — Today, 4:44 pm



Viewing all articles
Browse latest Browse all 1943

Latest Images

Trending Articles



Latest Images