Clear Button Texture and Text LUA Help
I am making an addon that creates buttons for the Sentinax beacons in your bags. I have it complete, except I cannot figure out how to iteratively clear and then refresh the button texture and text (for item count).
Maybe I am using the wrong template and or am missing something obvious. I always have trouble with refreshing text. Here is code that works in game, you can copy/paste into a test addon, and it puts the buttons on your screen in the middle. Head to a vendor and sell a beacon, or go in the field and loot some. It will make new frames fine. But if the count changes it wont clear the previous text so there is, for example, a 2 on top of a 3 when you use it. The same is true for the textures. Any help is appreciated. Cheers! Code:
--Beam Me Up Deja Initialization Frame |
I don't see where you check if a button already exists. Every OnEvent seems to trigger the creation of a new set of buttons for each specified item found.
|
You're code re-creates your buttons constantly, which would cause massive error junk when you loot beacons right in combat....
It would be much better to pre-create all necessary buttons and only handle the count text upon bag updates. Here is a little example on how it would look like: Lua Code:
The buttons in this example are static and do not hide / show themselves properly, but this is further secure wrapping.... PS: beacons are not stackable, as far as i'm aware |
Quote:
This isn't the entire code. I am not trying to show or hide them in combat, there is an inCombat check for a button that shows or hides them all that does nothing in combat. They do indeed stack.:) to 20 as per itemStackCount = GetItemInfo() Thank you for taking the time. I appreciate it very much. Let me know if you have any ideas about creating them as a loop. Gah I really don;t want to make static tables for this ;/ |
Quote:
Code:
if ((_G["BMUDButtonFS"..name])~=nil) then Yeah, BAG_UPDATE event fires a billion times and is more of a debugging event that i can use at a vendor to sell and rebuy my beacons to see if this works. Thanks for taking the time. Let me know if you think of anything else :) |
Quote:
if BAG_UPDATE fires a billion times your code will have created a billion new buttons and fontstrings. Rather than this, you need to check if a button of the same name exists before you create a new one: Code:
local BMUDButton |
Quote:
What do I do to reset the buttons? I have tried myriad solutions, none work. Quote:
Code:
_G["BMUDButton"..name]:SetNormalTexture(nil,"ARTWORK") |
Something like this:
Lua Code:
EDIT: If the textures aren't going to change for each button then you wouldn't need to set them to nil and then re-set them, just the text value. This also doesn't cover buttons created for beacons you no longer have. This would require either keeping a table of buttons created or checking for buttons created for beacons you don't have. |
Quote:
This does exactly what I have already tried. It does not reset the text or the textures after the first creation. |
See the last edit in the last post.
Make sure you're seeing what event last happened so you know if the button should or should not be visible. Change the bag code too: Code:
if event == "BAG_UPDATE" then -- only set textures and text for this event |
Just as a note, the code will only show the number of beacons of a type in the last bag slot with that type inspected. I haven't really played 7.2 so if you can only hold one beacon in a slot or you can have more than one slot with one type of beacon, then you will only ever see one or the quantity in the last slot checked holding the item.
|
Quote:
Quote:
Now to work on getting the textures to update after BAG_UPDATE like they do with a UI reload. Thanks for the help. Any ideas on textures? Is that not possible becasue frames persist until reload? Any way to recycle the frames? Hmmm. |
As beacons do not stack and consume an inventory slot each, you don't have to care about stackCount at all.
So you can raise your beacon count by 1 every time that particular beacon is found. Why do you want to update the textures at all? The buttons are named by the beacons name, so they are not be recycled anyway. And a beacon's icon is static and doesn't get changed by blizzard. |
Quote:
You may also be having trouble with positioning. If you /fstack over the buttons you'll probably find you have a bunch of "BMUDButton"..xxx buttons positioned over the top of each other. Edit: Thanks syncrow. You will need to keep a tally rather than just using the last itemCount value for the text. The recycle code Lua Code:
|
Quote:
I want to completely hide the button and have them collapse so that you do not have spaces where you do not have beacons. If I have two beacons I want to show them, If I then use one I want it to disappear. Then if I get a third one I want it to appear next to the one I still have, not leave a space and appear two or three icon spaces next to it, leaving empty space. |
Quote:
-- BMUDButton points to a shiney new button or -- BMUDButton points to the previously created button I get the concept. What the hell is the syntax? What you have so far works great. But once I have a button and use it and no longer have the beacons, the button persists. No event will remove it. Any ideas? |
This is what I pointed out previously, in edit admittedly so you may have missed it.
One idea. Keep a table of buttons as they are created (no pre-determined, fixed table needed), hide them all at the start of the event and only show the ones that actually have a count on any given pass. One idea, there may be better and it probably need refining. |
Quote:
|
This should handle hiding/showing (admitedly untested), collapsing/expanding would still have to be handled:
Lua Code:
There is now code that is surplus to requirements ;) |
you could use "ContainerFrameItemButtonTemplate" instead of "SecureActionButtonTemplate".
pros:
cons:
Edit: I'm going to prepare some code and explanation for you later... currently at work!^^ |
Quote:
Cheers! |
ok here is the code: (everything is tested, and should be properly debugged)
Lua Code:
Note: - Buttons are ordered from left to right, and from top to bottom (can be changed on line 129 - switch math operators for x / y) |
Quote:
https://mods.curse.com/addons/wow/265345-beammeupdeja Cheers! |
For this particular use, since you are scanning the bag anyway, I would recommend using the event BAG_UPDATE_DELAYED instead of BAG_UPDATE.
|
Quote:
|
Quote:
|
Quote:
Edit: @Deja, i would also recomment, using my code seperately instead of calling it inside a OnEvent function, the created frame was simply renamed by me but should be used as your initFrame... |
Thanks, after posting thought something similar, and found in ItemButtonTemplate.xml that it's indeed defined.
|
I'm going to hard test the complete addon on Friday.
Should I upload a new beta version on curse once debugged and changes made? |
Quote:
|
In line 54 probably a typo: instead of variable "texture" non-existant "tex" was used.
Removed external BeamMeUpDejaInitFrame. Don't know why but for item count updates to work, had to use CreateFontString in CreateButton. Modified version sent to Deja. Probably there's still much to fix/improve. |
Begun fixing the beacon bar part:
By the way, searching for names rather than using predefined itemIDs like mentions in my first solution, will be an issue for non english clients Except we want to handle each localization manually... |
Quote:
Code:
if name and name:find("Sentinax Beacon" or "Netherchunck") then We also need to query other items, like nether shards and boss summon stones. This is going to require tables... bleh. As for localization, we could simply search for local names, making our list, ostensibly, smaller, adding them to the table for Chinese, Russian, Portuguese, etc. But you are correct that we wont have to worry about localization if we use item IDs. |
Quote:
simply loop through the currency list and get your information I don't know what really speaks against a table that we want to use for tracking - localization friendly - can be maintained updated super easily by just adding / removing itemIDs - we can throw updates without touching anything besides the itemID table for new items to track... |
Quote:
So the project went from looking for three names to looking for 33 names across 11 locales. May as well just look for IDs instead. |
Deja,
how do you want the beacon bar to be displayed exactly?
[Rare Beacons] [Uncommen Beacons] [Other Items] Static layout: [X][X][X][X][X][X][X][X][X] [X][X][X][X][X][X] [X][X][X] dynamic: (#15 - live) [X][X][X][X][X][X] [X][X][X][X][X][X] [X][X][X][X][X][X] mixed 1: [X][X][X][X][X][X] [X][X][X][X][X][X] [X][X][X][X][X][X] mixed 2: [X][X][X][X][X] [X][X][X][X][X] [X][X][X][X][X] [X][X][X] |
I think ability to detect new Sentinax Beacons is interesting. Requirement to localize the search string - not so much. Therefore maybe some fuzzy detector whether or not this item is Sentinax Beacon can be written. Using currently known Sentinax Beacons a common string with maximal length could be calculated and used for searching.
Previously thought of more exotic ways of creation of the search string but currently think this is more or less plausible compared to others. |
broken shore stuff would be a thing till 7.3 then everything will to argus, so could bet that no new beacon or any new broken shore grind related item will be added after 7.2.5 launch
and even when...add 2 spellIDs throw update, fix and everything is happy. You simply cant prevent addons to be updated from time to time, but that is just my standpoint |
Indeed, in this specific example creation of search string through combinatorics is overkill. I was just surprised by possibility of automation of creation of feature extractor, as an input using few items.
But really, adding of few itemIDs after discovery of the new elusive Sentinax Beacons would be much easier. |
I want the layout to be static rarity rows that are dynamically created, i.e. collapse as created for each rarity per row.
[X][X][X] -- Netherchunk and Zone portals(see below) [X][X] -- Epic [X][X] -- Crafting Rare [X][X][X][X] -- Rare [X][X][X][X][X][X] -- Uncommon __________________________________________ Netherchunk and Zone portals(see below) Epic: [146921] = "", -- Illisthyndria [146920] = "", -- Fel Obliterator [146919] = "", -- An'thyna:An'thyna [146918] = "", -- Force-Commander Xillious [146917] = "", -- Skulguloth [146916] = "", -- Than'otalion Crafting Rare: [147355] = "", -- bloodstrike [146923] = "", -- petrification [146922] = "", -- fel growth Rare: [146915] = "", -- greater torment [146914] = "", -- greater engineering [146913] = "", -- greater warbeasts [146912] = "", -- greater carnage [146911] = "", -- greater firestorm [146910] = "", -- greater dominance Uncommon: [146909] = "", -- torment [146908] = "", -- engineering [146907] = "", -- warbeasts [146906] = "", -- carnage [146905] = "", -- firestorm [146903] = "", -- dominance _____________________ Zone portals are rare(IIRC they are Epic). They open a portal in a zone, like Skyhorn in Highmountain. You go there, click it and a portal opens with aq miniboss. You kill it and loot exactly 300 Nethershards. I have had 2 drop, went and did them, but have not seen any since. Others can help you kill the boss but they do not get loot AFAIK. That being said, I forget what their name is and my google/WoWHead - fu has failed me to bring up their names. At any rate, the very top row should be consumable you want to use right away, like Netherchunk and these zone portals. |
Hey Syncrow, any progress? If you are crunched for time, I can work on rewriting for tables, I just need help figuring out resetting the text.
Cheers! |
Pretty much no time these days, sry
|
Quote:
Here is the project on WoWInterface and on Curse in case you missed it. Cheers! |
All times are GMT -6. The time now is 07:46 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI