I have a button defined in my xml file as TRACK_QUEST_ABBREV The normal text for it is "Track". I would love to be able to change it to "UnTrack" if the quest is being tracked (like the Blizz quest log does). I copied the following Lua code from the Blizz quest log but it is giving me errors:
Lua Code:
function qgc:ToggleWatch(index)
if not index then
index = GetQuestLogSelection()
end
if index>0 then
if IsQuestWatched(index) then -- already watched, remove from watch
RemoveQuestWatch(index)
TRACK_QUEST_ABBREV:SetText(TEXT("Track"))
else -- not watched, see if there's room to add, add if so
if GetNumQuestWatches() >= MAX_WATCHABLE_QUESTS then
UIErrorsFrame:AddMessage(format(QUEST_WATCH_TOO_MANY,MAX_WATCHABLE_QUESTS),1,0.1,0.1,1)
else
AddQuestWatch(index)
TRACK_QUEST_ABBREV:SetText(TEXT("UnTrack"))
end
end
end
end
What am I missing? The error that I get is: attempt to call method 'SetText' (a nil value) and SetFormattedText gets the very same error.
Thanks in advance for any help on this.
Cheers!