Skip to content

Commit

Permalink
Update some deprecated Lua uses
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsc committed Mar 6, 2021
1 parent a2d7a26 commit cadb233
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions data/ai/lua/ai_helper.lua
Expand Up @@ -70,7 +70,7 @@ end
function ai_helper.clear_labels()
-- Clear all labels on a map
for x, y in wesnoth.current.map:iter(true) do
wesnoth.label { x = x, y = y, text = "" }
M.add_labels { x = x, y = y, text = "" }
end
end

Expand Down Expand Up @@ -111,7 +111,7 @@ function ai_helper.put_labels(map, cfg)
end

if (type(out) == 'number') then out = out * factor end
wesnoth.label { x = x, y = y, text = out, color = cfg.color }
M.add_labels { x = x, y = y, text = out, color = cfg.color }
end)
end

Expand Down Expand Up @@ -782,7 +782,7 @@ function ai_helper.get_closest_location(hex, location_filter, unit)

if unit then
for _,loc in ipairs(locs) do
local movecost = unit:movement(wesnoth.current.map[loc])
local movecost = unit:movement_on(wesnoth.current.map[loc])
if (movecost <= unit.max_moves) then return loc end
end
else
Expand All @@ -808,7 +808,7 @@ function ai_helper.get_passable_locations(location_filter, unit)
if unit then
local locs = {}
for _,loc in ipairs(all_locs) do
local movecost = unit:movement(wesnoth.current.map[loc])
local movecost = unit:movement_on(wesnoth.current.map[loc])
if (movecost <= unit.max_moves) then table.insert(locs, loc) end
end
return locs
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_assassin_move.lua
Expand Up @@ -25,7 +25,7 @@ local function custom_cost(x, y, unit, enemy_rating_map, prefer_map)
-- must return values >=1 for the a* search to work.

local terrain = wesnoth.current.map[{x, y}]
local move_cost = unit:movement(terrain)
local move_cost = unit:movement_on(terrain)

move_cost = move_cost + (enemy_rating_map:get(x, y) or 0)

Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_goto.lua
Expand Up @@ -8,7 +8,7 @@ local M = wesnoth.map

local function custom_cost(x, y, unit, avoid_map, enemy_map, enemy_attack_map, multiplier)
local terrain = wesnoth.current.map[{x, y}]
local move_cost = unit:movement(terrain)
local move_cost = unit:movement_on(terrain)

if avoid_map and avoid_map:get(x, y) then
move_cost = move_cost + AH.no_path
Expand Down
4 changes: 2 additions & 2 deletions data/ai/micro_ais/cas/ca_wolves_multipacks_functions.lua
Expand Up @@ -4,14 +4,14 @@ local M = wesnoth.map
local wolves_multipacks_functions = {}

function wolves_multipacks_functions.clear_label(x, y)
wesnoth.label{ x = x, y = y, text = "" }
M.add_label{ x = x, y = y, text = "" }
end

function wolves_multipacks_functions.put_label(x, y, text)
-- For displaying the wolf pack number underneath each wolf
-- Only use gray for now, but easily expandable to add a color option
text = "<span color='#c0c0c0'>" .. text .. "</span>"
wesnoth.label{ x = x, y = y, text = text }
M.add_label{ x = x, y = y, text = text }
end

function wolves_multipacks_functions.assign_packs(cfg)
Expand Down
Expand Up @@ -17,7 +17,7 @@ function connected_components(locs)
local todo = { loc }
l_set[loc_i] = color_i
while #todo ~= 0 do
for i, loc_ad in ipairs({wesnoth.map.get_adjacent_tiles(todo[1][1], todo[1][2])}) do
for i, loc_ad in ipairs({wesnoth.map.get_adjacent_hexes(todo[1][1], todo[1][2])}) do
local loc_ad_i = loc_to_index(loc_ad)
if l_set[loc_ad_i] then
if l_set[loc_ad_i] == true then
Expand Down
2 changes: 1 addition & 1 deletion data/lua/helper.lua
Expand Up @@ -72,7 +72,7 @@ end
-- Not deprecated because, unlike wesnoth.map.get_adjacent_tiles,
-- this verifies that the locations are on the map.
function helper.adjacent_tiles(x, y, with_borders)
local adj = {wesnoth.map.get_adjacent_tiles(x, y)}
local adj = {wesnoth.map.get_adjacent_hexes(x, y)}
local i = 0
return function()
while i < #adj do
Expand Down
2 changes: 1 addition & 1 deletion data/lua/wml-tags.lua
Expand Up @@ -800,7 +800,7 @@ function wml_actions.label( cfg )
local new_cfg = wml.parsed( cfg )
for index, location in ipairs( wesnoth.map.find( cfg ) ) do
new_cfg.x, new_cfg.y = location[1], location[2]
wesnoth.label( new_cfg )
wesnoth.map.add_label( new_cfg )
end
end

Expand Down

0 comments on commit cadb233

Please sign in to comment.