shadowm

Untitled

Sep 2nd, 2015
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | None | 0 0
  1. ---
  2. -- Installs mechanical "Door" units on gate terrain hexes.
  3. --
  4. -- [setup_doors]
  5. --     side=(side number)
  6. --     terrain=(optional terrain filter string, default "*^Z\,*^Z/")
  7. --     ... optional SLF ...
  8. -- [/setup_doors]
  9. ---
  10. function wesnoth.wml_actions.setup_doors(cfg)
  11.     local owner_side = cfg.side or
  12.         helper.wml_error("[setup_doors] No owner side= specified")
  13.  
  14.     if cfg.terrain == nil then
  15.         cfg["terrain"] = "*^Z\\,*^Z/"
  16.     end
  17.  
  18.     cfg.side = nil
  19.     local locs = wesnoth.get_locations(cfg)
  20.  
  21.     for k, loc in ipairs(locs) do
  22.         wesnoth.put_unit(loc[1], loc[2], {
  23.             type = "Door",
  24.             side = owner_side,
  25.             id = ("__door_X%dY%d"):format(loc[1], loc[2]),
  26.         })
  27.     end
  28. end
Advertisement
Add Comment
Please, Sign In to add comment