Update some deprecated Lua uses
This commit is contained in:
parent
a2d7a26365
commit
cadb233d6c
7 changed files with 11 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue