Advertisement
martintokio

Untitled

Feb 12th, 2021
626
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.60 KB | None | 0 0
  1. function friendHealer(parent)
  2.   local panelName = "advancedFriendHealer"
  3.   local ui = setupUI([[
  4. Panel
  5.   height: 145
  6.   margin-top: 2
  7.  
  8.   BotSwitch
  9.     id: title
  10.     anchors.left: parent.left
  11.     anchors.right: parent.right
  12.     anchors.top: parent.top
  13.     text-align: center
  14.     text: Friend Healer
  15.  
  16.   BotTextEdit
  17.     id: spellName
  18.     anchors.left: parent.left
  19.     anchors.right: parent.right
  20.     anchors.top: title.bottom
  21.     margin-top: 3
  22.  
  23.   Button
  24.     id: editList
  25.     anchors.left: parent.left
  26.     anchors.right: parent.right
  27.     anchors.top: prev.bottom
  28.     text-align: center
  29.     text: Edit List
  30.     margin-top: 3
  31.  
  32.   SmallBotSwitch
  33.     id: partyAndGuildMembers
  34.     anchors.left: parent.left
  35.     anchors.right: parent.right
  36.     anchors.top: prev.bottom
  37.     text-align: center
  38.     text: Heal Party/Guild
  39.     margin-top: 3
  40.  
  41.   BotLabel
  42.     id: manaInfo
  43.     anchors.left: parent.left
  44.     anchors.right: parent.right
  45.     anchors.top: partyAndGuildMembers.bottom
  46.     text-align: center
  47.  
  48.   HorizontalScrollBar
  49.     id: minMana
  50.     anchors.left: parent.left
  51.     anchors.right: parent.right
  52.     anchors.top: manaInfo.bottom
  53.     margin-top: 2
  54.     minimum: 1
  55.     maximum: 100
  56.     step: 1
  57.  
  58.   BotLabel
  59.     id: friendHp
  60.     anchors.left: parent.left
  61.     anchors.right: parent.right
  62.     anchors.top: prev.bottom
  63.     text-align: center
  64.  
  65.   HorizontalScrollBar
  66.     id: minFriendHp
  67.     anchors.left: parent.left
  68.     anchors.right: parent.horizontalCenter
  69.     anchors.top: friendHp.bottom
  70.     margin-right: 2
  71.     margin-top: 2
  72.     minimum: 1
  73.     maximum: 100
  74.     step: 1
  75.    
  76.   HorizontalScrollBar
  77.     id: maxFriendHp
  78.     anchors.left: parent.horizontalCenter
  79.     anchors.right: parent.right
  80.     anchors.top: prev.top
  81.     margin-left: 2
  82.     minimum: 1
  83.     maximum: 100
  84.     step: 1    
  85.   ]], parent)
  86.   ui:setId(panelName)
  87.  
  88.   if not storage[panelName] then
  89.     storage[panelName] = {
  90.       minMana = 60,
  91.       minFriendHp = 40,
  92.       maxFriendHp = 90,
  93.       spellName = "exura sio",
  94.       sioList = {},
  95.       partyAndGuildMembers = true
  96.     }
  97.   end
  98.  
  99.  
  100.   rootWidget = g_ui.getRootWidget()
  101.   sioListWindow = g_ui.createWidget('SioListWindow', rootWidget)
  102.   sioListWindow:hide()
  103.  
  104.   if storage[panelName].sioList and #storage[panelName].sioList > 0 then
  105.     for _, sioName in ipairs(storage[panelName].sioList) do
  106.       local label = g_ui.createWidget("SioFriendName", sioListWindow.SioList)
  107.       label.remove.onClick = function(widget)
  108.         table.removevalue(storage[panelName].sioList, label:getText())
  109.         label:destroy()
  110.       end
  111.       label:setText(sioName)
  112.     end
  113.   end
  114.  
  115.   sioListWindow.AddFriend.onClick = function(widget)
  116.     local friendName = sioListWindow.FriendName:getText()
  117.     if friendName:len() > 0 and not table.contains(storage[panelName].sioList, friendName, true) then
  118.       table.insert(storage[panelName].sioList, friendName)
  119.       local label = g_ui.createWidget("SioFriendName", sioListWindow.SioList)
  120.       label.remove.onClick = function(widget)
  121.         table.removevalue(storage[panelName].sioList, label:getText())
  122.         label:destroy()
  123.       end
  124.       label:setText(friendName)
  125.       sioListWindow.FriendName:setText('')
  126.     end
  127.   end
  128.  
  129.   ui.title:setOn(storage[panelName].enabled)
  130.   ui.partyAndGuildMembers:setOn(storage[panelName].partyAndGuildMembers)
  131.  
  132.   ui.title.onClick = function(widget)
  133.     storage[panelName].enabled = not storage[panelName].enabled
  134.     widget:setOn(storage[panelName].enabled)
  135.   end
  136.  
  137.   ui.partyAndGuildMembers.onClick = function(widget)
  138.     storage[panelName].partyAndGuildMembers = not storage[panelName].partyAndGuildMembers
  139.     widget:setOn(storage[panelName].partyAndGuildMembers)
  140.   end
  141.   ui.editList.onClick = function(widget)
  142.     sioListWindow:show()
  143.     sioListWindow:raise()
  144.     sioListWindow:focus()
  145.   end
  146.   ui.spellName.onTextChange = function(widget, text)
  147.     storage[panelName].spellName = text
  148.   end
  149.   local updateMinManaText = function()
  150.     ui.manaInfo:setText("Minimum Mana >= " .. storage[panelName].minMana)
  151.   end
  152.   local updateFriendHpText = function()
  153.     ui.friendHp:setText("" .. storage[panelName].minFriendHp .. "% <= hp >= " .. storage[panelName].maxFriendHp .. "%")  
  154.   end
  155.  
  156.   ui.minMana.onValueChange = function(scroll, value)
  157.     storage[panelName].minMana = value
  158.     updateMinManaText()
  159.   end
  160.   ui.minFriendHp.onValueChange = function(scroll, value)
  161.     storage[panelName].minFriendHp = value
  162.  
  163.     updateFriendHpText()
  164.   end
  165.   ui.maxFriendHp.onValueChange = function(scroll, value)
  166.     storage[panelName].maxFriendHp = value
  167.     updateFriendHpText()
  168.   end
  169.   ui.spellName:setText(storage[panelName].spellName)
  170.   ui.minMana:setValue(storage[panelName].minMana)
  171.   ui.minFriendHp:setValue(storage[panelName].minFriendHp)
  172.   ui.maxFriendHp:setValue(storage[panelName].maxFriendHp)
  173.  
  174.   macro(200, function()
  175.     if storage[panelName].enabled and storage[panelName].spellName:len() > 0 and manapercent() > storage[panelName].minMana then
  176.       for _, spec in ipairs(getSpectators()) do
  177.         if spec:isPlayer() and storage[panelName].minFriendHp >= spec:getHealthPercent() and spec:getHealthPercent() <= storage[panelName].maxFriendHp then
  178.           if storage[panelName].partyAndGuildMembers and (spec:getShield() >= 3 or spec:getEmblem() == 1) then
  179.               saySpell(storage[panelName].spellName .. ' "' .. spec:getName(), 100)
  180.           end
  181.           if table.contains(storage[panelName].sioList, spec:getName()) then
  182.             saySpell(storage[panelName].spellName .. ' "' .. spec:getName(), 100)
  183.           end
  184.         end
  185.       end
  186.     end
  187.   end)
  188. end
  189. friendHealer(batTab)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement