Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-02-19, 04:38 PM   #1
Maulkin
A Defias Bandit
Join Date: May 2019
Posts: 1
New to lua, need help implementing a loop.

Hello All,

This is my current code:
Code:
local DefensiveStance = 71
local RighteousFury = 25780
local ShieldBlock = 2565
local Taunt = 355

local button = CreateFrame("Button", "ReRoll", UIParent, "ActionButtonTemplate, InsecureActionButtonTemplate")
local type = "item"
local id = 777992
--local name, icon = GetItemInfo(id)
local name, _, _, _, _, _, _, _, _, icon = GetItemInfo(id)
button:SetAttribute("type", "item")
button:SetAttribute("*item1", name) 
button:SetAttribute("itemid", id)
button:SetText(name)
button.icon:SetTexture(icon)
button:SetAttribute("checkselfcast","1")
button:SetAttribute("checkfocuscast","1")
button:SetAttribute("enabled", true)
button:SetPoint("TOP", 0, -150)
button:SetSize(32, 32)
StaticPopup1Button1:Click()

local frame = CreateFrame('Frame')
frame:SetScript('OnEvent', function(self, event, ...)
    frame[event](self, ...)
end
 
function frame:LEARNED_SPELL_IN_TAB(self, ...)
    if IsSpellKnown(DefensiveStance, false) and IsSpellKnown(RighteousFury, false) and IsSpellKnown(ShieldBlock, false) and IsSpellKnown(Taunt, false) then end
		else C_Timer.After(3, ReRoll)  --To loop back to the button frame 
end
frame:RegisterEvent("LEARNED_SPELL_IN_TAB")
The first part of the code I am trying to create a button that will use an item in my inventory (ID: 777992) and then automatically click yes on the pop up box (StaticPopup1Button1:Click() ) checking if I want to use the item.

The second part is to check if the skills I am looking for have been learned or not.

What Im trying to figure out is how can I get it to Loop so if the skills are not learned it can automatically use the item (777992) and click the check box over and over. It would need to be on a 3 second timer for the loop.

This code is for 3.3.5 in case it makes much difference

Essentially I want to create a button that will use an item and accept the pop up, check if certain spells are learnt and then automatically re use the item and accept the pop up if the skills are not learnt/ on action bar.
 
 

WoWInterface » Developer Discussions » Lua/XML Help » New to lua, need help implementing a loop.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off