Move helper.find_attack -> wesnoth.units.find_attack
This commit is contained in:
parent
d5c1c9734f
commit
11a57e0fa7
4 changed files with 11 additions and 10 deletions
|
@ -569,6 +569,12 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
|
|||
end
|
||||
end
|
||||
|
||||
function wesnoth.units.find_attack(unit, filter)
|
||||
for i, atk in ipairs(unit.attacks) do
|
||||
if atk:matches(filter) then return atk end
|
||||
end
|
||||
end
|
||||
|
||||
-- gets map and recalllist units.
|
||||
function wesnoth.units.find(filter)
|
||||
local res = wesnoth.units.find_on_map(filter)
|
||||
|
|
|
@ -201,12 +201,6 @@ function helper.shuffle( t, random_func )
|
|||
end
|
||||
end
|
||||
|
||||
function helper.find_attack(unit, filter)
|
||||
for i, atk in ipairs(unit.attacks) do
|
||||
if atk:matches(filter) then return atk end
|
||||
end
|
||||
end
|
||||
|
||||
-- Compatibility and deprecations
|
||||
helper.distance_between = wesnoth.deprecate_api('helper.distance_between', 'wesnoth.map.distance_between', 1, nil, wesnoth.map.distance_between)
|
||||
helper.get_child = wesnoth.deprecate_api('helper.get_child', 'wml.get_child', 1, nil, wml.get_child)
|
||||
|
@ -221,6 +215,7 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
|
|||
helper.wml_error = wesnoth.deprecate_api('helper.wml_error', 'wml.error', 1, nil, wml.error)
|
||||
helper.move_unit_fake = wesnoth.deprecate_api('helper.move_unit_fake', 'wesnoth.interface.move_unit_fake', 1, nil, wesnoth.interface.move_unit_fake)
|
||||
helper.modify_unit = wesnoth.deprecate_api('helper.modify_unit', 'wesnoth.units.modify', 1, nil, wesnoth.units.modify)
|
||||
helper.find_attack = wesnoth.deprecate_api('helper.find_attack', 'wesnoth.units.find_attack', 1, nil, wesnoth.units.find_attack)
|
||||
end
|
||||
helper.literal = wesnoth.deprecate_api('helper.literal', 'wml.literal', 1, nil, wml.literal)
|
||||
helper.parsed = wesnoth.deprecate_api('helper.parsed', 'wml.parsed', 1, nil, wml.parsed)
|
||||
|
|
|
@ -38,11 +38,11 @@ local function add_animation(anim, cfg)
|
|||
primary = wesnoth.create_weapon(primary)
|
||||
end
|
||||
if secondary then
|
||||
secondary = helper.find_attack(unit, secondary)
|
||||
secondary = unit:find_attack(secondary)
|
||||
end
|
||||
else
|
||||
if primary then
|
||||
primary = helper.find_attack(unit, primary)
|
||||
primary = unit:find_attack(primary)
|
||||
end
|
||||
if secondary then
|
||||
secondary = wesnoth.create_weapon(secondary)
|
||||
|
|
|
@ -52,7 +52,7 @@ function wesnoth.wml_actions.kill(cfg)
|
|||
-- In the victory animation, this is simply swapped.
|
||||
if primary then
|
||||
if secondary_unit then
|
||||
primary = helper.find_attack(secondary_unit, primary)
|
||||
primary = secondary_unit:find_attack(primary)
|
||||
else
|
||||
primary = wesnoth.create_weapon(primary)
|
||||
end
|
||||
|
@ -60,7 +60,7 @@ function wesnoth.wml_actions.kill(cfg)
|
|||
end
|
||||
if secondary then
|
||||
if primary then
|
||||
secondary = helper.find_attack(unit, secondary)
|
||||
secondary = unit:find_attack(secondary)
|
||||
else
|
||||
secondary = wesnoth.create_weapon(secondary)
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue