WoWInterface SVN Ranch

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 5 to Rev 6
    Reverse comparison

Rev 5 → Rev 6

trunk/ranch.lua
9,15 → 9,54
RanchGameTip:CreateFontString( "$parentTextLeft1", nil, "GameTooltipText" ),
RanchGameTip:CreateFontString( "$parentTextRight1", nil, "GameTooltipText" )
);
ranch_temp = {}
 
 
function Ranch_Command(slashargs)
local startPos, endPos, firstWord, restOfString = string.find(slashargs, "(%w+)[%s%p]*(.*)");
firstWord = strlower(firstWord)
if firstWord == "track" then
ranchtrack = restOfString
if restOfString == "" or restOfString == nil then
ranchtrack = nil
else
ranchtrack = restOfString
end
elseif firstWord == "temp" then
ranch_temp[Ranch_ItemID(restOfString)] = true
elseif firstWord == "add" then
if restOfString ~= nil and restOfString ~= "" then
local itemID = Ranch_ItemID(restOfString)
ranch_perm[ItemID] = true
end
elseif firstWord == "remove" then
if restOfString ~= nil and restOfString ~= "" then
local itemID = Ranch_ItemID(restOfString)
local temptable = {}
local k,v
for k,_ in pairs(ranch_perm) do
if k ~= itemID then
temptable[k] = true
end
end
ranch_perm = temptable
temptable = nil
end
elseif firstWord == "removeall" then
ranch_perm = {}
end
end
 
function Ranch_ItemID(itemLink)
local found, _, itemString = string.find(itemLink, "^|c%x+|H(.+)|h%[.*%]")
if itemString == nil then
found, _, itemString = string.find(itemLink, "^c%x+|H(.+)|h%[.*%]")
end
if itemString == nil then
return nil
else
local _, itemId, enchantId, jewelId1, jewelId2, jewelId3, jewelId4, suffixId, uniqueId = strsplit(":", itemString)
return itemId
end
end
 
SLASH_RANCH1 = "/ranch"
SlashCmdList["RANCH"] = Ranch_Command;
37,12 → 76,11
local ContainerItemLink = GetContainerItemLink(i,j)
if ContainerItemLink ~= nil then
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(ContainerItemLink)
local itemId = Ranch_ItemID(itemLink)
if itemType == "Trade Goods" then
if ranch_items[itemSubType] == nil then
ranch_items[itemSubType] = {}
end
local found, _, itemString = string.find(itemLink, "^|c%x+|H(.+)|h%[.*%]")
local _, itemId, enchantId, jewelId1, jewelId2, jewelId3, jewelId4, suffixId, uniqueId = strsplit(":", itemString)
if ranch_items[itemSubType][itemId] == nil then
ranch_items[itemSubType][itemId] = GetItemCount(itemLink)
end
62,6 → 100,10
ranch_boe[itemLink] = GetSellValue(itemLink)
end
end
 
if ranch_temp[itemId] ~= nil then
ranch_temp[itemId] = GetItemCount(itemLink)
end
end
end
end
84,7 → 126,29
self:AddDoubleLine(itemLink,itemCount)
end
end
 
if Ranch_tcount(ranch_perm) > 0 then
self:AddLine(" ")
self:AddLine("Custom")
local i,v
for i,v in pairs(ranch_perm) do
if v then
local _, itemLink = GetItemInfo(i)
self:AddDoubleLine(itemLink, GetItemCount(itemLink))
end
end
end
 
if Ranch_tcount(ranch_temp) > 0 then
self:AddLine(" ")
self:AddLine("Temporary")
local i,v
for i,v in pairs(ranch_temp) do
local _, itemLink = GetItemInfo(i)
self:AddDoubleLine(itemLink, GetItemCount(itemLink))
end
end
 
if ranch_junk then
self:AddLine(" ")
local textcash
98,9 → 162,6
end
self:AddDoubleLine("Junk:", textcash)
end
if ranchtrack ~= nil then
dataobj.text = ranchtrack.." - "..GetItemCount(ranchtrack)
end
end
 
function Ranch_FormatCash(cash)
116,4 → 177,27
end
textcash = textcash.."|cFFFFFFFF"..copper.."|r|cffeda55fc|r"
return gold, silver, copper, textcash
end
\ No newline at end of file +end + +function Ranch_BAG_UPDATE(...) + if ranchtrack ~= nil then + dataobj.text = "|r|"..ranchtrack.." - "..GetItemCount(ranchtrack) + else + dataobj.text = "Ranch" + end +end + + -- tcount: count table members even if they're not indexed by numbers + -- From the Table Helpers page by Mikk on WoWWiki (http://www.wowwiki.com/Table_Helpers) + function Ranch_tcount(tab) + local n=0; + for _ in pairs(tab) do + n=n+1; + end + return n; + end + + +local frame = CreateFrame("Frame", "RanchFrame"); +frame:SetScript("OnEvent", function(self, event, ...) getglobal("Ranch_"..event)(event, ...) end); +frame:RegisterEvent("BAG_UPDATE"); \ No newline at end of file
trunk/ranch.toc
3,6 → 3,6
## Notes: Keeps track of items you've farmed.
## Author: Sekrin@Argent Dawn-EU
## Version: 1.0.wowi:revision
## SavedVariablesPerCharacter: ranch_items, ranch_options
## SavedVariablesPerCharacter: ranch_perm, ranch_options
 
ranch.lua
\ No newline at end of file