Thread Tools Display Modes
10-27-05, 05:44 PM   #1
vincentgdg
A Murloc Raider
Join Date: Sep 2005
Posts: 8
waiting for something

Hello.

I am just working on my first addon, called Restack.
What it shall do is restacking stackable items in your bags to the maximum possible stacksize.
You all know that when you get plenty of the same items through mail or the bank they don't stack but each stack takes its own place in your bags.

My addon scans the bags for identical items and puts them together in stacks when possible.

So far the addon works, but there is a problem with the timing.

Lets say you have 7, 3 and 2 stacks of the same item.
My addon does a PickupContainerItem(BagNum,SlotNum) first with the stack to move and then with the stack to put it on to. This is in a loop for each stack.

But it does that too fast with the second stack and WoW ignores it.

What can I do to somehow wait until WoW is ready to take on the next action?

Regards
Thomas
  Reply With Quote
10-28-05, 02:17 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
You can register for the BAG_UPDATE and check if there are any "locked" items in bags, and if not then do another consolidate pass.

Another method is to create an OnUpdate that turns on at a BAG_UPDATE event and counts out a second before running a consolidate pass (then hides itself so it doesn't run until next BAG_UPDATE).

It's worth mentioning that BAG_UPDATE can happen a lot. Literally hundreds of times when you log in or zone. So you'll want to make sure it doesn't do anything lengthy in response to every BAG_UPDATE.

edit: This mod: http://www.wowinterface.com/download...php?s=&id=4118 has some of what you're looking for. Look for the words 'Consolidate' in its lua and 'WaterboyBagUpdateFrame' in its xml. You're welcome to take parts of it and use as your own or do whatever you want with it. It does the second OnUpdate approach above. Your mod sounds really useful good luck with it

Last edited by Gello : 10-28-05 at 02:29 AM.
  Reply With Quote
10-29-05, 02:39 PM   #3
vincentgdg
A Murloc Raider
Join Date: Sep 2005
Posts: 8
Thanks

Hello agan. :-)

Thanks to Gello's Waterboy and some help from Rowne I managed to put together a working version of my "Restack".

I had to program around some very strange things. One was that the event BAG_UPDATE is fired on login before the name of all bags are even known, so my counting of free slots was wrong the first few seconds. Now I wait for 5 secs before my addon reacts on an event. :-)
Another thing was that the function PickupContainerItem() sometimes does not drop the item the client is holding, so I check this and if it is the case I just do another drop onto the next free slot I find. Funny thing is that the item is then dropped onto the correct slot it was meant to be dropped, I don't know why. But as it works, I don't care. :-)

What the addon does until now is the following:

It takes a minimum of wanted free slots (default is 1, it is changeable via slash command).

Whenever a BAG_UPDATE is fired, it waits for 0.5 secs to see if there is another event coming.

If there isn't another event it checks if the free slots are less than the wanted amount.
If this is the case it starts a restacking with the first restackable item found twice while scanning the bags. Then it stops and waits for another OnUpdate event to continue until the amount of wanted free slots is reached.

This even works with MailLoot, the addon with the fastest pushing of items into the bags I know.

Of couse you can also start the restacking manually by entering "/restack go".

One thing I have in mind to add is not restacking, but splitting of certain items into stacks with a chooseable stack size like 1, when you want to split stacks to sell them at the AH.

I have yet to think about how to do this. I could do a "/restack <item> <stack size>" or store a wanted maximum stack size for each item and split them automatically when /restack is called.

What do you think would be the better way?

After a bit more testing I will put this addon on the various addon sites.

Regards
Thomas
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » waiting for something

Thread Tools
Display Modes

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