Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. !-- allows things like  'for j in wesnoth.get_sides({{"has_unit",{race="orc"}}}) do wesnoth.message(j.gold) end  '  
  2.  
  3. --! Returns an iterator over teams matching a given side filter that can be used in a for-in loop.
  4. function wesnoth.get_sides(cfg)
  5.         local function f(s)
  6.                 local i = s.i
  7.                 local team
  8.                 repeat
  9.                         i = i + 1
  10.                         team = wesnoth.get_side(i)
  11.                         if not team then return nil end
  12.                 until wesnoth.match_side(i,cfg)
  13.                 s.i = i
  14.                 return team
  15.         end
  16.         return f, { i = 0 }
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement