Thread Tools Display Modes
05-18-06, 07:06 AM   #1
sirducky
A Defias Bandit
Join Date: May 2006
Posts: 3
Mod Debug Request

Hi guys, first time poster here and i wouldnt mind a bit of help because i have no idea when it comes to coding =P (fell asleep once to many times in IT)

Ok, basically I found a mod on Curse-Gaming, and I love the concept of it, it basically does everything I want / need it to do, and it would be great for all Priests who have the right gear for it, but its broken, i dont think its been updated for 1.10 =/. Errors are continually displayed, something about Invalid arguments and expecting 'nil' or something along those lines.

Rundown: This mod is designed to allow 3 Preset weapons, a high Int weapon, High spirit weapon, and normal weapon. when on full mana, the high int weap is equiped for the greater mana cap, when innervated, the spirit weap is equiped for bonus regen, and when on medium mana, the Normal weap is equiped to go for the harder hitting heals.

Here is the mod
-------------------------------------------------------------------------


CasterWeaponSwap_Enabled = nil;
CasterWeaponSwap_PercentSwap = 0.90;
CasterWeaponSwap_IntWeapon = {};
CasterWeaponSwap_NormalWeapon = {};
CasterWeaponSwap_SpiritWeapon = {};
CasterWeaponSwap_LastCast = 0;

function CasterWeaponSwap_OnLoad()
DEFAULT_CHAT_FRAME:AddMessage("CasterWeaponSwap Loaded. /cwswap");

SLASH_CasterWeaponSwap1 = "/cwswap";
SlashCmdList["CasterWeaponSwap"] = function(msg)
CasterWeaponSwap_SlashCommandHandler(msg);
end

this:RegisterEvent("UNIT_AURA");
this:RegisterEvent("UNIT_MANA");
this:RegisterEvent("SPELLCAST_STOP");
end

function CasterWeaponSwap_OnEvent()
if (not CasterWeaponSwap_Enabled) then
return;
end

if (event == "UNIT_AURA" or event == "UNIT_MANA") then
if (arg1 == "player") then
if (UnitMana("player") == UnitManaMax("player")) then
CasterWeaponSwap_EquipWeapon(CasterWeaponSwap_IntWeapon);
elseif (UnitMana("player") / UnitManaMax("player") <= CasterWeaponSwap_PercentSwap) then
if (CasterWeaponSwap_FindBuff("Aura of the Blue Dragon") or CasterWeaponSwap_FindBuff("Innervate") or CasterWeaponSwap_FindBuff("Evocation")) then
CasterWeaponSwap_EquipWeapon(CasterWeaponSwap_SpiritWeapon);
else
CasterWeaponSwap_EquipWeapon(CasterWeaponSwap_NormalWeapon);
end
end
end
elseif (event == "SPELLCAST_STOP") then
CasterWeaponSwap_LastCast = GetTime();
end
end

function CasterWeaponSwap_EquipWeapon(weapon)
if (not (GetInventoryItemLink("player", 16) == weapon[1]) and weapon[1]) then
local i, j = CasterWeaponSwap_FindItem(weapon[1]);
if (i) then
PickupContainerItem(i, j);
PickupInventoryItem(16);
end
end
if (not (GetInventoryItemLink("player", 17)) == weapon[2] and weapon[2]) then
local i, j = CasterWeaponSwap_FindItem(weapon[2]);
if (i) then
PickupContainerItem(i, j);
PickupInventoryItem(17);
end
end
end

function CasterWeaponSwap_SlashCommandHandler(msg)
local lowerMsg = string.lower(msg);
if (string.find(lowerMsg, "intweapon")) then
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> Changed int weapon.");
CasterWeaponSwap_IntWeapon = CasterWeaponSwap_GetCurrentWeapons();
elseif (string.find(lowerMsg, "normalweapon")) then
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> Changed normal weapon.");
CasterWeaponSwap_NormalWeapon = CasterWeaponSwap_GetCurrentWeapons();
elseif (string.find(lowerMsg, "spiritweapon")) then
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> Changed spirit weapon.");
CasterWeaponSwap_SpiritWeapon = CasterWeaponSwap_GetCurrentWeapons();
elseif (string.find(lowerMsg, "on")) then
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> Enabled.");
CasterWeaponSwap_Enabled = 1;
elseif (string.find(lowerMsg, "off")) then
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> Disabled.");
CasterWeaponSwap_Enabled = nil;
else
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> CasterWeaponSwap:");
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> /cwswap on");
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> /cwswap off");
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> /cwswap intweapon");
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> /cwswap normalweapon");
DEFAULT_CHAT_FRAME:AddMessage("<CasterWeaponSwap> /cwswap spiritweapon");
end
end

function CasterWeaponSwap_GetCurrentWeapons()
local ret = {};
local mh, oh = GetInventoryItemLink("player", 16), GetInventoryItemLink("player", 17);
tinsert(ret, mh);
tinsert(ret, oh);
return ret;
end

function CasterWeaponSwap_FindBuff(buffName)
i = 1;
while ( UnitBuff("player", i) ) do
GameTooltip:ClearLines();
GameTooltip:SetUnitBuff("player",i);
local buff_name = GameTooltipTextLeft1:GetText();

if ( string.find(buffName, buff_name) ) then
return 1;
end

i = i + 1;
end;
end


function CasterWeaponSwap_FindItem(item)
for j=0, 4 do
for k=1, GetContainerNumSlots(j) do
local itemLink = GetContainerItemLink(j, k);
if (itemLink == item) then
return j, k;
end
end
end
end


Any and all help is appreciated, thanks.
  Reply With Quote
05-18-06, 11:56 AM   #2
Guvante
An Aku'mai Servant
 
Guvante's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 31
Giving the error messages would help tremendously, as it is really hard to look at code and see the problem (Unless it has a simple problem)
  Reply With Quote
05-18-06, 02:59 PM   #3
brotherhobbes
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 313
have you tried this? looks like someone already made what you are trying to do:
http://www.wowinterface.com/download...fo.php?id=4749

of course i'm not trying to discourage you if you want to make your addon for learning purposes.
  Reply With Quote
05-19-06, 12:38 AM   #4
sirducky
A Defias Bandit
Join Date: May 2006
Posts: 3
Ok, i'll try and copy out the error message, any tips though? because only a partial ammount of it comes up in the default wow error UI.

and to the second post, Like i said, its not my mod, and there is few advantages to this one.

First of all, CasterWeaponSwapper is made to avoid the 1.5 second global cooldown when changing weaps, however, Priests do not suffer the 1.5 second CD, so its less accurate and a bit less efficient.

Secondly, CasterWeaponSwap (the one i'm trying to get fixed) searches for present buffs, and equips a weapon that will help you get the most out of the buff, this is another feature CasterWeaponSwapper does not have as yet.


Thanks
  Reply With Quote
05-19-06, 01:07 AM   #5
sirducky
A Defias Bandit
Join Date: May 2006
Posts: 3
Interface\Addons\CasterWeaponSwap\CasterWeaponSwap.lua: 102: bad argument #2 to ` find' (string expected, got nil)

Thats all that comes up i have a feeling it has something to do with the Spirit / Normal section of the mod, because it has no trouble when changing from Int to Normal and Normal to Int.... maybe i just havent realised though.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Mod Debug Request


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off