10-03-16, 07:51 PM | #1 |
setText or setFormattedText or ?
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:
Thanks in advance for any help on this. Cheers!
__________________
"There's no such thing as too many addons." Lothaer My Authored Addons HOME OF THE FREE, BECAUSE OF THE BRAVE
|
|
10-03-16, 08:16 PM | #2 |
TRACK_QUEST_ABBREV is a variable which holds a string. :SetText and :SetFormattedText are methods for a FontString object.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author of NPCScan and many other AddOns. |
|
10-03-16, 11:19 PM | #3 |
Also, the TEXT() function is legacy code from the very earliest iterations of the Blizzard UI; you should never use it in an addon. It literally just returns the string you pass to it:
Code:
function TEXT(text) return text; end As to the actual question: SetText and SetFormattedText are methods that exist on font string objects -- not string values. "Font string" is a type of widget in the WoW UI API, like "texture", "frame", or "button". "String" is a type of value in the Lua programming language, like "number", "boolean", or "table". If you want to display text, you either need to create a font string (which in turn needs to be attached to a frame): lua Code:
... or find the name of, or a reference to, a font string that already exists in the UI. Then you can tell it what text to display: Lua Code:
SetFormattedText is a "shortcut" to calling string.format and SetText; these do the same thing: Lua Code:
The difference is that SetFormattedText shifts the string.format operation over into C code, where it's (presumably) faster than running it in Lua. Unless you're doing it a million times in a row, though, you'll never notice the difference, so the main reason to use SetFormattedText is that it makes your code less verbose and more readable. Edit: After re-reading your post I noticed that you mentioned you think the TRACK_QUEST_ABBREV variable is referring a button. That is not correct -- the Blizzard UI code defines TRACK_QUEST_ABBREV as containing the string "Track". If you overwrote that value with a pointer to a button object, that's even worse -- not only does your code still not work, but you're also breaking any part of the default UI and other addons that expect TRACK_QUEST_ABBREV to be a string. Please post the rest of your code.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. Last edited by Phanx : 10-03-16 at 11:25 PM. |
|
10-06-16, 04:58 AM | #4 |
The xml code is below
Code:
<Button parentKey="TrackButton" inherits="MagicButtonTemplate" text="TRACK_QUEST_ABBREV"> <Size x="80" y="22"/> <Anchors> <Anchor point="LEFT" relativeKey="$parent.push" relativePoint="RIGHT"/> </Anchors> <Scripts> <OnClick> QuestGuru:ToggleWatch() </OnClick> <OnEnter> GameTooltip_AddNewbieTip(self, TRACK_QUEST, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_TRACKQUEST, 1) </OnEnter> <OnLeave function="GameTooltip_Hide"/> </Scripts> </Button> lua Code:
Blizzards coding from the Map/Quest is: lua Code:
Cheers
__________________
"There's no such thing as too many addons." Lothaer My Authored Addons HOME OF THE FREE, BECAUSE OF THE BRAVE
|
|
10-06-16, 09:16 AM | #5 |
You're not defining a global variable named "TrackButton" (nor should you) so you're now trying to call "SetText" on a nil value. The button object in the XML snippet you defined doesn't have a name (which is good) -- the "parentKey" attribute makes it accessible globally as "ParentFrame.TrackButton" or "AncestorFrame.Mothership.FlyingPopTarts.TrackButton" or something like that. However, since you did not post all of your code (seriously, why is it so hard to get people to do this?!) I can't tell you the actual path to that button you need to use in your Lua code, so you'll have to figure it out yourself.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
10-12-16, 01:32 AM | #6 |
The full xml code is below. I only did the section of Lua code that has anything to do with trying to change the button text. Pasting over 500 lines of Lua code that has nothing to do with it doesn't make sense to me. So the XML code fully is:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"> <CheckButton name="QuestGuruCheckButtonTemplate" inherits="UICheckButtonTemplate" virtual="true"> <Size x="24" y="24"/> <Scripts> <OnEnter> QuestGuru.OptionOnEnter(self) </OnEnter> <OnLeave function="GameTooltip_Hide"/> <OnClick> QuestGuru.OptionOnClick(self) </OnClick> </Scripts> </CheckButton> <Button name="QuestGuruListTemplate" virtual="true" text="Quest Title Example"> <Size x="299" y="16"/> <Layers> <Layer level="BACKGROUND"> <Texture parentKey="selected" file="Interface\QuestFrame\UI-QuestLogTitleHighlight" alphaMode="ADD"/> </Layer> <Layer level="ARTWORK"> <!-- number to left of quest indicating how many in group are on same quest --> <FontString parentKey="groupMates" inherits="GameFontNormalSmall" justifyH="RIGHT"> <Size x="0" y="16"/> <Anchors> <Anchor point="LEFT" x="8" y="0"/> </Anchors> </FontString> <!-- icon for the "tag" (Daily) (Account) (Raid) (Complete) etc --> <Texture parentKey="tag" file="Interface\QuestFrame\QuestTypeIcons"> <Size x="18" y="18"/> <Anchors> <Anchor point="RIGHT" x="-2" y="0"/> </Anchors> </Texture> <!-- checkmark to note tracked quests appears to right of normalText (anchored in the UpdateLogList) --> <Texture parentKey="check" file="Interface\Buttons\UI-CheckBox-Check"> <Size x="16" y="16"/> <Anchors> <Anchor point="LEFT"/> </Anchors> </Texture> </Layer> </Layers> <!-- quest title/header normalText is shifted to right 20 --> <ButtonText parentKey="normalText" nonspacewrap="true"> <Size x="0" y="10"/> <Anchors> <Anchor point="LEFT" x="20" y="0"/> </Anchors> </ButtonText> <NormalTexture file="Interface\Buttons\UI-MinusButton-UP"> <Size x="16" y="16"/> <Anchors> <Anchor point="LEFT" x="3" y="0"/> </Anchors> </NormalTexture> <HighlightTexture file="Interface\Buttons\UI-PlusButton-Hilight" alphaMode="ADD"> <Size x="16" y="16"/> <Anchors> <Anchor point="LEFT" x="3" y="0"/> </Anchors> </HighlightTexture> <NormalFont style="GameFontNormalLeft"/> <HighlightFont style="GameFontHighlightLeft"/> <DisabledFont style="GameFontHighlightLeft"/> <Scripts> <OnLoad> self.check:SetPoint("LEFT",self.normalText,"RIGHT") </OnLoad> <OnClick> QuestGuru.ListEntryOnClick(self) </OnClick> <OnEnter> QuestGuru.ListEntryOnEnter(self) </OnEnter> <OnLeave> GameTooltip:Hide() </OnLeave> </Scripts> </Button> <Frame name="QuestGuru" parent="UIParent" toplevel="true" clampedToScreen="true" enableMouse="true" movable="true" resizable="true" inherits="ButtonFrameTemplate" hidden="true"> <Size x="667" y="496"/> <Anchors> <Anchor point="LEFT"/> </Anchors> <Layers> <Layer level="OVERLAY" textureSubLevel="-1"> <Texture name="QGC_FramePortrait" file="Interface\QuestFrame\UI-QuestLog-BookIcon"> <Size x="64" y="64"/> <Anchors> <Anchor point="TOPLEFT" x="-9" y="9"/> </Anchors> </Texture> </Layer> <Layer level="BACKGROUND"> <!-- temporary fix for lua error in QuestInfo.lua:45 (questFrame.SealMaterialBG is nil) --> <Texture parentKey="SealMaterialBG" hidden="true"/> <FontString name="QGC_FrameTitleText" inherits="GameFontNormal" text="QUESTGURU_VERSION"> <Anchors> <Anchor point="TOP" x="0" y="-5"/> </Anchors> </FontString> </Layer> </Layers> <Frames> <!-- this is for a one-frame OnUpdate to run UpdateLog (so the function doesn't run multiple times in a frame --> <Frame parentKey="update" hidden="true"> <Scripts> <OnUpdate> self:GetParent():UpdateLog() </OnUpdate> </Scripts> </Frame> <!-- close button in bottomright --> <Button inherits="MagicButtonTemplate" text="CLOSE"> <Size x="80" y="22"/> <Anchors> <Anchor point="BOTTOMRIGHT" x="-6" y="4"/> </Anchors> <Scripts> <OnClick> self:GetParent():Hide() </OnClick> </Scripts> </Button> <!-- abandon button in bottomleft --> <Button parentKey="abandon" inherits="MagicButtonTemplate" text="ABANDON_QUEST_ABBREV"> <Size x="80" y="22"/> <Anchors> <Anchor point="BOTTOMLEFT" x="4" y="4"/> </Anchors> <Scripts> <OnClick> SetAbandonQuest(); local items = GetAbandonQuestItems(); if ( items ) then StaticPopup_Hide("ABANDON_QUEST"); StaticPopup_Show("ABANDON_QUEST_WITH_ITEMS", GetAbandonQuestName(), items); else StaticPopup_Hide("ABANDON_QUEST_WITH_ITEMS"); StaticPopup_Show("ABANDON_QUEST", GetAbandonQuestName()); end </OnClick> <OnEnter> GameTooltip_AddNewbieTip(self, ABANDON_QUEST, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_ABANDONQUEST, 1); </OnEnter> <OnLeave function="GameTooltip_Hide"/> </Scripts> </Button> <Button parentKey="push" inherits="MagicButtonTemplate" text="SHARE_QUEST_ABBREV"> <Size x="80" y="22"/> <Anchors> <Anchor point="LEFT" relativeKey="$parent.abandon" relativePoint="RIGHT"/> </Anchors> <Scripts> <OnClick> QuestLogPushQuest() PlaySound("igQuestLogOpen") </OnClick> <OnEnter> GameTooltip_AddNewbieTip(self, SHARE_QUEST, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_SHAREQUEST, 1) </OnEnter> <OnLeave function="GameTooltip_Hide"/> </Scripts> </Button> <Button parentKey="TrackButton" inherits="MagicButtonTemplate" text="TRACK_QUEST_ABBREV"> <Size x="80" y="22"/> <Anchors> <Anchor point="LEFT" relativeKey="$parent.push" relativePoint="RIGHT"/> </Anchors> <Scripts> <OnClick> QuestGuru:ToggleWatch() </OnClick> <OnEnter> GameTooltip_AddNewbieTip(self, TRACK_QUEST, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_TRACKQUEST, 1) </OnEnter> <OnLeave function="GameTooltip_Hide"/> </Scripts> </Button> <!-- frame with spiderwebs over left page, to show when quest log is empty --> <Frame parentKey="emptyLog" hidden="true"> <Size x="305" y="340"/> <Anchors> <Anchor point="LEFT" x="32" y="-16"/> </Anchors> <Layers> <Layer level="BACKGROUND"> <Texture file="Interface\QuestFrame\UI-QuestLog-Empty-TopLeft"> <Size x="256" y="256"/> <Anchors> <Anchor point="TOPLEFT"/> </Anchors> </Texture> <Texture file="Interface\QuestFrame\UI-QuestLog-Empty-BotLeft"> <Size x="256" y="84"/> <Anchors> <Anchor point="BOTTOMLEFT"/> </Anchors> <TexCoords left="0" right="1" top="0" bottom="0.65625"/> </Texture> <Texture file="Interface\QuestFrame\UI-QuestLog-Empty-TopRight"> <Size x="49" y="256"/> <Anchors> <Anchor point="TOPRIGHT"/> </Anchors> <TexCoords left="0" right="0.765625" top="0" bottom="1"/> </Texture> <Texture file="Interface\QuestFrame\UI-QuestLog-Empty-BotRight"> <Size x="49" y="84"/> <Anchors> <Anchor point="BOTTOMRIGHT"/> </Anchors> <TexCoords left="0" right="0.765625" top="0" bottom="0.65625"/> </Texture> </Layer> <Layer level="ARTWORK"> <FontString name="QuestLogNoQuestsText" inherits="GameFontHighlight" text="QUESTLOG_NO_QUESTS_TEXT"> <Size x="200" y="0"/> <Anchors> <Anchor point="CENTER" x="-6" y="16"/> </Anchors> </FontString> </Layer> </Layers> </Frame> <Frame parentKey="count" inherits="InsetFrameTemplate3"> <Size x="120" y="20"/> <Anchors> <Anchor point="TOPLEFT" x="132" y="-33"/> </Anchors> <Layers> <Layer level="ARTWORK"> <FontString parentKey="text" inherits="GameFontNormalSmall" text="Quests: 0/25"> <Anchors> <Anchor point="CENTER"/> </Anchors> </FontString> </Layer> </Layers> </Frame> <Button parentKey="mapButton"> <Size x="48" y="32"/> <Anchors> <Anchor point="TOPRIGHT" x="-24" y="-27"/> </Anchors> <Layers> <Layer level="ARTWORK"> <FontString name="$parentText" inherits="GameFontNormal" text="SHOW_MAP" parentKey="text"> <Anchors> <Anchor point="RIGHT" relativePoint="LEFT" x="0" y="0"/> </Anchors> </FontString> </Layer> </Layers> <NormalTexture file="Interface\QuestFrame\UI-QuestMap_Button"> <TexCoords left="0.125" right="0.875" top="0" bottom="0.5"/> </NormalTexture> <PushedTexture file="Interface\QuestFrame\UI-QuestMap_Button"> <TexCoords left="0.125" right="0.875" top="0.5" bottom="1.0"/> </PushedTexture> <HighlightTexture file="Interface\Buttons\ButtonHilight-Square" alphaMode="ADD"> <Size x="36" y="25"/> <Anchors> <Anchor point="RIGHT" x="-7" y="0"/> </Anchors> </HighlightTexture> <Scripts> <OnClick> QuestGuru:ShowMap() </OnClick> </Scripts> </Button> <!-- the actual log scrollFrame in left panel --> <ScrollFrame parentKey="scrollFrame" name="QuestGuruScrollFrame" inherits="HybridScrollFrameTemplate"> <Size x="305" y="403"/> <Anchors> <Anchor point="TOPLEFT" x="6" y="-64"/> </Anchors> <Layers> <Layer level="BACKGROUND"> <Texture parentKey="top" file="Interface\PaperDollInfoFrame\UI-Character-ScrollBar"> <Size x="29" y="102"/> <Anchors> <Anchor point="TOPLEFT" relativePoint="TOPRIGHT" x="-6" y="5"/> </Anchors> <TexCoords left="0" right="0.445" top="0" bottom="0.4"/> </Texture> <Texture parentKey="bottom" file="Interface\PaperDollInfoFrame\UI-Character-ScrollBar"> <Size x="29" y="106"/> <Anchors> <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMRIGHT" x="-6" y="-2"/> </Anchors> <TexCoords left="0.515625" right="0.960625" top="0" bottom="0.4140625"/> </Texture> <Texture file="Interface\PaperDollInfoFrame\UI-Character-ScrollBar"> <Size x="29" y="1"/> <Anchors> <Anchor point="TOP" relativeKey="$parent.top" relativePoint="BOTTOM"/> <Anchor point="BOTTOM" relativeKey="$parent.bottom" relativePoint="TOP"/> </Anchors> <TexCoords left="0" right="0.445" top=".75" bottom="1.0"/> </Texture> </Layer> <Layer level="BORDER"> <Texture parentKey="BG" file="Interface\QuestFrame\QuestBookBG"> <Anchors> <Anchor point="TOPLEFT" x="0" y="1"/> <Anchor point="BOTTOMRIGHT" x="-2" y="-2"/> </Anchors> <TexCoords left="0" right="0.5859375" top="0" bottom="0.65625"/> </Texture> </Layer> </Layers> <Frames> <!-- expand/collapse all button --> <Button parentKey="expandAll"> <Size x="64" y="32"/> <Anchors> <Anchor point="BOTTOMLEFT" relativePoint="TOPLEFT" x="48" y="0"/> </Anchors> <Layers> <Layer level="BACKGROUND"> <Texture file="Interface\QuestFrame\UI-QuestLogSortTab-Left"> <Size x="8" y="32"/> <Anchors> <Anchor point="LEFT"/> </Anchors> </Texture> <Texture file="Interface\QuestFrame\UI-QuestLogSortTab-Right"> <Size x="8" y="32"/> <Anchors> <Anchor point="RIGHT"/> </Anchors> </Texture> <Texture file="Interface\QuestFrame\UI-QuestLogSortTab-Middle"> <Size x="0" y="32"/> <Anchors> <Anchor point="LEFT" x="8" y="0"/> <Anchor point="RIGHT" x="-8" y="0"/> </Anchors> </Texture> </Layer> </Layers> <!-- quest title/header normalText is shifted to right 20 --> <ButtonText parentKey="normalText" text="ALL"> <Size x="0" y="10"/> <Anchors> <Anchor point="LEFT" x="28" y="-4"/> </Anchors> </ButtonText> <NormalTexture file="Interface\Buttons\UI-MinusButton-UP"> <Size x="16" y="16"/> <Anchors> <Anchor point="LEFT" x="11" y="-4"/> </Anchors> </NormalTexture> <HighlightTexture file="Interface\Buttons\UI-PlusButton-Hilight" alphaMode="ADD"> <Size x="16" y="16"/> <Anchors> <Anchor point="LEFT" x="11" y="-4"/> </Anchors> </HighlightTexture> <NormalFont style="GameFontNormalLeft"/> <HighlightFont style="GameFontHighlightLeft"/> <DisabledFont style="GameFontHighlightLeft"/> <Scripts> <OnClick> QuestGuru:ExpandAllOnClick() </OnClick> </Scripts> </Button> <Slider name="$parentScrollBar" inherits="HybridScrollBarTemplate" parentKey="scrollBar"> <Anchors> <Anchor point="TOPLEFT" relativePoint="TOPRIGHT" x="0" y="-13"/> <Anchor point="BOTTOMLEFT" relativePoint="BOTTOMRIGHT" x="0" y="14"/> </Anchors> <Scripts> <OnLoad> local name = self:GetName(); _G[name.."BG"]:Hide(); _G[name.."Top"]:Hide(); _G[name.."Bottom"]:Hide(); _G[name.."Middle"]:Hide(); self.doNotHide = true; </OnLoad> </Scripts> </Slider> <Frame parentKey="highlightFrame" hidden="true"> <Anchors> <Anchor point="TOPLEFT"/> <Anchor point="BOTTOMRIGHT"/> </Anchors> <Layers> <Layer level="ARTWORK"> <Texture parentKey="texture" file="Interface\QuestFrame\UI-QuestLogTitleHighlight" alphaMode="ADD"/> </Layer> </Layers> <Scripts> <OnLoad> self:SetParent(nil); </OnLoad> </Scripts> </Frame> </Frames> </ScrollFrame> <ScrollFrame parentKey="detail" name="QuestGuruDetailScrollFrame" inherits="QuestScrollFrameTemplate"> <Size x="298" y="403"/> <!-- was 403 --> <Anchors> <Anchor point="TOPRIGHT" x="-32" y="-63"/> </Anchors> <Layers> <Layer level="BACKGROUND"> <Texture parentKey="DetailBG" file="Interface\QuestFrame\QuestBG"> <Anchors> <Anchor point="TOPLEFT" x="-2" y="1"/> <Anchor point="BOTTOMRIGHT" x="1" y="-1"/> </Anchors> <TexCoords left="0" right="0.5859375" top="0" bottom="0.65625"/> </Texture> </Layer> </Layers> <ScrollChild> <Frame name="QuestGuruDetailScrollChildFrame"> <Size x="298" y="403"/> </Frame> </ScrollChild> </ScrollFrame> <Frame parentKey="optionsFrame" enableMouse="true" inherits="BasicFrameTemplateWithInset" hidden="true"> <Size x="220" y="208"/> <Anchors> <Anchor point="BOTTOM" relativeKey="$parent.options" relativePoint="TOP" x="0" y="0"/> </Anchors> <Frames> <CheckButton parentKey="UndockWindow" inherits="QuestGuruCheckButtonTemplate"> <Anchors> <Anchor point="TOPLEFT" x="16" y="-32"/> </Anchors> </CheckButton> <CheckButton parentKey="LockWindow" inherits="QuestGuruCheckButtonTemplate"> <Anchors> <Anchor point="TOPLEFT" relativeKey="$parent.UndockWindow" relativePoint="BOTTOMLEFT" x="16" y="-4"/> </Anchors> </CheckButton> <CheckButton parentKey="ShowResizeGrip" inherits="QuestGuruCheckButtonTemplate"> <Anchors> <Anchor point="TOPLEFT" relativeKey="$parent.LockWindow" relativePoint="BOTTOMLEFT" x="-16" y="-4"/> </Anchors> </CheckButton> <CheckButton parentKey="ShowLevels" inherits="QuestGuruCheckButtonTemplate"> <Anchors> <Anchor point="TOPLEFT" relativeKey="$parent.ShowResizeGrip" relativePoint="BOTTOMLEFT" x="0" y="-4"/> </Anchors> </CheckButton> <CheckButton parentKey="ShowTooltips" inherits="QuestGuruCheckButtonTemplate"> <Anchors> <Anchor point="TOPLEFT" relativeKey="$parent.ShowLevels" relativePoint="BOTTOMLEFT" x="0" y="-4"/> </Anchors> </CheckButton> <CheckButton parentKey="SolidBackground" inherits="QuestGuruCheckButtonTemplate"> <Anchors> <Anchor point="TOPLEFT" relativeKey="$parent.ShowTooltips" relativePoint="BOTTOMLEFT" x="0" y="-4"/> </Anchors> </CheckButton> </Frames> </Frame> </Frames> <Scripts> <OnLoad> self:RegisterEvent("PLAYER_LOGIN") </OnLoad> <OnEvent> self.OnEvent(self,event) </OnEvent> <OnShow> self.OnShow(self) PlaySound("igQuestLogOpen") </OnShow> <OnHide> self.OnHide(self) PlaySound("igQuestLogClose") </OnHide> <OnMouseDown> self:StartMoving() </OnMouseDown> <OnMouseUp> self:StopMovingOrSizing() </OnMouseUp> </Scripts> </Frame> </Ui>
__________________
"There's no such thing as too many addons." Lothaer My Authored Addons HOME OF THE FREE, BECAUSE OF THE BRAVE
|
|
10-12-16, 07:15 PM | #7 |
The immediate parent of your button is QuestGuru, so the globally accessible path to your button is QuestGuru.TrackButton:
/run QuestGuru.TrackButton:SetText("Test")
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
10-14-16, 05:07 AM | #8 |
Trying the above gave this error:
Code:
1x [string "QuestGuru.TrackButton:SetText("Test")"]:1: attempt to index field 'TrackButton' (a nil value) [string "QuestGuru.TrackButton:SetText("Test")"]:1: in main chunk [C]: in function `RunScript' FrameXML\ChatFrame.lua:2051: in function `?' FrameXML\ChatFrame.lua:4332: in function `ChatEdit_ParseText' FrameXML\ChatFrame.lua:4000: in function `ChatEdit_SendText' FrameXML\ChatFrame.lua:4036: in function `ChatEdit_OnEnterPressed' [string "*:OnEnterPressed"]:1: in function <[string "*:OnEnterPressed"]:1> Locals: (*temporary) = nil (*temporary) = nil (*temporary) = nil (*temporary) = "attempt to index field 'TrackButton' (a nil value)"
__________________
"There's no such thing as too many addons." Lothaer My Authored Addons HOME OF THE FREE, BECAUSE OF THE BRAVE
|
|
10-17-16, 05:09 PM | #9 |
This is from the XML you posted:
Code:
<Frame name="QuestGuru" parent="UIParent" ...> ... <Frames> ... <Button parentKey="TrackButton" inherits="MagicButtonTemplate" text="TRACK_QUEST_ABBREV"> The only ways that "QuestGuru.TrackButton" can be nil are: 1. The code you posted is not your real code. 2. Some other code (that you didn't post) overrides the "QuestGuru" global with some other object that isn't the frame created by your XML, so there's no longer any global reference to the frame or anything (like the button) attached to it. Again, this is why you should post your entire, actual code when you're asking for help. It doesn't matter if it's 50 lines or 50,000,000 lines -- we're not going to read through every line, we're going to search for specific parts that are related to the issue at hand. Without being able to do that, all we can do is throw out random guesses that may or may not be useful. The only difference between 50 lines and 50,000,000 lines is that you should not embed the latter in a forum post; use pastebin or gist for longer pieces of code.
__________________
Retired author of too many addons. Message me if you're interested in taking over one of my addons. Don’t message me about addon bugs or programming questions. |
|
10-25-16, 08:08 PM | #10 |
Thanks for all of your help, especially Phanx. They code I posted above was directly from my addon. Next time I will postman or github them. For any wanting to know how I fixed it, posting below:This first section checks whether a quest is tracked and if so, untracked it. or just the opposite if is not tracked.
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) QuestGuru.Track:SetText("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) QuestGuru.Track:SetText("UnTrack") end end end end and second section changes the button to Track/UnTrack depending if the quest is tracked or not: Code:
function qgc:SelectQuestIndex(index) SelectQuestLogEntry(index) StaticPopup_Hide("ABANDON_QUEST") StaticPopup_Hide("ABANDON_QUEST_WITH_ITEMS") SetAbandonQuest() if ( index == 0 ) then qgc.selectedIndex = nil QuestGuruDetailScrollFrame:Hide() elseif index>0 and index<=GetNumQuestLogEntries() and not select(4,GetQuestLogTitle(index)) then QuestGuruDetailScrollFrame:Show() QuestInfo_Display(QUEST_TEMPLATE_LOG, QuestGuruDetailScrollChildFrame) QuestGuruDetailScrollFrameScrollBar:SetValue(0) -- scroll to top end if IsQuestWatched(index) then -- already watched, remove from watch QuestGuru.Track:SetText("UnTrack") else -- not watched, see if there's room to add, add if so QuestGuru.Track:SetText("Track") end qgc:UpdateLogList() end I thought this might be handy for others that may want a button to change depending on what is needed. Cheers!
__________________
"There's no such thing as too many addons." Lothaer My Authored Addons HOME OF THE FREE, BECAUSE OF THE BRAVE
|
|
11-01-16, 11:16 PM | #11 | |
__________________
Garrison Mission Manager |
||
11-03-16, 12:24 PM | #12 |
Just confirmed this.
Lua Code:
Lua Code:
__________________
Garrison Mission Manager |
|
WoWInterface » Developer Discussions » Lua/XML Help » setText or setFormattedText or ? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|