Upgrade deprecated Lua

loadstring was removed, load does the same thing.
atan2 was remvoed, atan works instead
This commit is contained in:
Gregory A Lundberg 2016-10-16 00:41:34 -05:00
parent a90ef4a1cb
commit fc6774289e
3 changed files with 3 additions and 3 deletions

View file

@ -544,7 +544,7 @@ function ai_helper.get_angle(from_hex, to_hex)
local _, y1cart = ai_helper.cartesian_coords(x1, y1)
local _, y2cart = ai_helper.cartesian_coords(x2, y2)
return math.atan2(y2cart - y1cart, x2 - x1)
return math.atan(y2cart - y1cart, x2 - x1)
end
function ai_helper.get_direction_index(from_hex, to_hex, n, center_on_east)

View file

@ -90,7 +90,7 @@ local function get_attack_filter_from_aspect(aspect, which, data, is_leader)
end
elseif (aspect.name == "lua_aspect") then
--print("Found lua aspect")
local filter = loadstring(aspect.code)(nil, H.get_child(aspect, 'args'), data)
local filter = load(aspect.code)(nil, H.get_child(aspect, 'args'), data)
if (type(filter[which]) == 'function') then
temporary_attacks_filter_fcn = filter[which]
local units = AH.get_live_units(attack_filter(which, {

View file

@ -14,7 +14,7 @@ wesnoth.wml_actions.random_placement = function(cfg)
local math_abs = math.abs
local locs = wesnoth.get_locations(filter)
if type(num_items) == "string" then
num_items = math.floor(loadstring("local size = " .. #locs .. "; return " .. num_items)())
num_items = math.floor(load("local size = " .. #locs .. "; return " .. num_items)())
print("num_items=" .. num_items .. ", #locs=" .. #locs)
end
local size = #locs