Thread Tools Display Modes
01-03-11, 12:54 PM   #1
Calabera
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 2
First wow mod, need help to trouble shoot.

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

lolcal conflagCDC
 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
  Reply With Quote
01-03-11, 04:10 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
First, you never created a frame. Second, you never told it when to run your function. Third, you're not telling your code what to do with the variables you create.

Pretty much, your syntax/logic is way off. Have a read at these two sites for starters.
http://www.lua.org/pil/
http://lua-users.org/wiki/TutorialDirectory
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
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
01-04-11, 09:55 AM   #4
Calabera
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 2
I have figured it out, with a lot of help from pros.

It looks like
Code:
local EventFrame = CreateFrame("Frame",nil,UIParent)
function EventFrame:Check()
    --- Dark Intent Check
    local myDarkIntent = UnitBuff("player", "Dark Intent")
    if (myDarkIntent == 0) then 
        print("You are missing Dark Intent!")
    end
		
    --- Improved Soul Fire Check
    local impSoulFire = UnitBuff("player", "Improved Soul Fire")
    if (impSoulFire == 0) then
        print("You are missing improved Soul Fire!")
    end
		
    --- Conflag Check
    local start, duration, enabled = GetSpellCooldown("Conflagrate")
    if (enabled == 0) then
        print("Conflag is ready for use!")
    else 
        if ( start > 0 and duration > 0) then
            print("Conflag is on Cooldown " .. (start + duration - GetTime()) .. " secs to be up.")
	else
	    print("Conflag is ready for use!")
        end
    end
end
EventFrame:RegisterEvent("PLAYER_LOGIN")
EventFrame:RegisterEvent("PLAYER_REGEN_DISABLED")
EventFrame:SetScript("OnEvent", EventFrame.Check)
EventFrame:Show()
It works, I am just working on a way to have loop while on combat. As it is now it just checks when I first enter combat, should have figured the whole loop situation figured out today. I hope... lol
  Reply With Quote
01-04-11, 11:39 AM   #5
willgk
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 37
Look into using an OnUpdate for something like this it wouldn't be too bad since it's small. Though a second solution for all of this would be just get the addon PowerAuras and build these checks into it which takes just a few seconds and he has lots of different checks to look for.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » First wow mod, need help to trouble shoot.


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