Avian Gamers Network
http://avian-gamers.net/forums/

SmackTalk Error... please help
http://avian-gamers.net/forums/viewtopic.php?f=40&t=14829
Page 1 of 1

Author:  Cyrus Rex [ Wed Jun 01, 2005 9:57 pm ]
Post subject:  SmackTalk Error... please help

I am getting this error:

    [string "Interface\AddOns\SmackTalk\SmackTalk.lua"]:172:attempt to compare number with nil


Does anyone have an idea what is going wrong around line 172?

Code:
-- SmackTalk v0.5
-- Author: Theck
--


local nsmack=1
local nperc=0.05
local whovar="say"
local SMACKTALK_OPTIONS_TIP="Check to enable SmackTalk for this skill"
local SmackTalk_Help="Check each box to enable SmackTalk for that skill"
local SmackgotVariables = false;
local SmackgotPlayerName = false;
local SMACK_VERSION="0.5"
Smack = {}

--Blizzard Registrations
UIPanelWindows["SmackTalkFrame"] = { area = "left", pushable = 11 };


function SmackTalk_OnLoad()

   this:RegisterEvent("VARIABLES_LOADED");
   this:RegisterEvent("PLAYER_ENTERING_WORLD");
   this:RegisterEvent("UNIT_NAME_UPDATE");
--   this:RegisterEvent("CHAT");

   this:RegisterEvent("CHAT_MSG_COMBAT_SELF_HITS");
   this:RegisterEvent("CHAT_MSG_COMBAT_PET_HITS");

   this:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
   this:RegisterEvent("CHAT_MSG_SPELL_PET_DAMAGE");
   this:Hide();

   SlashCmdList["SMACKTALK"]=SmackTalk_SlashCommandHandler;
   SLASH_SMACKTALK1 = "/smack";
   SLASH_SMACKTALK2 = "/smacktalk";

--   getglobal("Header"):SetTextHeight(10);


--   if not Smack then

--   end
   RegisterForSave("Smack")
   OptionsFrame_EnableDropDown(VerboseDropdown);

end

function SmackTalk_Initialize()
--   DEFAULT_CHAT_FRAME:AddMessage("SMACK INITIALIZE",1,0,0)
   if (not Smack[plyr] or not Smack[plyr].latestversion or Smack[plyr].latestversion~=SMACK_VERSION) then
      Smack[plyr]={}
      Smack[plyr]["chatloc"]="say"
      Smack[plyr]["critvar"]=1
      Smack[plyr]["opt2"]=nil
      Smack[plyr]["opt3"]=nil
      Smack[plyr]["opt4"]=nil
      Smack[plyr]["opt5"]=nil
      Smack[plyr]["latestversion"]=SMACK_VERSION
      DEFAULT_CHAT_FRAME:AddMessage("SmackTalk Defaults Loaded",1,0,0)
   end
   if STlist[plyr] then
      while STlist[plyr][nsmack] and STlist[plyr][nsmack]~=""do
         nsmack=nsmack+1
      end
      nperc=STlist[plyr].percent
      DEFAULT_CHAT_FRAME:AddMessage("SmackTalk settings for "..plyr.." loaded", 1, 0.6, 0);
   else
      while STlist["DEFAULT"][nsmack] and STlist["DEFAULT"][nsmack]~="" do
         nsmack=nsmack+1
      end
      nperc=STlist["DEFAULT"].percent
   end
end

-- Check the player name, return true if the player name is known, false otherwise
function SmackCheckPlayerName()
  if (gotPlayerName) then
    return true;
  end
  local pName = UnitName("player");
  if ((pName ~= nil) and (pname ~= UNKNOWNOBJECT) and (pname ~= UKNOWNBEING)) then
    SmackgotPlayerName = true;
    plyr=pName;
    return true;
  end
  return false;
end

function SmackTalk_OnEvent()

   if (event == "VARIABLES_LOADED") then
           SmackgotVariables = true;
          if (SmackCheckPlayerName()) then
               SmackTalk_Initialize();
--         DEFAULT_CHAT_FRAME:AddMessage("SACK INIT VAR LOAD",1,0,0)
          end
      if ( DEFAULT_CHAT_FRAME ) then
             DEFAULT_CHAT_FRAME:AddMessage("SmackTalk loaded, /smack for options", 1, 0.6, 0);
        end   
          return

   end
     if ((event == "PLAYER_ENTERING_WORLD") or (event == "UNIT_NAME_UPDATE" and arg1 == "player")) then
          if (not SmackgotPlayerName) then
               if (SmackCheckPlayerName() and SmackgotVariables) then
                 SmackTalk_Initialize();
--            DEFAULT_CHAT_FRAME:AddMessage("SACK INIT PEW",1,0,0)
               end
          end
          return
     end
   if (event == "CHAT_MSG_COMBAT_MISC_INFO") then
--      DEFAULT_CHAT_FRAME:AddMessage("MISC_INFO")

   end
   if (event == "CHAT_MSG_COMBAT_SELF_HITS") then
--      DEFAULT_CHAT_FRAME:AddMessage("SELF_HITS")
--      DEFAULT_CHAT_FRAME:AddMessage(arg1)
           you1, you2 = string.find(arg1, "You");
      miss, miss2 = string.find(arg1, "miss");
      hit, hit2 = string.find(arg1, "hit");
      crit, crit2 = string.find(arg1, "crit");
      heroic, heroic2 = string.find(arg1, "Heroic Strike");
      mortal, mortal2 = string.find(arg1, "Mortal Strike");
      revenge, revenge2 = string.find(arg1, "Revenge");
           if (you1==1 and you2==3) then
         if crit and Smack[plyr].critvar then
            RandomSmack()
         elseif hit and Smack[plyr].critvar then
            RandomSmack()
         elseif heroic and opt2 then
--            DEFAULT_CHAT_FRAME:AddMessage("Heroic Strike!!")
         elseif mortal and opt3 then
--            DEFAULT_CHAT_FRAME:AddMessage("Mortal Strike!!")
         elseif revenge and opt4 then
--            DEFAULT_CHAT_FRAME:AddMessage("Revenge!!")
         end
           end
   end
   if (event == "CHAT_MSG_COMBAT_PET_HITS") then
      DEFAULT_CHAT_FRAME:AddMessage("PET_HITS")
   end
   if (event == "CHAT_MSG_SPELL_SELF_DAMAGE") then
--      DEFAULT_CHAT_FRAME:AddMessage("SPELL_SELF_DAMAGE")
--      DEFAULT_CHAT_FRAME:AddMessage(arg1)
        you1, you2 = string.find(arg1, "You");
      resist, resist2 = string.find(arg1, "resist");
      hit, hit2 = string.find(arg1, "hit")
      crit, crit2 = string.find(arg1, "crit");
      mind, mind2 = string.find(arg1, "Mind Blast");
      psych, psych2 = string.find(arg1, "Psychic Scream");
      frost, frost2 = string.find(arg1, "Frostbolt");
      if (you1==1 and you2==3) then
         if crit and Smack[plyr].critvar then
            RandomSmack()
--         elseif hit then
--            RandomSmack()
--         elseif frost and resist then
--            DEFAULT_CHAT_FRAME:AddMessage("Frost Bolt resisted!!")
         end
      end
      
   end
   if (event == "CHAT_MSG_SPELL_PET_DAMAGE") then
--      DEFAULT_CHAT_FRAME:AddMessage("SPELL_PET_DAMAGE")
   end
end

function RandomSmack()
   local iperc = math.random()
   if iperc<=nperc then
--   DEFAULT_CHAT_FRAME:AddMessage(iperc)
--   DEFAULT_CHAT_FRAME:AddMessage(nperc)
      local ismack = math.random(nsmack-1)
--      DEFAULT_CHAT_FRAME:AddMessage(ismack.." / "..nsmack-1)
      if STlist[plyr] then
         SendChatMessage(STlist[plyr][ismack], whovar)
      else
         SendChatMessage(STlist["DEFAULT"][ismack], whovar)
      end

   end
end

function SmackTalk_CloseButton()
   SmackTalkFrame:Hide()
end


function SmackTalk_SlashCommandHandler(msg)

   if (msg == "hide") then
      SmackTalkFrame:Hide()
      return
   end
   if (msg == "show") or (msg=="") then
      SmackTalkFrame:Show()
      return
   end
   
end


function SmackTalk_CheckButtonEnter(id)
   GameTooltip:SetOwner(this, "ANCHOR_RIGHT");

   GameTooltip:SetText(SMACKTALK_OPTIONS_TIP .. " ".. id);
end
function SmackTalk_CheckButtonLeave()
   GameTooltip:Hide();
end

function SmackTalk_CheckToggle(set,state)
   if (set==1) then
   if ( state == true or state == 1 ) then
      Smack[plyr].critvar=1
--      BADebug("critvar",Smack[plyr].critvar)
   else
      Smack[plyr].critvar=nil
