Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created April 17, 2010 13:53
Show Gist options
  • Save cowboy/369555 to your computer and use it in GitHub Desktop.
Save cowboy/369555 to your computer and use it in GitHub Desktop.
-- OLD, but amusing nonetheless
-- http://www.wowinterface.com/downloads/info6813-CowboysMasterBaiter.html
-- INIT
CB_MB = {};
CB_MB.Version = "20006.003";
function CB_MB:OnLoad()
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("PLAYER_LOGIN");
this:RegisterEvent("UNIT_INVENTORY_CHANGED");
self:Trace("Cowboy's Master Baiter "..self.Version.." Loaded!", 1);
end
-- EVENTS
function CB_MB:OnEvent(event, arg1)
if event == "VARIABLES_LOADED" then
if not CB_MB_DB then
CB_MB_DB = {};
end
if not CB_MB_DB.config then
CB_MB_DB.config = {["loot"] = true, ["audio"] = true};
end
if CB_MB_DB.version ~= self.Version then
CB_MB_DB.version = self.Version;
self:PrintUsage(true);
end
SlashCmdList["CB_MB"] = function(arg)
CB_MB:Do(arg);
end
SLASH_CB_MB1 = "/cbmb";
SLASH_CB_MB2 = "/cowboysmasterbaiter";
SLASH_CB_MB3 = "/cowboysmasturbater"; -- heh
self:SetFishingMode(true);
elseif event == "PLAYER_LOGIN" then
self:SetFishingMode();
elseif event == "UNIT_INVENTORY_CHANGED" and arg1 == "player" then
self:SetFishingMode();
end
end
-- DO STUFF
function CB_MB:SetFishingMode(Force)
local mainHandLink = GetInventoryItemLink("player", GetInventorySlotInfo("MainHandSlot"));
local _,_,itemCode = strfind(mainHandLink or "", "(%d+):");
local _,_,_,_,_,_,itemSubType = GetItemInfo(itemCode or "");
local was = self.fishingmode;
self.fishingmode = itemSubType == "Fishing Pole";
if self.fishingmode ~= was or Force then
self:SetAutoLootDefault(self.fishingmode);
self:SetEnhanceAudio(self.fishingmode);
self:Trace("Fishing mode "..(self.fishingmode and "Enabled" or "Disabled"));
end
end
function CB_MB:SetAutoLootDefault(state)
if CB_MB_DB.config.loot then
SetAutoLootDefault(state);
end
end
function CB_MB:SetEnhanceAudio(state)
if CB_MB_DB.config.audio then
if state and not CB_MB_DB.audio then
local enhanced = {["SoundVolume"] = 1.0, ["MusicVolume"] = 0.0, ["AmbienceVolume"] = 0.0};
CB_MB_DB.audio = {};
for k, v in pairs(enhanced) do
CB_MB_DB.audio[k] = GetCVar(k);
SetCVar(k, v);
end
elseif not state and CB_MB_DB.audio then
for k, v in pairs(CB_MB_DB.audio) do
SetCVar(k, v);
end
CB_MB_DB.audio = nil;
end
end
end
-- OPTIONS
function CB_MB:Trace(text, noprefix)
DEFAULT_CHAT_FRAME:AddMessage("|c00ffc600"..(noprefix and "" or "CBMB: |c00ffffff")..text);
end
function CB_MB:Do(arg)
arg = string.lower(arg);
if arg == "loot" then
CB_MB_DB.config.loot = not CB_MB_DB.config.loot;
self:Trace("Auto-loot when fishing "..self:ShowConfig("loot"));
elseif arg == "audio" then
CB_MB_DB.config.audio = not CB_MB_DB.config.audio;
self:Trace("Auto-enhance audio when fishing "..self:ShowConfig("audio"));
else
self:PrintUsage();
end
end
function CB_MB:PrintUsage(FirstUse)
self:Trace("Cowboy's Master Baiter "..self.Version, 1);
if FirstUse then
self:Trace("New install or recent upgrade detected! Here are the addon options:", 1);
end
self:Trace(" /cbmb |c00ffffff: list available options", 1);
self:Trace(" /cbmb loot |c00ffffff: toggle auto-loot when fishing "..self:ShowConfig("loot"), 1);
self:Trace(" /cbmb audio |c00ffffff: toggle auto-enhance audio when fishing "..self:ShowConfig("audio"), 1);
end
function CB_MB:ShowConfig(setting)
if CB_MB_DB.config[setting] then
return format("[|c0000ff00%s|c00ffffff]", "ON");
else
return format("[|c00ff0000%s|c00ffffff]", "OFF");
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment