mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 08:11:19 +00:00
better code logic for previous commit
This commit is contained in:
parent
9301736078
commit
53d3f7f49f
@ -470,10 +470,12 @@ function wml_actions.modify_unit(cfg)
|
||||
end
|
||||
end
|
||||
|
||||
local function handle_unit(cfg, unit_num)
|
||||
local filter = helper.get_child(cfg, "filter") or helper.wml_error "[modify_unit] missing required [filter] tag"
|
||||
local cfg = helper.parsed(cfg)
|
||||
local type = cfg.type; cfg.type = nil
|
||||
local function handle_unit(unit_num)
|
||||
local children_handled = {}
|
||||
local unit_path = string.format("%s[%u]", unit_variable, unit_num)
|
||||
local type = cfg.type; cfg.type = nil
|
||||
handle_attributes(cfg, unit_path)
|
||||
|
||||
for current_index, current_table in ipairs(cfg) do
|
||||
@ -501,14 +503,11 @@ function wml_actions.modify_unit(cfg)
|
||||
wml_actions.unstore_unit { variable = unit_path }
|
||||
end
|
||||
|
||||
local filter = helper.get_child(cfg, "filter") or helper.wml_error "[modify_unit] missing required [filter] tag"
|
||||
local cfg = helper.parsed(cfg)
|
||||
|
||||
wml_actions.store_unit { {"filter", filter}, variable = unit_variable, kill = true }
|
||||
local max_index = wesnoth.get_variable(unit_variable .. ".length") - 1
|
||||
|
||||
for current_unit = 0, max_index do
|
||||
handle_unit(cfg, current_unit)
|
||||
handle_unit(current_unit)
|
||||
end
|
||||
|
||||
wesnoth.set_variable(unit_variable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user