View Single Post
01-14-10, 04:30 PM   #58
wurmfood
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 122
The key to adding bags is in the filter section and in the right order.

cargBags_Nivaya keeps the info in two places. In filters.lua you have the basic filters which then get applied in cargBags_Nivaya.lua and some descriptions in localization.lua.

Assuming you want to do it right, I'd start out in localization.lua. Here, I'd start with adding 'cBinvL.Mining = "Mining"' after the bullet entry, and then add '["cBinv_Mining"],' after the new items entry. Do something similar for JC.

Next we head over to filters.lua. I'd add these just after the Trade Goods filter in here, but that's just to keep them ordered in my mind. I don't think they have to go in any order here.

Our first filter is going to be for mining. The first few lines for a filter in Nivaya look to be pretty common (ignoring the config option). A basic filter looks like this:
Code:
cB_Filters.fMining = function(item)
  local tC = cBniv_CatInfo[item.name]
  if tC then return (tC == "cBinv_Mining") and true or false end
  return (item.type and item.type == L.Trades) and (item.subType == "Metal & Stone")
end
The subType info comes from http://www.wowwiki.com/ItemType.

Then create something similar for JC.

Now we get to the fun part. Something important about cargBags is that when it processes the filters it does so in a particular order. The first filter it comes across that matches the item is where it is placed. This means that if we put our above filters after the trade goods filter, they'll only ever be placed in trade goods.

The order of the filters seems to be around lines 64 - 153 of cargBags_Nivaya.lua. We see the trade goods bag appears at 144 - 147, so let's put our new bags just before that and after Consumable. Since filters appear to be applied in order of the bags, this should work for us.

The format for the bags is very simple. The mining bag should look something like this:
Code:
local t = cargBags:Spawn("cBinv_Mining") -- from localization.lua
t:SetFilter(cB_Filters.fMining, true) -- from the filter we created
cB_Bags.mining = t -- creating a new bag for the stuff
Again, do the same for JC.

Finally, we place the bag by anchoring it to something else. While you can place it where you want, I'll put it under the quest items.

The function to use here is called out at line 159 (note, all line numbers are before changes) and is really simple: CreateAnchorInfo(bag we anchor to, bag we want to anchor, source bag anchor point). So, if we want to attach our bag to the bottom of something, it appears to be "CreateAnchorInfo(cB_Bags.bagStuff, cB_Bags.mining, "Top")". If we put that in after the last CreateAnchorInfo line, you should be good.

Now, I haven't tested this, but it should work with only minimal debugging. Hopefully there was enough explanation there to help.
  Reply With Quote