mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-25 21:50:25 +00:00
Lua API: Add wesnoth.sides.iter
This replaces both helper.get_sides and helper.all_teams
This commit is contained in:
parent
1e42f80c13
commit
47951c4700
@ -17,6 +17,20 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
|
||||
}
|
||||
setmetatable(wesnoth.sides, sides_mt)
|
||||
|
||||
function wesnoth.sides.iter(filter)
|
||||
local function f(s)
|
||||
local i = s.i
|
||||
while i < #wesnoth.sides do
|
||||
i = i + 1
|
||||
if filter == nil or wesnoth.sides.matches(i, filter) then
|
||||
s.i = i
|
||||
return wesnoth.sides[i], i
|
||||
end
|
||||
end
|
||||
end
|
||||
return f, { i = 0 }
|
||||
end
|
||||
|
||||
-- Deprecated functions
|
||||
function wesnoth.set_side_variable(side, var, val)
|
||||
wesnoth.sides[side].variables[var] = val
|
||||
|
@ -112,5 +112,7 @@ helper.get_user_choice = wesnoth.deprecate_api('helper.get_user_choice', 'gui.ge
|
||||
helper.rand = wesnoth.deprecate_api('helper.rand', 'mathx.random_choice', 1, nil, mathx.random_choice)
|
||||
helper.round = wesnoth.deprecate_api('helper.round', 'mathx.round', 1, nil, mathx.round)
|
||||
helper.shuffle = wesnoth.deprecate_api('helper.shuffle', 'mathx.shuffle', 1, nil, mathx.shuffle)
|
||||
helper.all_teams = wesnoth.deprecate_api('helper.all_teams', 'wesnoth.sides.iter', 1, nil, helper.all_teams)
|
||||
helper.get_sides = wesnoth.deprecate_api('helper.get_sides', 'wesnoth.sides.iter', 1, nil, helper.get_sides)
|
||||
|
||||
return helper
|
||||
|
Loading…
x
Reference in New Issue
Block a user