--      BADebug("critvar",Smack[plyr].critvar)
   end
   end
   if (set==2) then
   if ( state == true or state == 1 ) then
      Smack[plyr].opt2=1
   else
      Smack[plyr].opt2=nil
   end
   end
   if (set==3) then
   if ( state == true or state == 1 ) then
      Smack[plyr].opt3=1
   else
      Smack[plyr].opt3=nil
   end
   end
   if (set==4) then
   if ( state == true or state == 1 ) then
      Smack[plyr].opt4=1
   else
      Smack[plyr].opt4=nil
   end
   end
   if (set==5) then
   if ( state == true or state == 1 ) then
      Smack[plyr].opt5=1
   else
      Smack[plyr].opt5=nil
   end
   end
   SmackTalk_OnShow()
end




function SmackTalk_OnShow()
    SmackTalk_ShowHelp()
   
   getglobal("SmackTalkCheckButton1"):SetChecked(Smack[plyr].critvar);
   getglobal("SmackTalkCheckButton2"):SetChecked(Smack[plyr].opt2)
   getglobal("SmackTalkCheckButton3"):SetChecked(Smack[plyr].opt3)
   getglobal("SmackTalkCheckButton4"):SetChecked(Smack[plyr].opt4)
   getglobal("SmackTalkCheckButton5"):SetChecked(Smack[plyr].opt5)
   getglobal("SmackTalkCheckButton2"):Hide()
   getglobal("SmackTalkCheckButton3"):Hide()
   getglobal("SmackTalkCheckButton4"):Hide()
   getglobal("SmackTalkCheckButton5"):Hide()
end

function SmackTalk_ShowHelp()
   local helptext = getglobal("SmackTalkFrameHelpText");
   if ( helptext ) then
         helptext:SetText(SmackTalk_Help);
   end
end

function VerboseDropdown_Initialize()
   local selectedValue = UIDropDownMenu_GetSelectedValue(VerboseDropdown);
   local info;

   -- raid
   info = {};
   info.text = "Raid";
   info.tooltipTitle = info.text;
   info.tooltipText = "Smack will trash talk in Raid chat";
   info.func = VerboseDropdown_OnClick;
   info.value = 1;
   if ( selectedValue == info.value ) then
      info.checked = 1;
   else
      info.checked = nil;
   end
   UIDropDownMenu_AddButton(info);

   -- party
   info = {};
   info.text = "Party";
   info.tooltipTitle = info.text;
   info.tooltipText = "Smack will trash talk in Party chat";
   info.func = VerboseDropdown_OnClick;
   info.value = 2;
   if ( selectedValue == info.value ) then
      info.checked = 1;
   else
      info.checked = nil;
   end
   UIDropDownMenu_AddButton(info);

   -- say
   info = {};
   info.text = "Say";
   info.tooltipTitle = info.text;
   info.tooltipText = "Smack will trash talk in Say chat";
   info.func = VerboseDropdown_OnClick;
   info.value = 3;
   if ( selectedValue == info.value ) then
      info.checked = 1;
   else
      info.checked = nil;
   end
   UIDropDownMenu_AddButton(info);

   -- yell
   info = {};
   info.text = "Yell";
   info.tooltipTitle = info.text;
   info.tooltipText = "Smack will trash talk in Yell chat";
   info.func = VerboseDropdown_OnClick;
   info.value = 4;
   if ( selectedValue == info.value ) then
      info.checked = 1;
   else
      info.checked = nil;
   end
   UIDropDownMenu_AddButton(info);

end
function VerboseDropdown_OnLoad()
   UIDropDownMenu_Initialize(this, VerboseDropdown_Initialize);
   if whovar=="raid" then
      UIDropDownMenu_SetSelectedID(VerboseDropdown, 1);
   elseif whovar=="party" then
      UIDropDownMenu_SetSelectedID(VerboseDropdown, 2);
   elseif whovar=="say" then
      UIDropDownMenu_SetSelectedID(VerboseDropdown, 3);
   elseif whovar=="yell" then
      UIDropDownMenu_SetSelectedID(VerboseDropdown, 4);
   end
   UIDropDownMenu_SetWidth(70, VerboseDropdown);
end

function VerboseDropdown_OnClick()
   UIDropDownMenu_SetSelectedValue(VerboseDropdown, this.value);
--   BADebug("value",UIDropDownMenu_GetSelectedValue(VerboseDropdown))
   local temp1 = UIDropDownMenu_GetSelectedValue(VerboseDropdown);
   if temp1==1 then
      whovar="raid"
   elseif temp1==2 then
      whovar="party"
   elseif temp1==3 then
      whovar="say"
   elseif temp1==4 then
      whovar="yell"
   end
   VerboseDropdown.tooltip = this.tooltipText;
end

Author:  bigyak [ Thu Jun 02, 2005 3:57 am ]
Post subject: 

I didn't look at exactly what's on that line, but try changing it to ~= 0 instead of ~= nil and see if it works.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/