Ok I'm stumped. This is my first attempt to program a simple addon and I can't figure out why it won't work : /
I've checked out WoW's Wiki site as well as looked at other addon's code to figure it out. Everything seems simple enough. Below are all my files and code. I've written these files in Notepad.exe on Windows. If anybody can tell me what is wrong I'd greatly appreciate it. I really think it all looks good enough to at least load up and respond to slash commands.
Directory: /DKGuard
File: Bindings.xml
-------------------------------------------
Code:
<Bindings>
<Binding name="DKGuard Toggle Enabled" header="DKGUARD">
toggleDKGuard();
</Binding>
</Bindings>
-------------------------------------------
File: DKGuard.lua
-------------------------------------------
Code:
--[[
path: /DKGuard/
filename: DKGuard.lua
author: Brian Roberds <[email protected]>
created: 2005-12-27 15:13:00 PM -0600
updated: 2005-12-27 15:13:00 PM -0600
Dishonerable Kill Guard: An addon that keeps you from targeting Civilians.
]]
-- Configuration
DKG_Config = {
Enabled = 1,
Alert = 1
};
DKG_VERSION = "v1.0a December 27th, 2005";
function DKGuard_OnLoad()
SLASH_DKGUARD1 = "/dkguard";
SLASH_DKGUARD2 = "/dkg";
SlashCmdList["DKGUARD"] = DKGuard_SlashCmd;
this:RegisterEvent("PLAYER_TARGET_CHANGED");
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r " .. DKG_VERSION .. " Loaded.", 0.0, .80, 1);
end
function DKGuard_SlashCmd(msg)
if (msg == "") then
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r " .. DKG_VERSION .. " by Brian Roberds.", 0.0, .80, 1);
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/dkguard enable|r: Enable DKGuard's target clearing functions.", 0.0, .80, 1);
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/dkguard disable|r: Disable DKGuard's target clearing functions.", 0.0, .80, 1);
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/dkguard alertnone|r: Show no warnings.", 0.0, .80, 1);
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/dkguard alertchat|r: Show warnings in Chat Window.", 0.0, .80, 1);
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffff/dkguard alertscreen|r: Show warnings in Combat.", 0.0, .80, 1);
return;
end
if (msg = "enable") then
DKG_Config.Enabled = 1;
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r Enabled - Civilian targets WILL be cleared", 0.0, .80, 1);
end
if (msg = "disable") then
DKG_Config.Enabled = 0;
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r Disabled - Civilian targets will NOT be cleared", 0.0, .80, 1);
end
if (msg = "alertnone") then
DKG_Config.Alert = 0;
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r Alerts Disabled - No visible alerts will be provided when a civilian target is cleared", 0.0, .80, 1);
end
if (msg = "alertchat") then
DKG_Config.Alert = 1;
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r Alerts To Chat - Visible alerts will be provided when a civilian target is cleared via the default chat window", 0.0, .80, 1);
end
if (msg = "alertcombat") then
DKG_Config.Alert = 1;
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r Alerts Combat UI - (Not Implimented Chat Box Used) Visible alerts will be provided when a civilian target is cleared via the console", 0.0, .80, 1);
end
end
function DKGuard_OnEvent(event)
if (event == "PLAYER_TARGET_CHANGED") then
DKGuard_CheckTarget();
return;
end
end
function DKGuard_CheckTarget()
if (UnitIsCivilian("target")==1) then
if(DKG_Config.Alert = 1)
DEFAULT_CHAT_FRAME:AddMessage("|c00bfffffDKGuard|r -= Civilian Target Cleared =-", 0.0, .80, 1);
end
if(DKG_Config.Alert = 2)
-- Show Big Message
end
ClearTarget();
end
end
function toggleDKGuard()
if (DKG_Config.Enabled = 1) then
DKGuard_SlashCmd("disable");
else
DKGuard_SlashCmd("enable");
end
end
-------------------------------------------
File: DKGuard.toc
-------------------------------------------
Code:
## Interface: 1800
## Title : Dishonerable Kill Guard
## Notes: An addon that keeps you from targeting Civilians.
## Author: Brian Roberds
## eMail: [email protected]
## Version: 1.0a
## DefaultState: enabled
## SavedVariables: DKG_Config
-------------------------------------------