PDA

View Full Version : [Help Needed] Code issues...


undrgrnd
30-10-2006, 10:47 PM
I haven't really made any working UI mods yet so I'm sure I'm doing something stupid and ovbiously wrong lol, can someome just take a look at this and point it out? The point of this mod is so that when I whisper a person with it (A Priest) that he automatically targets me and casts Greater Heal. If you need more info just ask!

function ZMod_OnLoad()
this:RegisterEvent("CHAT_MSG_WHISPER");

SLASH_ZMOD1 = "/zmod";
SLASH_ZMOD2 = "/zm";
SlashCmdList["ZMOD"] = function(msg)
ZMod_SlashCommandHandler(msg);
end
DEFAULT_CHAT_FRAME:AddMessage("ZMod Running!");
end

function ZMod_SlashCommandHandler(msg)
if( msg ) then
local command = string.lower(msg);
if( command == "reload" ) then
ReloadUI();
end
if( command == "two" ) then
DEFAULT_CHAT_FRAME:AddMessage("Numbah 2");
end
end
end

function ZMod_OnEvent(event)
if( event == "CHAT_MSG_WHISPER" ) then
ZMod_ReadWhisper(arg2, arg1);
end
end

function ZMod_ReadWhisper(name, content)
if ( (string.find(string.lower(content))) == "cast heal") then
ZMod_Cast("Greater Heal", name);
end
end

function ZMod_Cast(spell, name)
TargetByName(name);
CastSpellByName(spell);
end

Klishu
03-11-2006, 10:29 AM
Theoritically your addon is correct!

The problem is that certain API functions like CastSpellByName() require user input to work. That is they can only work in response to a click of the mouse (on the action bar for example) or pressing a button on your keyboard.

What you can do is maybe save the name of the last person who whispered you with "cast heal" and pop up a huge button in the middle of your screen for you to click! When you click it, you cast "Greater Heal" on the person that whispered you last with the message "cast heal".