Guest User

ClearFactoryQueue

a guest
Jul 4th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. function widget:GetInfo()
  2.   return {
  3.     name      = "ClearFactoryQueue",
  4.     desc      = "Clears the entire build queue of all selected factories.",
  5.     author    = "FlorisXIV",
  6.     date      = "2013-07-04",
  7.     license   = "Dunno  about licenses, use this in any way you like.",
  8.     layer     = 0,
  9.     enabled   = true  
  10.   }
  11. end
  12.  
  13.  
  14. --includes
  15. include("keysym.h.lua")
  16.  
  17.  
  18. function widget:Initialize()
  19.   if (Spring.GetSpectatingState() or Spring.IsReplay()) then
  20.         widgetHandler:RemoveWidget()
  21.   end  
  22. end
  23.  
  24.  
  25. local function clearFactory()
  26.  
  27.  
  28.     selectedUnits = Spring.GetSelectedUnits()
  29.    
  30.     for _, unitID in ipairs( selectedUnits ) do
  31.        
  32.         ud = UnitDefs[ Spring.GetUnitDefID(unitID)]
  33.        
  34.        
  35.         if ( ud.isFactory ) then
  36.            
  37.             buildQueue = Spring.GetFactoryCommands (unitID)
  38.            
  39.             for _, buildCommand in ipairs( buildQueue) do
  40.                 Spring.GiveOrderToUnit( unitID, CMD.REMOVE, { buildCommand.tag } , {"ctrl"} )
  41.             end
  42.                        
  43.         end
  44.     end
  45.    
  46. end
  47.  
  48.  
  49. function widget:KeyPress(key, modifier, isRepeat)
  50.  
  51.     if( key == KEYSYMS.SEMICOLON ) then
  52.         clearFactory()
  53.     end
  54.  
  55. end
Advertisement
Add Comment
Please, Sign In to add comment