stoneharry

Untitled

Jan 19th, 2013
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.18 KB | None | 0 0
  1.  
  2. local resources = 0
  3.  
  4. function MiniGameEvent(self, event)
  5.     if event == 0 then
  6.         PlaySound("igSpellBookOpen");
  7.         self:Show();
  8.         MinigameFrame:SetFrameStrata("BACKGROUND")
  9.     elseif event == 1 then
  10.         self:Hide();
  11.     end
  12. end
  13.  
  14. function PurchaseWeakGhoul()
  15.     if resources > 4 then
  16.         SendChatMessage("[CU-ADDON] SpawnWeakGhouls", "WHISPER", nil, UnitName("player"))
  17.     end
  18. end
  19.  
  20. function PurchaseSpellcaster()
  21.     if resources > 6 then
  22.         SendChatMessage("[CU-ADDON] SpawnSpellcaster", "WHISPER", nil, UnitName("player"))
  23.     end
  24. end
  25.  
  26. function PurchaseAbomination()
  27.     if resources > 49 then
  28.         SendChatMessage("[CU-ADDON] SpawnAbomination", "WHISPER", nil, UnitName("player"))
  29.     end
  30. end
  31.  
  32. function PurchaseTurret(self,num)
  33.     if resources > 29 then
  34.         self:Disable()
  35.         if num == 0 then -- R
  36.             SendChatMessage("[CU-ADDON] TurretR", "WHISPER", nil, UnitName("player"))
  37.         else
  38.             SendChatMessage("[CU-ADDON] TurretL", "WHISPER", nil, UnitName("player"))
  39.         end
  40.     end
  41. end
  42.  
  43. function Upgrade_Unit(self, num)
  44.     if resources > 49 then
  45.         self:Disable()
  46.         if num == 0 then -- upgrade ghouls
  47.        
  48.         else -- upgrade necromancers
  49.        
  50.         end
  51.     end
  52. end
  53.  
  54. ChatFrame_MessageEvnt3 = ChatFrame_MessageEventHandler
  55.  
  56. function ChatFrame_MessageEventHandler(s,e,arg1,...)
  57.     if arg1 ~= nil then
  58.         if arg1 ~= "" then
  59.             if string.find(arg1, "[CU-ADDON]", 1, true) ~= nil then
  60.                 if (arg1 == "[CU-ADDON] OpenMinigame") then
  61.                     MiniGameEvent(MinigameFrame, 0);
  62.                 elseif (arg1 == "[CU-ADDON] CloseMiniGame") then
  63.                     MiniGameEvent(MinigameFrame, 1);
  64.                 elseif (string.find(arg1, "[CU-ADDON] minigame-resources : ", 1, true) ~= nil) then
  65.                     local nums = scen_split(arg1)
  66.                     if #nums == 1 then
  67.                         MiniGameResourcesButton.label:SetText("Resources:\n"..nums[1])
  68.                         resources = tonumber(nums[1])
  69.                     end
  70.                 end
  71.                 return;
  72.             end
  73.         end
  74.     end
  75.     ChatFrame_MessageEvnt3(s,e,arg1,...)
  76. end
  77.  
  78. function scen_split(str)
  79.     local b = {}
  80.     local c = 1
  81.     local d = {}
  82.     string.gsub(str, "[%d]", function(a)
  83.         if (a == "-") then
  84.             c = c + 1
  85.         else
  86.             if (not b[c]) then
  87.                 b[c] = {}
  88.             end
  89.             table.insert(b[c], a)
  90.         end
  91.     end)
  92.     for k, v in pairs (b) do
  93.         table.insert(d, table.concat(v))
  94.     end
  95.     return d
  96. end
Advertisement
Add Comment
Please, Sign In to add comment