Quantcast
WoWInterface: SVN - fernir_UI - Rev 2 - /helpers.lua

WoWInterface SVN fernir_UI

[/] [helpers.lua] - Rev 2

Compare with Previous | Blame | View Log

--[[     Options start here     ]]
-- "true" means enabled, "false" means disabled
local AutoGreedOnGreen = false       -- Should all be green items automatically rolled "greed" in groups and raids?
local AutoRepair = true             -- Auto repair all equipment upon visiting vendor + print repair cost info.
local SellGreyCrap = true           -- Sell all grey items to vendor automatically.
local AcceptInvites = true          -- Accept party invites from frieds and guild members
local NoErrors = false               -- Hide all erros from UIErrorsFrame

local raidaddons = {    -- Addons you use only in raids or groups
    "BigWigs",
    "oRA2",
    "SimpleRaidTargetIcons",
    "Scada",
}

local pvpaddons = {     -- Addons you use only in arenas or BGs. Nothing here since i rarely do PvP =)
    "Gladius",
    "Capping",
}

--[[ Clear UIErrors frame ]]
UIErrorsFrame:SetScale(0.8)
--CalendarFrame:SetScale(0.8)
if(NoErrors==true) then UIErrorsFrame:UnregisterEvent("UI_ERROR_MESSAGE") end


WatchFrameTitle:SetAlpha(0)

local p1, p2, p3, p4, p5 = WatchFrameCollapseExpandButton:GetPoint()
WatchFrameCollapseExpandButton:ClearAllPoints()
WatchFrameCollapseExpandButton:SetPoint(p1, p2, p3, p4 - 15, p5)

local a, b, c, d, e = RaidFrameNotInRaidRaidBrowserButton:GetPoint() 
RaidFrameNotInRaidRaidBrowserButton:SetPoint(a, b, c, d, e - 25)


-- Disabled WoW's combat log at startup
-- local f = CreateFrame("Frame")
-- f:SetScript("OnEvent", function()  
    -- f:UnregisterEvent("COMBAT_LOG_EVENT")
    -- COMBATLOG:UnregisterEvent("COMBAT_LOG_EVENT")
-- end)
-- f:RegisterEvent("COMBAT_LOG_EVENT")


--[[ Changing some variables ]]
SetCVar("screenshotQuality", 10)
SetCVar("cameraDistanceMax", 50)
SetCVar("cameraDistanceMaxFactor", 3.4)


--[[ Autogreed on green items ]]
if(AutoGreedOnGreen==true) then
    local f = CreateFrame("Frame")
    f:RegisterEvent("START_LOOT_ROLL")
    f:SetScript("OnEvent", function(_, _, id)
        if(id and select(4, GetLootRollItemInfo(id))==2) then
            RollOnLoot(id, 2)
        end
    end)
end

--[[ Accept invites ]]
if(AcceptInvites==true) then
    local IsFriend = function(name)
        for i=1, GetNumFriends() do if(GetFriendInfo(i)==name) then return true end end
        if(IsInGuild()) then for i=1, GetNumGuildMembers() do if(GetGuildRosterInfo(i)==name) then return true end end end
    end

    local ai = CreateFrame("Frame")
    ai:RegisterEvent("PARTY_INVITE_REQUEST")
    ai:SetScript("OnEvent", function(frame, event, name)
        if(IsFriend(name)) then
            AcceptGroup()
            for i = 1, 4 do
                local frame = _G["StaticPopup"..i]
                if(frame:IsVisible() and frame.which=="PARTY_INVITE") then
                    frame.inviteAccepted = 1
                    StaticPopup_Hide("PARTY_INVITE")
                    return
                end
            end
        else
            SendWho(name)
        end
    end)
end

local module = CreateFrame("Frame",nil,UIParent)
 
local sells,tmp_money = 0,0
 
-- íîðìàëüíûé ôîðìàò âûâîäà äåíåã
 
local money_format = function(val)
   return format("|cffffd700%dg|r |cffc7c7cf%ds|r |cffeda55f%dc|r",mod(val/10000,10000),mod(val/100,100),mod(val,100))
end
 
module.MERCHANT_SHOW = function(self)
    if (AutoRepair==true) then
    -- ÷èíèìñÿ  
     
       if (CanMerchantRepair()) then
          local cost,money = GetRepairAllCost(),GetMoney()
          if cost > 0 then
             RepairAllItems()
             print(string.format("repairing cost : %s",money_format(math.min(cost, money))))
          end
       end
    end

    if (SellGreyCrap==true) then
    -- ïðîäàåì ìóñîð
     
       local bag,slot 
       tmp_money = GetMoney() 
       for bag = 0,4 do
          if GetContainerNumSlots(bag) > 0 then
             for slot = 0, GetContainerNumSlots(bag) do
                local link = GetContainerItemLink(bag,slot)
                if(link) then
                   local _,_,i_rar=GetItemInfo(link)
                   if i_rar == 0 then
                      UseContainerItem(bag,slot)
                      sells = sells+GetItemCount(link)
                   end
                end
             end
          end
       end
    end
end

module.PLAYER_MONEY = function(self)
   if(sells>0) then
      print(string.format("sold %d items for %s",sells,money_format(GetMoney()-tmp_money)))   
      sells = 0
   end
end
 
-------------------------------------------------------------------------------------------------------------
 
module:SetScript("OnEvent",function(self,event,...) self[event](self,event,...) end)
 
module:RegisterEvent("MERCHANT_SHOW")
module:RegisterEvent("PLAYER_MONEY")

Compare with Previous | Blame