mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-23 19:28:15 +00:00
Lua: Replace uses of deprecated (moved) sides functions
This commit is contained in:
parent
930e39422a
commit
3734bce276
@ -1171,7 +1171,7 @@ function ai_helper.get_attackable_enemies(filter, side, cfg)
|
||||
local enemies = {}
|
||||
local all_units = wesnoth.units.find_on_map()
|
||||
for _,unit in ipairs(all_units) do
|
||||
if wesnoth.is_enemy(side, unit.side)
|
||||
if wesnoth.sides.is_enemy(side, unit.side)
|
||||
and (not unit.status.petrified)
|
||||
and unit:matches(filter_plus_vision)
|
||||
then
|
||||
@ -1195,7 +1195,7 @@ function ai_helper.is_attackable_enemy(unit, side, cfg)
|
||||
local viewing_side = cfg and cfg.viewing_side or side
|
||||
|
||||
if (not unit)
|
||||
or (not wesnoth.is_enemy(side, unit.side))
|
||||
or (not wesnoth.sides.is_enemy(side, unit.side))
|
||||
or unit.status.petrified
|
||||
or (not ai_helper.is_visible_unit(viewing_side, unit))
|
||||
then
|
||||
|
@ -65,7 +65,7 @@ function ca_grab_villages:evaluation(cfg, data, filter_own)
|
||||
if (not owner) then
|
||||
village_rating = village_rating + 10000
|
||||
else
|
||||
if wesnoth.is_enemy(owner, wesnoth.current.side) then village_rating = village_rating + 20000 end
|
||||
if wesnoth.sides.is_enemy(owner, wesnoth.current.side) then village_rating = village_rating + 20000 end
|
||||
end
|
||||
|
||||
local village_closest_enemy, enemy_distance_from_village = AH.get_closest_enemy(v)
|
||||
|
@ -304,7 +304,7 @@ return {
|
||||
-- positive only because it is used to estimate the number of enemy units that could appear
|
||||
-- and negative numbers shouldn't subtract from the number of units on the map
|
||||
local gold = 0
|
||||
local sides = wesnoth.get_sides(side_filter)
|
||||
local sides = wesnoth.sides.find(side_filter)
|
||||
for i,s in ipairs(sides) do
|
||||
if s.gold > 0 then
|
||||
gold = gold + s.gold
|
||||
@ -410,7 +410,7 @@ return {
|
||||
add_unit_type(unit.type)
|
||||
end
|
||||
-- Collect all possible enemy recruits and count them as virtual enemies
|
||||
local enemy_sides = wesnoth.get_sides({
|
||||
local enemy_sides = wesnoth.sides.find({
|
||||
{ "enemy_of", {side = wesnoth.current.side} },
|
||||
{ "has_unit", { canrecruit = true }} })
|
||||
for i, side in ipairs(enemy_sides) do
|
||||
@ -680,7 +680,7 @@ return {
|
||||
-- If no enemy is on the map, then we first use closest enemy start hex,
|
||||
-- and if that does not exist either, a location mirrored w.r.t the center of the map
|
||||
if not enemy_location then
|
||||
local enemy_sides = wesnoth.get_sides({ { "enemy_of", {side = wesnoth.current.side} } })
|
||||
local enemy_sides = wesnoth.sides.find({ { "enemy_of", {side = wesnoth.current.side} } })
|
||||
local min_dist = math.huge
|
||||
for _, side in ipairs(enemy_sides) do
|
||||
local enemy_start_hex = wesnoth.special_locations[side.side]
|
||||
@ -909,7 +909,7 @@ return {
|
||||
local villages = {}
|
||||
for _,v in ipairs(all_villages) do
|
||||
local owner = wesnoth.get_village_owner(v[1], v[2])
|
||||
if ((not owner) or wesnoth.is_enemy(owner, wesnoth.current.side))
|
||||
if ((not owner) or wesnoth.sides.is_enemy(owner, wesnoth.current.side))
|
||||
and (not exclude_map:get(v[1], v[2]))
|
||||
then
|
||||
for _,loc in ipairs(data.castle.locs) do
|
||||
|
@ -99,7 +99,7 @@ function ca_coward:execution(cfg)
|
||||
local max_rating, best_target = - math.huge
|
||||
for xa,ya in H.adjacent_tiles(coward.x, coward.y) do
|
||||
local target = wesnoth.units.get(xa, ya)
|
||||
if target and wesnoth.is_enemy(coward.side, target.side) then
|
||||
if target and wesnoth.sides.is_enemy(coward.side, target.side) then
|
||||
local rating = - target.hitpoints
|
||||
|
||||
if (rating > max_rating) then
|
||||
|
@ -39,7 +39,7 @@ function ca_fast_move:execution(cfg)
|
||||
table.remove(villages, i)
|
||||
else
|
||||
local owner = wesnoth.get_village_owner(villages[i][1], villages[i][2])
|
||||
if owner and (not wesnoth.is_enemy(owner, wesnoth.current.side)) then
|
||||
if owner and (not wesnoth.sides.is_enemy(owner, wesnoth.current.side)) then
|
||||
table.remove(villages, i)
|
||||
elseif (not leader) and (not owner) then
|
||||
table.remove(villages, i)
|
||||
|
@ -159,7 +159,7 @@ function ca_goto:execution(cfg, data)
|
||||
local enemy_at_goal
|
||||
if cfg.ignore_enemy_at_goal then
|
||||
enemy_at_goal = wesnoth.units.get(loc[1], loc[2])
|
||||
if enemy_at_goal and wesnoth.is_enemy(wesnoth.current.side, enemy_at_goal.side) then
|
||||
if enemy_at_goal and wesnoth.sides.is_enemy(wesnoth.current.side, enemy_at_goal.side) then
|
||||
enemy_at_goal:extract()
|
||||
else
|
||||
enemy_at_goal = nil
|
||||
|
@ -9,9 +9,9 @@ function ca_healer_initialize:evaluation()
|
||||
end
|
||||
|
||||
function ca_healer_initialize:execution(cfg, data)
|
||||
wesnoth.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]")
|
||||
wesnoth.sides.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]")
|
||||
|
||||
wesnoth.add_ai_component(wesnoth.current.side, "aspect[attacks].facet",
|
||||
wesnoth.sides.add_ai_component(wesnoth.current.side, "aspect[attacks].facet",
|
||||
{
|
||||
name = "ai_default_rca::aspect_attacks",
|
||||
id = "no_healers_attack",
|
||||
|
@ -9,7 +9,7 @@ function ca_healer_may_attack:evaluation()
|
||||
end
|
||||
|
||||
function ca_healer_may_attack:execution(cfg, data)
|
||||
wesnoth.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]")
|
||||
wesnoth.sides.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[no_healers_attack]")
|
||||
|
||||
-- Once combat (by other units) is done, set the healer move score so that it
|
||||
-- now happens before combat (of the healers which were so far excluded from combat)
|
||||
|
@ -39,15 +39,15 @@ return {
|
||||
end
|
||||
|
||||
-- Always delete the attacks aspect first, so that we do not end up with 100 copies of the facet
|
||||
wesnoth.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[limited_attack]")
|
||||
wesnoth.sides.delete_ai_component(wesnoth.current.side, "aspect[attacks].facet[limited_attack]")
|
||||
|
||||
-- Also delete aggression, caution - for the same reason
|
||||
wesnoth.delete_ai_component(wesnoth.current.side, "aspect[aggression].facet[*]")
|
||||
wesnoth.delete_ai_component(wesnoth.current.side, "aspect[caution].facet[*]")
|
||||
wesnoth.sides.delete_ai_component(wesnoth.current.side, "aspect[aggression].facet[*]")
|
||||
wesnoth.sides.delete_ai_component(wesnoth.current.side, "aspect[caution].facet[*]")
|
||||
|
||||
-- If the target can be attacked, set the attacks aspect accordingly
|
||||
if attack_locs[1] then
|
||||
wesnoth.add_ai_component(wesnoth.current.side, "aspect[attacks].facet",
|
||||
wesnoth.sides.add_ai_component(wesnoth.current.side, "aspect[attacks].facet",
|
||||
{
|
||||
name = "ai_default_rca::aspect_attacks",
|
||||
id = "limited_attack",
|
||||
@ -58,7 +58,7 @@ return {
|
||||
|
||||
-- We also want to set aggression=1 and caution=0,
|
||||
-- otherwise there could be turns on which nothing happens
|
||||
wesnoth.append_ai(wesnoth.current.side, { aggression = 1, caution = 0 })
|
||||
wesnoth.sides.append_ai(wesnoth.current.side, { aggression = 1, caution = 0 })
|
||||
end
|
||||
|
||||
return 0
|
||||
|
@ -15,7 +15,7 @@ function wesnoth.micro_ais.fast_ai(cfg)
|
||||
-- Also need to delete/add some default CAs
|
||||
if (cfg.action == 'delete') then
|
||||
-- This can be done independently of whether these were removed earlier
|
||||
wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
wesnoth.sides.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
{
|
||||
id="combat",
|
||||
engine="cpp",
|
||||
@ -25,7 +25,7 @@ function wesnoth.micro_ais.fast_ai(cfg)
|
||||
}
|
||||
)
|
||||
|
||||
wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
wesnoth.sides.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
{
|
||||
id="villages",
|
||||
engine="cpp",
|
||||
@ -35,7 +35,7 @@ function wesnoth.micro_ais.fast_ai(cfg)
|
||||
}
|
||||
)
|
||||
|
||||
wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
wesnoth.sides.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
{
|
||||
id="retreat",
|
||||
engine="cpp",
|
||||
@ -45,7 +45,7 @@ function wesnoth.micro_ais.fast_ai(cfg)
|
||||
}
|
||||
)
|
||||
|
||||
wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
wesnoth.sides.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
{
|
||||
id="move_to_targets",
|
||||
engine="cpp",
|
||||
@ -56,8 +56,8 @@ function wesnoth.micro_ais.fast_ai(cfg)
|
||||
)
|
||||
else
|
||||
if (not cfg.skip_combat_ca) then
|
||||
wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[high_xp_attack]")
|
||||
wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[combat]")
|
||||
wesnoth.sides.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[high_xp_attack]")
|
||||
wesnoth.sides.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[combat]")
|
||||
else
|
||||
for i,parm in ipairs(CA_parms) do
|
||||
if (parm.ca_id == 'combat') or (parm.ca_id == 'combat_leader') then
|
||||
@ -67,11 +67,11 @@ function wesnoth.micro_ais.fast_ai(cfg)
|
||||
end
|
||||
|
||||
if (not cfg.skip_move_ca) then
|
||||
wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[villages]")
|
||||
wesnoth.sides.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[villages]")
|
||||
|
||||
wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[retreat]")
|
||||
wesnoth.sides.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[retreat]")
|
||||
|
||||
wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_to_targets]")
|
||||
wesnoth.sides.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_to_targets]")
|
||||
else
|
||||
for i,parm in ipairs(CA_parms) do
|
||||
if (parm.ca_id == 'move') then
|
||||
|
@ -23,7 +23,7 @@ function wesnoth.micro_ais.protect_unit(cfg)
|
||||
-- Optional key disable_move_leader_to_keep: needs to be dealt with
|
||||
-- separately as it affects a default CA
|
||||
if cfg.disable_move_leader_to_keep then
|
||||
wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_leader_to_keep]")
|
||||
wesnoth.sides.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[move_leader_to_keep]")
|
||||
end
|
||||
|
||||
-- attacks aspects also needs to be set separately
|
||||
@ -47,7 +47,7 @@ function wesnoth.micro_ais.protect_unit(cfg)
|
||||
MAIH.delete_aspects(cfg.side, aspect_parms)
|
||||
-- We also need to add the move_leader_to_keep CA back in
|
||||
-- This works even if it was not removed, it simply overwrites the existing CA
|
||||
wesnoth.add_ai_component(side, "stage[main_loop].candidate_action",
|
||||
wesnoth.side.add_ai_component(side, "stage[main_loop].candidate_action",
|
||||
{
|
||||
id="move_leader_to_keep",
|
||||
engine="cpp",
|
||||
|
@ -1,11 +1,11 @@
|
||||
local function handle_default_recruitment(cfg)
|
||||
-- Also need to delete/add the default recruitment CA
|
||||
if cfg.action == 'add' then
|
||||
wesnoth.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[recruitment]")
|
||||
wesnoth.sides.delete_ai_component(cfg.side, "stage[main_loop].candidate_action[recruitment]")
|
||||
elseif cfg.action == 'delete' then
|
||||
-- We need to add the recruitment CA back in
|
||||
-- This works even if it was not removed, it simply overwrites the existing CA
|
||||
wesnoth.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
wesnoth.sides.add_ai_component(cfg.side, "stage[main_loop].candidate_action",
|
||||
{
|
||||
id="recruitment",
|
||||
engine="cpp",
|
||||
|
@ -91,7 +91,7 @@ function micro_ai_helper.add_CAs(side, ca_id_core, CA_parms, CA_cfg)
|
||||
CA.location = parms.location
|
||||
table.insert(CA, T.args(CA_cfg))
|
||||
|
||||
wesnoth.add_ai_component(side, "stage[main_loop].candidate_action", CA)
|
||||
wesnoth.sides.add_ai_component(side, "stage[main_loop].candidate_action", CA)
|
||||
end
|
||||
end
|
||||
|
||||
@ -108,7 +108,7 @@ function micro_ai_helper.delete_CAs(side, ca_id_core, CA_parms)
|
||||
for _,parms in ipairs(CA_parms) do
|
||||
local ca_id = ca_id_core .. '_' .. parms.ca_id
|
||||
|
||||
wesnoth.delete_ai_component(side, "stage[main_loop].candidate_action[" .. ca_id .. "]")
|
||||
wesnoth.sides.delete_ai_component(side, "stage[main_loop].candidate_action[" .. ca_id .. "]")
|
||||
|
||||
-- Also need to delete variable stored in all units of the side, so that later MAIs can use these units
|
||||
local units = wesnoth.units.find_on_map { side = side }
|
||||
@ -140,7 +140,7 @@ function micro_ai_helper.add_aspects(side, aspect_parms)
|
||||
-- }
|
||||
|
||||
for _,parms in ipairs(aspect_parms) do
|
||||
wesnoth.add_ai_component(side, "aspect[" .. parms.aspect .. "].facet", parms.facet)
|
||||
wesnoth.sides.add_ai_component(side, "aspect[" .. parms.aspect .. "].facet", parms.facet)
|
||||
end
|
||||
end
|
||||
|
||||
@ -151,7 +151,7 @@ function micro_ai_helper.delete_aspects(side, aspect_parms)
|
||||
-- aspect_parms.aspect_id field is needed
|
||||
|
||||
for _,parms in ipairs(aspect_parms) do
|
||||
wesnoth.delete_ai_component(side, "aspect[attacks].facet[" .. parms.facet.id .. "]")
|
||||
wesnoth.sides.delete_ai_component(side, "aspect[attacks].facet[" .. parms.facet.id .. "]")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -419,12 +419,12 @@
|
||||
saved_orc_leader.side = 2
|
||||
saved_orc_leader.facing = "se"
|
||||
|
||||
local loc = wesnoth.get_starting_location(2)
|
||||
local loc = wesnoth.sides[2].starting_location
|
||||
wesnoth.units.to_map(saved_orc_leader, loc[1], loc[2])
|
||||
|
||||
wml.variables.orc_leader_store = nil
|
||||
else
|
||||
local loc = wesnoth.get_starting_location(2)
|
||||
local loc = wesnoth.sides[1].starting_location
|
||||
wesnoth.units.to_map(fallback_orc_leader, loc[1], loc[2])
|
||||
end
|
||||
>>
|
||||
|
@ -7,7 +7,7 @@ local recruitedType
|
||||
local recruitCost
|
||||
|
||||
local zombies = V.zombies
|
||||
local sides = wesnoth.get_sides()
|
||||
local sides = wesnoth.sides.find()
|
||||
|
||||
local unit_row = T.row {
|
||||
T.column { grow_factor=0, border="right", border_size=5, horizontal_alignment = "left", T.image { id = "unit_sprite" } },
|
||||
|
@ -10,7 +10,7 @@ function helper.get_sides(cfg)
|
||||
local i = s.i
|
||||
while i < #wesnoth.sides do
|
||||
i = i + 1
|
||||
if wesnoth.match_side(i, cfg) then
|
||||
if wesnoth.sides.matches(i, cfg) then
|
||||
s.i = i
|
||||
return wesnoth.sides[i], i
|
||||
end
|
||||
|
@ -58,7 +58,7 @@ function wml_actions.sync_variable(cfg)
|
||||
end
|
||||
|
||||
function wml_actions.chat(cfg)
|
||||
local side_list = wesnoth.get_sides(cfg)
|
||||
local side_list = wesnoth.sides.find(cfg)
|
||||
local speaker = tostring(cfg.speaker or "WML")
|
||||
local message = tostring(cfg.message or
|
||||
helper.wml_error "[chat] missing required message= attribute."
|
||||
@ -74,7 +74,7 @@ function wml_actions.chat(cfg)
|
||||
local observable = cfg.observable ~= false
|
||||
|
||||
if observable then
|
||||
local all_sides = wesnoth.get_sides()
|
||||
local all_sides = wesnoth.sides.find()
|
||||
local has_human_side = false
|
||||
for index, side in ipairs(all_sides) do
|
||||
if side.controller == "human" and side.is_local then
|
||||
@ -92,7 +92,7 @@ end
|
||||
function wml_actions.gold(cfg)
|
||||
local amount = tonumber(cfg.amount) or
|
||||
helper.wml_error "[gold] missing required amount= attribute."
|
||||
local sides = wesnoth.get_sides(cfg)
|
||||
local sides = wesnoth.sides.find(cfg)
|
||||
for index, team in ipairs(sides) do
|
||||
team.gold = team.gold + amount
|
||||
end
|
||||
@ -101,7 +101,7 @@ end
|
||||
--note: This tag can't easily (without deprecation) be extended to store an array,
|
||||
--since the gold is stored in a scalar variable, not a container (there's no key).
|
||||
function wml_actions.store_gold(cfg)
|
||||
local team = wesnoth.get_sides(cfg)[1]
|
||||
local team = wesnoth.sides.find(cfg)[1]
|
||||
if team then wml.variables[cfg.variable or "gold"] = team.gold end
|
||||
end
|
||||
|
||||
@ -157,7 +157,7 @@ end
|
||||
|
||||
function wml_actions.allow_recruit(cfg)
|
||||
local unit_types = cfg.type or helper.wml_error("[allow_recruit] missing required type= attribute")
|
||||
for index, team in ipairs(wesnoth.get_sides(cfg)) do
|
||||
for index, team in ipairs(wesnoth.sides.find(cfg)) do
|
||||
local v = team.recruit
|
||||
for type in utils.split(unit_types) do
|
||||
table.insert(v, type)
|
||||
@ -181,7 +181,7 @@ end
|
||||
|
||||
function wml_actions.disallow_recruit(cfg)
|
||||
local unit_types = cfg.type
|
||||
for index, team in ipairs(wesnoth.get_sides(cfg)) do
|
||||
for index, team in ipairs(wesnoth.sides.find(cfg)) do
|
||||
if unit_types then
|
||||
local v = team.recruit
|
||||
for w in utils.split(unit_types) do
|
||||
@ -217,7 +217,7 @@ end
|
||||
|
||||
function wml_actions.set_recruit(cfg)
|
||||
local recruit = cfg.recruit or helper.wml_error("[set_recruit] missing required recruit= attribute")
|
||||
for index, team in ipairs(wesnoth.get_sides(cfg)) do
|
||||
for index, team in ipairs(wesnoth.sides.find(cfg)) do
|
||||
local v = {}
|
||||
for w in utils.split(recruit) do
|
||||
table.insert(v, w)
|
||||
@ -505,7 +505,7 @@ function wml_actions.capture_village(cfg)
|
||||
if side then side = tonumber(side) or helper.wml_error("invalid side in [capture_village]") end
|
||||
if filter_side then
|
||||
if side then helper.wml_error("duplicate side information in [capture_village]") end
|
||||
side = wesnoth.get_sides(filter_side)[1]
|
||||
side = wesnoth.sides.find(filter_side)[1]
|
||||
if side then side = side.side end
|
||||
end
|
||||
local locs = wesnoth.get_locations(cfg)
|
||||
@ -654,8 +654,8 @@ end
|
||||
|
||||
function wml_actions.store_starting_location(cfg)
|
||||
local writer = utils.vwriter.init(cfg, "location")
|
||||
for _, side in ipairs(wesnoth.get_sides(cfg)) do
|
||||
local loc = wesnoth.get_starting_location(side.side)
|
||||
for _, side in ipairs(wesnoth.sides.find(cfg)) do
|
||||
local loc = side.starting_location
|
||||
if loc then
|
||||
local terrain = wesnoth.get_terrain(loc[1], loc[2])
|
||||
local result = { x = loc[1], y = loc[2], terrain = terrain }
|
||||
@ -916,7 +916,7 @@ end
|
||||
local function parse_fog_cfg(cfg)
|
||||
-- Side filter
|
||||
local ssf = wml.get_child(cfg, "filter_side")
|
||||
local sides = wesnoth.get_sides(ssf or {})
|
||||
local sides = wesnoth.sides.find(ssf or {})
|
||||
-- Location filter
|
||||
local locs = wesnoth.get_locations(cfg)
|
||||
return locs, sides
|
||||
|
@ -58,9 +58,9 @@ function utils.get_sides(cfg, key_name, filter_name)
|
||||
if cfg[key_name] then
|
||||
wesnoth.log('warn', "ignoring duplicate side filter information (inline side=)")
|
||||
end
|
||||
return wesnoth.get_sides(filter)
|
||||
return wesnoth.sides.findd(filter)
|
||||
else
|
||||
return wesnoth.get_sides{side = cfg[key_name]}
|
||||
return wesnoth.sides.findd{side = cfg[key_name]}
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -168,7 +168,7 @@ function wml_actions.harm_unit(cfg)
|
||||
end
|
||||
|
||||
if experience ~= false and harmer and harmer.valid
|
||||
and wesnoth.is_enemy( unit_to_harm.side, harmer.side )
|
||||
and wesnoth.sides.is_enemy( unit_to_harm.side, harmer.side )
|
||||
then
|
||||
if kill ~= false and unit_to_harm.hitpoints <= 0 then
|
||||
harmer.experience = harmer.experience + calc_xp( unit_to_harm.__cfg.level )
|
||||
|
@ -15,11 +15,11 @@ function wesnoth.wml_actions.modify_ai(cfg)
|
||||
end
|
||||
component = wml.parsed(component)
|
||||
end
|
||||
for i = 1, #sides do
|
||||
for _, side in ipairs(sides) do
|
||||
if cfg.action == "add" then
|
||||
wesnoth.add_ai_component(sides[i].side, cfg.path, component)
|
||||
side:add_ai_component(cfg.path, component)
|
||||
elseif cfg.action == "delete" or cfg.action == "try_delete" then
|
||||
wesnoth.delete_ai_component(sides[i].side, cfg.path)
|
||||
side:delete_ai_component(cfg.path)
|
||||
elseif cfg.action == "change" then
|
||||
local id_start = final + 2
|
||||
local id_final = string.len(cfg.path) - 1
|
||||
@ -29,7 +29,7 @@ function wesnoth.wml_actions.modify_ai(cfg)
|
||||
elseif not component.id and not id:match("[0-9]+") then
|
||||
component.id = id
|
||||
end
|
||||
wesnoth.change_ai_component(sides[i].side, cfg.path, component)
|
||||
side:change_ai_component(cfg.path, component)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -49,7 +49,7 @@ function wesnoth.wml_actions.modify_side(cfg)
|
||||
side.hidden = cfg.hidden
|
||||
end
|
||||
if cfg.color or cfg.flag then
|
||||
wesnoth.set_side_id(side.side, cfg.flag, cfg.color)
|
||||
side:set_id(cfg.flag, cfg.color)
|
||||
end
|
||||
if cfg.flag_icon then
|
||||
side.flag_icon = cfg.flag_icon
|
||||
@ -109,13 +109,13 @@ function wesnoth.wml_actions.modify_side(cfg)
|
||||
end
|
||||
|
||||
if cfg.switch_ai then
|
||||
wesnoth.switch_ai(side.side, cfg.switch_ai)
|
||||
side:switch_ai(cfg.switch_ai)
|
||||
end
|
||||
if #ai > 0 then
|
||||
if replace_ai then
|
||||
wesnoth.switch_ai(side.side, ai)
|
||||
side:switch_ai(ai)
|
||||
else
|
||||
wesnoth.append_ai(side.side, ai)
|
||||
side:append_ai(ai)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -185,7 +185,7 @@ function wml_actions.objectives(cfg)
|
||||
cfg = wml.parsed(cfg)
|
||||
end
|
||||
|
||||
local sides_cfg = wesnoth.get_sides(cfg)
|
||||
local sides_cfg = wesnoth.sides.find(cfg)
|
||||
local silent = cfg.silent
|
||||
|
||||
local objectives = generate_objectives(cfg)
|
||||
@ -226,7 +226,7 @@ function wml_actions.show_objectives(cfg)
|
||||
team.objectives_changed = true
|
||||
end
|
||||
end
|
||||
local sides = wesnoth.get_sides(cfg)
|
||||
local sides = wesnoth.sides.find(cfg)
|
||||
if #sides == 0 then
|
||||
local_show_objectives(wesnoth.sides)
|
||||
else
|
||||
|
@ -1,3 +1,3 @@
|
||||
for i, side in ipairs(wesnoth.get_sides({})) do
|
||||
for i, side in ipairs(wesnoth.sides.find({})) do
|
||||
wml.variables["p" .. tostring(i) .. "_faction"] = side.faction
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
[event]
|
||||
name = prestart
|
||||
[lua]
|
||||
code = << local s = wesnoth.get_sides({})
|
||||
code = << local s = wesnoth.sides.find({})
|
||||
local result = (s[1].side == 1) and (s[2].side == 2)
|
||||
wml.variables["result"] = result >>
|
||||
[/lua]
|
||||
|
@ -3508,7 +3508,7 @@ static int intf_modify_ai_old(lua_State *L)
|
||||
config cfg;
|
||||
luaW_toconfig(L, 1, cfg);
|
||||
int side = cfg["side"];
|
||||
deprecated_message("wesnoth.modify_ai", DEP_LEVEL::PREEMPTIVE, {1, 15, 0}, "Use wesnoth.add_ai_component, wesnoth.delete_ai_component, or wesnoth.change_ai_component.");
|
||||
deprecated_message("wesnoth.modify_ai", DEP_LEVEL::PREEMPTIVE, {1, 15, 0}, "Use wesnoth.sides.add_ai_component, wesnoth.sides.delete_ai_component, or wesnoth.sides.change_ai_component.");
|
||||
ai::manager::get_singleton().modify_active_ai_for_side(side, cfg);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user