WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   First wow mod, need help to trouble shoot. (https://www.wowinterface.com/forums/showthread.php?t=38100)

Calabera 01-03-11 12:54 PM

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


Seerah 01-03-11 04:10 PM

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

Ekaterina 01-04-11 02:47 AM

Quote:

Originally Posted by Calabera (Post 225319)
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


Calabera 01-04-11 09:55 AM

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

willgk 01-04-11 11:39 AM

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.


All times are GMT -6. The time now is 06:32 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI