Lua: Update all mainline references to the helper module

This commit is contained in:
Celtic Minstrel 2021-07-04 17:07:53 -04:00 committed by Celtic Minstrel
parent 8b05449bbc
commit 4ec60b99d9
38 changed files with 42 additions and 79 deletions

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"
local F = wesnoth.require "functional"
local M = wesnoth.map
@ -598,7 +597,7 @@ function ai_helper.find_opposite_hex_adjacent(hex, center_hex)
-- y is slightly more tricky, because of the hexagonal shape, but there's a trick
-- that saves us from having to build in a lot of if statements
-- Among the adjacent hexes, it is the one with the correct x, and y _different_ from hex[2]
for xa,ya in H.adjacent_tiles(center_hex[1], center_hex[2]) do
for xa,ya in wesnoth.current.map:iter_adjacent(center_hex) do
if (xa == opp_x) and (ya ~= hex[2]) then return { xa, ya } end
end
@ -1201,7 +1200,7 @@ function ai_helper.get_attackable_enemies(filter, side, cfg)
local is_avoided = false
if cfg and cfg.avoid_map then
is_avoided = true
for xa,ya in H.adjacent_tiles(unit.x, unit.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(unit) do
if (not cfg.avoid_map:get(xa, ya)) then
is_avoided = false
break
@ -1905,7 +1904,7 @@ function ai_helper.find_path_with_avoid(unit, x, y, avoid_map, options)
if (not options.ignore_enemies) and (not unit:ability("skirmisher")) then
enemy_map:iter(function(x, y, level)
if (level > 0) then
for xa,ya in H.adjacent_tiles(x, y) do
for xa,ya in wesnoth.current.map:iter_adjacent(x, y) do
enemy_zoc_map:insert(xa, ya, level)
end
end
@ -2144,7 +2143,7 @@ function ai_helper.get_attacks(units, cfg)
local attack_hex_map = LS.create()
enemy_map:iter(function(e_x, e_y, i)
for xa,ya in H.adjacent_tiles(e_x, e_y) do
for xa,ya in wesnoth.current.map:iter_adjacent(e_x, e_y) do
-- If there's no unit of another side on this hex, include it
-- as possible attack location (this includes hexes occupied
-- by own units at this time)
@ -2359,7 +2358,7 @@ function ai_helper.get_attack_combos(units, enemy, cfg)
-- Find which units in @units can get to hexes next to the enemy
local attacks_dst_src = {}
local found_attacks = false
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
-- Make sure the hex is not occupied by unit that cannot move out of the way
local dst = xa * 1000 + ya

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "location_set"
local M = wesnoth.map
@ -815,7 +814,7 @@ function battle_calcs.attack_rating(attacker, defender, dst, cfg, cache)
damage = damage - 1.25 * wesnoth.terrain_types[map[dst]].healing
-- Equivalently, if attack is adjacent to an unoccupied healing location, that's bad
for xa,ya in H.adjacent_tiles(dst[1], dst[2]) do
for xa,ya in wesnoth.current.map:iter_adjacent(dst) do
local healing = wesnoth.terrain_types[map[{xa, ya}]].healing
if (healing > 0) and (not wesnoth.units.get(xa, ya)) then
damage = damage + 1.25 * healing
@ -1181,7 +1180,7 @@ function battle_calcs.get_attack_map_unit(unit, cfg)
for _,loc in ipairs(initial_reach) do
reach.units:insert(loc[1], loc[2], 1)
reach.hitpoints:insert(loc[1], loc[2], unit.hitpoints)
for xa,ya in H.adjacent_tiles(loc[1], loc[2]) do
for xa,ya in wesnoth.current.map:iter_adjacent(loc) do
reach.units:insert(xa, ya, 1)
reach.hitpoints:insert(xa, ya, unit.hitpoints)
end
@ -1467,7 +1466,7 @@ function battle_calcs.get_attack_combos_subset(units, enemy, cfg)
-- For units on other sides we always assume that they can move away
local blocked_hexes = LS.create()
if units[1] and (units[1].side == wesnoth.current.side) then
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
local unit_in_way = wesnoth.units.get(xa, ya)
if unit_in_way then
-- Units on the same side are blockers if they cannot move away
@ -1502,7 +1501,7 @@ function battle_calcs.get_attack_combos_subset(units, enemy, cfg)
local locs = {} -- attack locations for this unit
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
local loc = {} -- attack location information for this unit for this hex

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "location_set"
local M = wesnoth.map
@ -100,7 +99,7 @@ function ca_attack_highxp:evaluation(cfg, data, filter_own)
local target = attacks_aspect.enemy[target_info.ind_target]
local can_force_level = {}
local attack_hexes = LS.create()
for xa,ya in H.adjacent_tiles(target.x, target.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(target) do
if (not avoid_map:get(xa, ya)) then
local unit_in_way = wesnoth.units.get(xa, ya)

View file

@ -3,7 +3,6 @@
-- only kicks in when the AI would do nothing else. It prevents the AI from
-- being inactive on maps without enemy leaders and villages.
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local MTAE_unit, MTAE_destination
@ -41,7 +40,7 @@ function ca_move_to_any_enemy:evaluation(cfg, data, filter_own)
-- We only need to look at adjacent hexes. And we don't worry whether they
-- are occupied by other enemies. If that is the case, no path will be found,
-- but one of those enemies will later be found as potential target.
for xa,ya in H.adjacent_tiles(e.x, e.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(e) do
if (not avoid_map:get(xa, ya)) then
local path, cost = AH.find_path_with_avoid(u, xa, ya, avoid_map)
if (cost < best_cost) then

View file

@ -2,7 +2,6 @@
Functions to support the retreat of injured units
]=]
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local LS = wesnoth.require "location_set"
@ -121,7 +120,7 @@ function retreat_functions.get_healing_locations(possible_healers)
end
end
if heal_amount + cure > 0 then
for x, y in H.adjacent_tiles(u.x, u.y) do
for x, y in wesnoth.current.map:iter_adjacent(u) do
local old_values = healing_locs:get(x, y) or {0, 0}
local best_heal = math.max(old_values[0] or heal_amount)
local best_cure = math.max(old_values[1] or cure)

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "location_set"
@ -81,7 +80,7 @@ function ca_assassin_move:execution(cfg)
local unit_damage_map = LS.create()
for _,loc in ipairs(reach) do
unit_damage_map:insert(loc[1], loc[2], max_damage)
for xa,ya in H.adjacent_tiles(loc[1], loc[2]) do
for xa,ya in wesnoth.current.map:iter_adjacent(loc) do
unit_damage_map:insert(xa, ya, max_damage)
end
end
@ -119,7 +118,7 @@ function ca_assassin_move:execution(cfg)
end
if zoc_active then
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
enemy_rating_map:insert(xa, ya, (enemy_rating_map:get(xa, ya) or 0) + unit.max_moves)
end
end

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "location_set"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
@ -30,7 +29,7 @@ function ca_big_animals:execution(cfg)
local enemies_to_be_avoided = AH.get_attackable_enemies(avoid_tag)
for _,enemy in ipairs(enemies_to_be_avoided) do
avoid_map:insert(enemy.x, enemy.y)
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
avoid_map:insert(xa, ya)
end
end
@ -62,7 +61,7 @@ function ca_big_animals:execution(cfg)
-- Proximity to an enemy unit is a plus
local enemy_hp = 500
for xa,ya in H.adjacent_tiles(x, y) do
for xa,ya in wesnoth.current.map:iter_adjacent(x, y) do
local enemy = wesnoth.units.get(xa, ya)
if AH.is_attackable_enemy(enemy) then
if (enemy.hitpoints < enemy_hp) then enemy_hp = enemy.hitpoints end
@ -94,7 +93,7 @@ function ca_big_animals:execution(cfg)
-- Finally, if the unit ended up next to enemies, attack the weakest of those
local min_hp, target = math.huge
for xa,ya in H.adjacent_tiles(unit.x, unit.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(unit) do
local enemy = wesnoth.units.get(xa, ya)
if AH.is_attackable_enemy(enemy) then
if (enemy.hitpoints < min_hp) then

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
@ -87,7 +86,7 @@ local function bottleneck_create_positioning_map(max_value, data)
-- Only store those that are not in enemy territory.
local map = LS.create()
BD_def_map:iter(function(x, y, v)
for xa,ya in H.adjacent_tiles(x, y) do
for xa,ya in wesnoth.current.map:iter_adjacent(x, y) do
if BD_is_my_territory:get(xa, ya) then
local rating = BD_def_map:get(x, y) or 0
rating = rating + (map:get(xa, ya) or 0)
@ -136,7 +135,7 @@ local function bottleneck_get_rating(unit, x, y, has_leadership, is_healer, on_m
-- If leadership unit is injured -> prefer hexes next to healers
if (unit.hitpoints < unit.max_hitpoints) then
for xa,ya in H.adjacent_tiles(x, y) do
for xa,ya in wesnoth.current.map:iter_adjacent(x, y) do
local adjacent_unit = wesnoth.units.get(xa, ya)
if adjacent_unit and (adjacent_unit.usage == "healer") then
leadership_rating = leadership_rating + 100
@ -276,7 +275,7 @@ function ca_bottleneck_move:evaluation(cfg, data)
local healers = wesnoth.units.find_on_map { side = wesnoth.current.side, ability = "healing" }
BD_healing_map = LS.create()
for _,healer in ipairs(healers) do
for xa,ya in H.adjacent_tiles(healer.x, healer.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(healer) do
-- Cannot be on the line, and needs to be in own territory
if BD_is_my_territory:get(xa, ya) then
local min_dist = math.huge
@ -322,7 +321,7 @@ function ca_bottleneck_move:evaluation(cfg, data)
local enemies = AH.get_attackable_enemies()
local attacks = {}
for _,enemy in ipairs(enemies) do
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
if BD_is_my_territory:get(xa, ya) then
local unit_in_way = wesnoth.units.get(xa, ya)
if (not AH.is_visible_unit(wesnoth.current.side, unit_in_way)) then

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local F = wesnoth.require "functional"
@ -97,7 +96,7 @@ function ca_coward:execution(cfg)
-- If 'attack_if_trapped' is set, the coward attacks the weakest unit it ends up next to
if cfg.attack_if_trapped then
local max_rating, best_target = - math.huge
for xa,ya in H.adjacent_tiles(coward.x, coward.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(coward) do
local target = wesnoth.units.get(xa, ya)
if target and wesnoth.sides.is_enemy(coward.side, target.side) then
local rating = - target.hitpoints

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local FAU = wesnoth.require "ai/micro_ais/cas/ca_fast_attack_utils.lua"
local LS = wesnoth.require "location_set"
@ -111,7 +110,7 @@ function ca_fast_combat_leader:evaluation(cfg, data)
-- not units) on the AI leader
local leader_current_threat = 0
if cfg and cfg.threatened_leader_fights then
for xa,ya in H.adjacent_tiles(leader.x, leader.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(leader) do
local enemy_power = enemy_power_map:get(xa, ya) or 0
if (enemy_power > leader_current_threat) then
leader_current_threat = enemy_power
@ -130,7 +129,7 @@ function ca_fast_combat_leader:evaluation(cfg, data)
-- First check if the threat against the leader at this hex
-- is acceptable
local acceptable_attack = true
for xa,ya in H.adjacent_tiles(attack.dst.x, attack.dst.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(attack.dst) do
local enemy_power = enemy_power_map:get(xa, ya) or 0
local enemy_number = enemy_number_map:get(xa, ya) or 0

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local BC = wesnoth.require "ai/lua/battle_calcs.lua"
local LS = wesnoth.require "location_set"
@ -122,7 +121,7 @@ function ca_goto:execution(cfg, data)
enemy_map:insert(enemy.x, enemy.y, (enemy_map:get(enemy.x, enemy.y) or 0) + 1000)
end
for _,enemy in ipairs(live_enemies) do
for xa,ya in H.adjacent_tiles(enemy.x, enemy.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(enemy) do
enemy_map:insert(xa, ya, (enemy_map:get(xa, ya) or 0) + 10)
end
end

View file

@ -1,5 +1,4 @@
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"
return function(cfg)
@ -16,7 +15,7 @@ return function(cfg)
-- Then, also exclude hexes next to herding_perimeter; some of the functions work better like that
herding_area:iter( function(x, y, v)
for xa, ya in H.adjacent_tiles(x, y) do
for xa, ya in wesnoth.current.map:iter_adjacent(x, y) do
if (wesnoth.map.matches(xa, ya, location_filter) ) then
herding_area:remove(x, y)
end

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local herding_area = wesnoth.require "ai/micro_ais/cas/ca_herding_f_herding_area.lua"
@ -27,7 +26,7 @@ function ca_herding_sheep_move:execution(cfg)
local dogs_filter = wml.get_child(cfg, "filter")
-- Exclude those that are next to a dog
reach_map:iter( function(x, y, v)
for xa, ya in H.adjacent_tiles(x, y) do
for xa, ya in wesnoth.current.map:iter_adjacent(x, y) do
local dog = wesnoth.units.get(xa, ya)
if dog and dog:matches(dogs_filter) then
reach_map:remove(x, y)

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
local M = wesnoth.map
@ -13,7 +12,7 @@ local function hunter_attack_weakest_adj_enemy(ai, hunter)
if (hunter.attacks_left == 0) then return 'no_attack' end
local min_hp, target = math.huge
for xa,ya in H.adjacent_tiles(hunter.x, hunter.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(hunter) do
local enemy = wesnoth.units.get(xa, ya)
if AH.is_attackable_enemy(enemy) then
if (enemy.hitpoints < min_hp) then
@ -81,7 +80,7 @@ function ca_hunter:execution(cfg)
-- Huge rating bonus if this is next to an enemy
local enemy_hp = 500
for xa,ya in H.adjacent_tiles(x, y) do
for xa,ya in wesnoth.current.map:iter_adjacent(x, y) do
local enemy = wesnoth.units.get(xa, ya)
if AH.is_attackable_enemy(enemy) then
if (enemy.hitpoints < enemy_hp) then enemy_hp = enemy.hitpoints end

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local messenger_next_waypoint = wesnoth.require "ai/micro_ais/cas/ca_messenger_f_next_waypoint.lua"
@ -25,7 +24,7 @@ local function messenger_find_enemies_in_way(messenger, goal_x, goal_y, avoid_ma
for i = 2,#path do
local sub_path, sub_cost = AH.find_path_with_avoid(messenger, path[i][1], path[i][2], avoid_map, { ignore_enemies = true })
if (sub_cost <= messenger.moves) then
for xa,ya in H.adjacent_tiles(path[i][1], path[i][2]) do
for xa,ya in wesnoth.current.map:iter_adjacent(path[i]) do
local enemy = wesnoth.units.get(xa, ya)
if AH.is_attackable_enemy(enemy) then return enemy end
end

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require("ai/lua/ai_helper.lua")
local LS = wesnoth.require "location_set"
@ -24,7 +23,7 @@ function ca_recruit_random:evaluation(cfg)
local new_hexes = {}
castle_map:iter(function(x, y)
for xa,ya in H.adjacent_tiles(x, y) do
for xa,ya in wesnoth.current.map:iter_adjacent(x, y) do
if (not castle_map:get(xa, ya)) and wesnoth.current.map:on_board(xa, ya) then
local is_castle = wesnoth.terrain_types[wesnoth.current.map[{xa, ya}]].castle

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local M = wesnoth.map
@ -55,7 +54,7 @@ function ca_stationed_guardian:execution(cfg)
-- Find tiles adjacent to the target
-- Save the one with the highest defense rating that guardian can reach
local best_defense, attack_loc = - math.huge
for xa,ya in H.adjacent_tiles(target.x, target.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(target.x) do
-- Only consider unoccupied hexes
local unit_in_way = wesnoth.units.get(xa, ya)
if (not AH.is_visible_unit(wesnoth.current.side, unit_in_way))

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local MAIUV = wesnoth.require "ai/micro_ais/micro_ai_unit_variables.lua"
local WMPF = wesnoth.require "ai/micro_ais/cas/ca_wolves_multipacks_functions.lua"
@ -99,7 +98,7 @@ function ca_wolves_multipacks_attack:execution(cfg)
-- Also, any target sitting next to a wolf of the same pack that has
-- no attacks left is priority targeted (in order to stick with
-- the same target for all wolves of the pack)
for xa,ya in H.adjacent_tiles(target.x, target.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(target) do
local adj_unit = wesnoth.units.get(xa, ya)
if adj_unit then
local unit_pack_number = MAIUV.get_mai_unit_variables(adj_unit, cfg.ai_id, "pack_number")

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local AH = wesnoth.require "ai/lua/ai_helper.lua"
local LS = wesnoth.require "location_set"
local M = wesnoth.map
@ -40,7 +39,7 @@ function ca_zone_guardian:execution(cfg)
-- Find tiles adjacent to the target
-- Save the one with the highest defense rating that guardian can reach
local best_defense, attack_loc = - math.huge
for xa,ya in H.adjacent_tiles(target.x, target.y) do
for xa,ya in wesnoth.current.map:iter_adjacent(target) do
-- Only consider unoccupied hexes
local unit_in_way = wesnoth.units.get(xa, ya)
if (not AH.is_visible_unit(wesnoth.current.side, unit_in_way))

View file

@ -2,8 +2,7 @@ return {
init = function()
local priority_target = {}
local H = wesnoth.require "helper"
local W = H.set_wml_action_metatable {}
local W = wml.fire
local AH = wesnoth.require "ai/lua/ai_helper.lua"
function priority_target:change_attacks_aspect(target_id)

View file

@ -530,7 +530,6 @@
[/kill]
[lua]
code=<<
local helper = wesnoth.require "helper"
local units = wesnoth.units.find_on_map( { side = 1 } )
for i = 1, #units do
-- pick an advancement randomly, and remove others so advance() doesn't show the dialog
@ -542,7 +541,7 @@
-- level the unit and give it a random amount of experience up to half of max
units[i].experience = units[i].max_experience
units[i]:advance( )
units[i].experience = mathx.random ( 0, helper.round( units[i].max_experience / 2 ) )
units[i].experience = mathx.random ( 0, mathx.round( units[i].max_experience / 2 ) )
end
>>
[/lua]

View file

@ -1,7 +1,6 @@
-- Used for the bandit villages in S5. Much more specific than the village spawn implementations elsewhere,
-- since there are a lot more specific things needed (mostly the boss mechanics and village spreading)
local helper = wesnoth.require "helper"
local wml_actions = wesnoth.wml_actions
local _ = wesnoth.textdomain "wesnoth-ei"
local T = wml.tag

View file

@ -1,6 +1,5 @@
local H = wesnoth.require "helper"
local T = wml.tag
local W = H.set_wml_action_metatable {}
local W = wml.fire
local _ = wesnoth.textdomain 'wesnoth-sota'
-- After preshow, this variable will hold the unit_types being shown in the listbox.

View file

@ -1,4 +1,3 @@
local H = wesnoth.require "helper"
local LS = wesnoth.require "location_set"
local M = wesnoth.map
local T = wml.tag
@ -72,7 +71,7 @@ function ca_transport:execution()
-- This is mostly to avoid it being across the bay in SotBE S6
local adj_tiles = {}
if (rating >= -0.05) then
for x,y in H.adjacent_tiles(r[1], r[2]) do
for x,y in wesnoth.current.map:iter_adjacent(r) do
if (not unit_map:get(x, y)) then
if wesnoth.map.matches(x, y, { terrain = "!, W*" }) then
rating = rating + 1

View file

@ -1,6 +1,5 @@
-- Used for the bandit spawns in scenario 5
local helper = wesnoth.require "helper"
local utils = wesnoth.require "wml-utils"
local wml_actions = wesnoth.wml_actions
local T = wml.tag

View file

@ -384,7 +384,6 @@
#define PLACE_ENEMY_UNITS
[lua]
code = <<
local helper = wesnoth.require "helper"
local wml_actions = wesnoth.wml_actions
local T = wml.tag
local vars = wml.variables

View file

@ -1,5 +1,4 @@
local on_event = wesnoth.require("on_event")
local helper = wesnoth.require("helper")
local _ = wesnoth.textdomain 'wesnoth-wc'

View file

@ -1,6 +1,5 @@
local _ = wesnoth.textdomain 'wesnoth-wc'
local on_event = wesnoth.require("on_event")
local helper = wesnoth.require("helper")
local bonus = {}
bonus.sceneries = {}

View file

@ -1,5 +1,4 @@
local _ = wesnoth.textdomain 'wesnoth-wc'
local helper = wesnoth.require("helper")
local T = wml.tag
local terrain_map = { fungus = "Uft", cave = "Ut", sand = "Dt",

View file

@ -1,4 +1,3 @@
local helper = wesnoth.require("helper")
local T = wml.tag
local _ = wesnoth.textdomain 'wesnoth-wc'

View file

@ -1,5 +1,4 @@
_ = wesnoth.textdomain 'wesnoth-wc'
helper = wesnoth.require("helper")
utils = wesnoth.require("wml-utils")
functional = wesnoth.require("functional")
wc2_convert = wesnoth.dofile("./../shared_utils/wml_converter.lua")

View file

@ -5,7 +5,6 @@
---------------------------------------------------------
_ = wesnoth.textdomain "wesnoth-wc"
helper = wesnoth.require("helper")
local function table_join(t1, t2)
local r = {}

View file

@ -1,4 +1,3 @@
local helper = wesnoth.require "helper"
local utils = wesnoth.require "wml-utils"
local wml_actions = wesnoth.wml_actions
local T = wml.tag
@ -548,7 +547,7 @@ end
function wml_actions.store_side(cfg)
local writer = utils.vwriter.init(cfg, "side")
for t, side_number in helper.get_sides(cfg) do
for t, side_number in wesnoth.sides.iter(cfg) do
local container = t.__cfg
-- set values not properly handled by the __cfg
container.income = t.total_income

View file

@ -1,4 +1,3 @@
local helper = wesnoth.require "helper"
local T = wml.tag
local function add_animation(anim, cfg)

View file

@ -1,4 +1,3 @@
local helper = wesnoth.require "helper"
local utils = wesnoth.require "wml-utils"
local wml_actions = wesnoth.wml_actions
local T = wml.tag

View file

@ -1,4 +1,3 @@
local helper = wesnoth.require "helper"
local location_set = wesnoth.require "location_set"
local kill_recursion_preventer = location_set.create()

View file

@ -1,4 +1,3 @@
local helper = wesnoth.require "helper"
local location_set = wesnoth.require "location_set"
function wesnoth.wml_actions.store_reachable_locations(cfg)
@ -37,7 +36,7 @@ function wesnoth.wml_actions.store_reachable_locations(cfg)
if range == "attack" then
unit_reach:iter(function(x, y)
reach:insert(x, y)
for u,v in helper.adjacent_tiles(x, y) do
for u,v in wesnoth.current.map:iter_adjacent(x, y) do
reach:insert(u, v)
end
end)

View file

@ -3,9 +3,9 @@
name = prestart
[lua]
code = <<
H = wesnoth.require("helper")
F = wesnoth.require("functional")
A = wesnoth.require("ai/lua/extCAexample.lua")
unit_test.assert(H and A and true, 'require works')
unit_test.assert(F and A and true, 'require works')
unit_test.succeed()
>>
[/lua]