Hello!
I'm kind of into archaeology atm, and writing a small addon about it to make it more comfortable to me (watching TV while digging simplifies everything!).
I'm encountering a problem, when I want to make a "solve-button".
I got a window with a statusbar of the current project of every race, next to the artifact icon. I want to be able to click on that icon, if I got enough artifacts, but my SetScript don't works:
lua Code:
PredatorArchy:RegisterEvent('PLAYER_ENTERING_WORLD')
PredatorArchy:SetScript('OnEvent', function()
local i, raceName, raceTex
local _, _, hasArch = GetProfessions()
if ( hasArch ) then
-- Setting up the main frame
PredatorArchy:SetBackdrop( {
bgFile = solidTex,
edgeFile = borderTex,
tile = false,
edgeSize = 8,
insets = { left = 4, right = 4, top = 4, bottom = 4 }
} )
PredatorArchy:SetBackdropColor(0, 0, 0, 0.7)
PredatorArchy:SetWidth(300)
PredatorArchy:SetHeight(40)
PredatorArchy:EnableMouse(true)
PredatorArchy:RegisterForDrag("LeftButton","RightButton")
PredatorArchy:SetMovable(true)
PredatorArchy:SetUserPlaced(true)
PredatorArchy:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
PredatorArchy:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
PredatorArchy:SetPoint('CENTER')
PredatorArchy.SkillRank = CreateFrame('StatusBar', nil, PredatorArchy)
PredatorArchy.SkillRank:SetPoint('TOPLEFT', 15, -10)
PredatorArchy.SkillRank:SetPoint('BOTTOMRIGHT', PredatorArchy, 'TOPRIGHT', -15, -30)
PredatorArchy.SkillRank:SetStatusBarTexture(barTex)
PredatorArchy.SkillRank:SetStatusBarColor(0, 0.7, 0)
PredatorArchy.SkillRank:RegisterEvent('ARTIFACT_COMPLETE')
PredatorArchy.SkillRank:SetScript('OnEvent', function()
core.UpdateSkill(hasArch)
core.UpdateArtifacts()
end)
PredatorArchy.SkillRank.back = PredatorArchy.SkillRank:CreateTexture(nil, 'BACKGROUND')
PredatorArchy.SkillRank.back:SetAllPoints(PredatorArchy.SkillRank)
PredatorArchy.SkillRank.back:SetTexture(barTex)
PredatorArchy.SkillRank.back:SetVertexColor(0.3, 0.3, 0.3, 1)
PredatorArchy.SkillRank.text = lib.CreateFontObject(PredatorArchy.SkillRank, 14, font)
PredatorArchy.SkillRank.text:SetPoint('CENTER', 0, 1)
PredatorArchy.SkillRank.text:SetText('INIT')
PredatorArchy.SkillRank.text:SetJustifyH('CENTER')
PredatorArchy.List = {}
for i = 1, GetNumArchaeologyRaces() do
raceName, raceTex = GetArchaeologyRaceInfo(i)
PredatorArchy.List[raceName] = {}
PredatorArchy.List[raceName].raceName = raceName
PredatorArchy.List[raceName].raceIcon = PredatorArchy:CreateTexture(nil, 'OVERLAY')
PredatorArchy.List[raceName].raceIcon:SetSize(36,36)
PredatorArchy.List[raceName].raceIcon:SetTexture(raceTex)
PredatorArchy.List[raceName].raceIcon:SetPoint('TOPLEFT', PredatorArchy.SkillRank, 'TOPLEFT', 0, -(i*25))
PredatorArchy.List[raceName].artifactIcon = CreateFrame('Button', nil, PredatorArchy)
PredatorArchy.List[raceName].artifactIcon:SetSize(21, 21)
PredatorArchy.List[raceName].artifactIcon:SetPoint('RIGHT', PredatorArchy, 'RIGHT', -15, 0)
PredatorArchy.List[raceName].artifactIcon:SetPoint('TOP', PredatorArchy.List[raceName].raceIcon, 'TOP', 0, -1)
PredatorArchy.List[raceName].artifactIcon:SetScript('OnClick', function()
lib.debugging(PredatorArchy.List[raceName].raceName)
-- core.SolveArtifact(PredatorArchy.List[raceName].raceName)
end)
PredatorArchy.List[raceName].progress = CreateFrame('StatusBar', nil, PredatorArchy)
PredatorArchy.List[raceName].progress:SetStatusBarTexture(barTex)
PredatorArchy.List[raceName].progress:SetPoint('TOPLEFT', PredatorArchy.List[raceName].raceIcon, 'TOPRIGHT', -10, -1)
PredatorArchy.List[raceName].progress:SetPoint('BOTTOM', PredatorArchy.List[raceName].raceIcon, 'TOP', 0, -22)
PredatorArchy.List[raceName].progress:SetPoint('RIGHT', PredatorArchy.List[raceName].artifactIcon, 'LEFT', -10, 0)
PredatorArchy.List[raceName].progress:SetMinMaxValues(0, 1)
PredatorArchy.List[raceName].progress:SetValue(0)
PredatorArchy.List[raceName].progress.back = PredatorArchy.List[raceName].progress:CreateTexture(nil, 'BACKGROUND')
PredatorArchy.List[raceName].progress.back:SetAllPoints(PredatorArchy.List[raceName].progress)
PredatorArchy.List[raceName].progress.back:SetTexture(barTex)
PredatorArchy.List[raceName].progress.back:SetVertexColor(0.3, 0.3, 0.3, 1)
PredatorArchy.List[raceName].progress.text = lib.CreateFontObject(PredatorArchy.List[raceName].progress, 14, font)
PredatorArchy.List[raceName].progress.text:SetPoint('LEFT', 10, 1)
PredatorArchy.List[raceName].progress.text:SetText('INIT')
PredatorArchy:SetHeight(PredatorArchy:GetHeight()+26)
end
PredatorArchy:UnregisterAllEvents()
PredatorArchy:RegisterEvent('CHAT_MSG_CURRENCY')
PredatorArchy:SetScript('OnEvent', core.UpdateArtifacts)
core.UpdateSkill(hasArch)
core.UpdateArtifacts()
end
end)
Lines 63/64 are my problems: When I click the button, a chat message is displayed with the name of the "clicked" race, so is the plan at least.
I always get the name of the race, with the highest ID (on my german client, it's "Anderes", should be "others".
I'm kind of sure, this is related to setting the script-handler inside of that loop, which iterates all races, but on the other hand, it doesn't seem logic, because setting the right textures and stuff is working.
Can someone give me a hint please?