Fix [for] not working for decreasing ranges
This commit is contained in:
parent
c0384520ad
commit
281f952a08
1 changed files with 8 additions and 1 deletions
|
@ -364,7 +364,14 @@ wesnoth.wml_actions["for"] = function(cfg)
|
|||
local i_var = cfg.variable or "i"
|
||||
local save_i = utils.start_var_scope(i_var)
|
||||
wesnoth.set_variable(i_var, first)
|
||||
while wesnoth.get_variable(i_var) <= last do
|
||||
local function loop_condition()
|
||||
if first < last then
|
||||
return wesnoth.get_variable(i_var) <= last
|
||||
else
|
||||
return wesnoth.get_variable(i_var) >= last
|
||||
end
|
||||
end
|
||||
while loop_condition() do
|
||||
for do_child in helper.child_range( cfg, "do" ) do
|
||||
local action = utils.handle_event_commands(do_child, "loop")
|
||||
if action == "break" then
|
||||
|
|
Loading…
Add table
Reference in a new issue