Skip to content

Commit

Permalink
Upgrade deprecated Lua
Browse files Browse the repository at this point in the history
loadstring was removed, load does the same thing.
atan2 was remvoed, atan works instead
  • Loading branch information
GregoryLundberg committed Oct 17, 2016
1 parent a90ef4a commit fc67742
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/ai/lua/ai_helper.lua
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion data/ai/micro_ais/cas/ca_fast_attack_utils.lua
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion data/lua/wml/random_placement.lua
Expand Up @@ -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
Expand Down

0 comments on commit fc67742

Please sign in to comment.