View Single Post
01-04-11, 02:47 AM   #3
Ekaterina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 65
Originally Posted by Calabera View Post
First of all, thanks for taking the time to visit my post.

I have some programming background, I used to study CIS before I decided to join the military and go in a medical career.

Now, I am trying to make a simple mod using nothing but local values.

I want the mod to detect if I have Dark Intent up, if I have Improved Soul Fire up, and last but not least to see if Conflag is off from CD. (Yes I play a warlock)

Code:
EventFrame:RegisterEvent("PLAYER_LOGIN")


function CalaberaAnnounce:PLAYER_ENTERS_COMBAT()

local myDarkIntent
       myDarkIntent = UnitBuff("player", "Dark Intent");
end;
else
  DEFAULT_CHAT_FRAME:AddMessage("You are missing Dark Intent!");
end;



--- Improved Soul Fire Check

local impSoulFire
       impSoulFire = UnitBuff("player", "Improved Soul Fire", 2)
end;
else
  DEFAULT_CHAT_FRAME:AddMessage("You are missing Improved Soul Fire!")
end;

--- Conflag Check
 local start, duration, enabled = GetSpellCooldown("Conflagrate");
if enabled == 0 then
 DEFAULT_CHAT_FRAME:AddMessage("Conflag is ready for use!");
elseif ( start > 0 and duration > 0) then
 DEFAULT_CHAT_FRAME:AddMessage("Conflag is on Cooldown " .. (start + duration - GetTime()) .. " secs to be up.");
else
DEFAULT_CHAT_FRAME:AddMessage("Conflag is ready for use!");
end;
Where did I go wrong with this in my Lua?

My TOC reads as follows:

Code:
## Interface: 40000
## CalaberaAnnounce
## Version: v.1.0.b
## Description: Mod to remind me when Dark Intent is not buffed, Conflag is off GCD, and when Improved Soul Fire has fallen.
## Author: Calabera of Skullcrusher - US
## SavedVariables: DestroAnnouceVar


CalaberaAnnounce.lua
As seerah pointed out you didn't have a frame created, had registered your event to one frame and then tried programming another. Also your syntax was a little screwy. Check out the links that Seerah provided. Also Wowwiki and http://wowprogramming.com/. The book they sell on that site, I cannot recommend highly enough for helping you wrap your head around the basics of the lua syntax and the wow api.

I've drycoded something below that you may want to try, but I haven't tested it. No doubt there are others who would come up with something more elegant or point out my mistakes.

Code:
local CalaberaAnnounce = CreateFrame(frame)

CalaberaAnnounce:RegisterEvent("PLAYER_ENTERS_COMBAT")

function CalaberaAnnounce:PLAYER_ENTERS_COMBAT()
	local myDarkIntent = UnitBuff("player", "Dark Intent")
	local impSoulFire = UnitBuff("player", "Improved Soul Fire", 2)

	local conflagCDC
	local start, duration, enabled = GetSpellCooldown("Conflagrate")

	if start == 0 then
 		DEFAULT_CHAT_FRAME:AddMessage("Conflag is ready for use!");
	elseif ( start > 0 and duration > 0) then
 		DEFAULT_CHAT_FRAME:AddMessage("Conflag is on Cooldown " .. (start + duration - GetTime()) .. " secs to be up.");
	end

	if not myDarkIntent then 
		DEFAULT_CHAT_FRAME:AddMessage("You are missing Dark Intent!");
	end

	if not impSoulFire then 
		DEFAULT_CHAT_FRAME:AddMessage("You are missing Improved Soul Fire!")
	end 
end
  Reply With Quote