Thread Tools Display Modes
09-06-08, 07:39 PM   #1
Hanakabo17
A Deviate Faerie Dragon
 
Hanakabo17's Avatar
Join Date: Aug 2008
Posts: 18
Can someone help me?

I have a will to write a mod for rogues that warns you when you need to reapply poisons. However, i only have a basic understanding of how to write addons, and although i can get the .toc folder down, the .xml and .lua files i would have a lottttt of trouble with. Any help would be appreciated, as I have an insane craving to try out beta.
__________________
Deus ex Machina.

Last edited by Hanakabo17 : 09-06-08 at 10:26 PM.
  Reply With Quote
09-11-08, 07:03 PM   #2
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
OK - here's something to get you started...

You don't need an .XML file - just a .LUA file which contains the following...

Code:
-- define a frame
local OurPoisonMod = CreateFrame("Frame")

-- create a BIG text object  
local OPM_alarm = UIParent:CreateFontString(nil, 'BACKGROUND') 
OPM_alarm:SetWidth(700) -- 700 pixels wide
OPM_alarm:SetHeight(50) -- 50 pixels high
OPM_alarm:SetPoint("CENTER",0,100) -- 100 pixels up from center of the screen
OPM_alarm:SetFont(GameFontNormal:GetFont(),40) -- set it's font to 40pt
OPM_alarm:SetTextColor(1,0,0) -- make it RED

-- initialise some timers
local OPM_alarmtime = 0 -- initialise our alarm timer
local OPM_checkweapons = 0 -- initialse our weapon check timer

-- the function which does all the clever stuff 
local function OPM_update()
  
  -- every 10 seconds we check our weapons to see if they have poisons
  if GetTime() - OPM_checkweapons > 10 then 
    -- GetWeaponEnchantInfo tells us about 'temporary' enchants on our weapons (poisons, shaman weaponbuffs, stones etc.)
    local mh,_,_,oh = GetWeaponEnchantInfo()
    if not mh then -- we have no MH enchant
      OPM_alarm:SetText("No Poison on Mainhand Weapon") -- show alarm
      OPM_alarmtime = GetTime() -- start timer
    elseif not oh then -- we have no OH enchant
      OPM_alarm:SetText("No Poison on Offhand Weapon") -- show alarm
      OPM_alarmtime = GetTime() -- start timer
    end
    OPM_checkweapons = GetTime()
  end

  -- 5 seconds after we showed the message, we clear it
  if OPM_alarmtime > 0 and GetTime() - OPM_alarmtime > 5 then 
    OPM_alarm:SetText("") -- clear the alarm
    OPM_alarmtime = 0
  end
end

-- link our function to our frame's OnUpdate event
-- OnUpdate is called EVERY time the screen updates - if you have 40fps that's 40 times a second!
OurPoisonMod:SetScript("OnUpdate", OPM_update)
All this does is - every 10 check your weapons for 'temporary enchants' and if you don't have one it puts a BIG message on the screen.

5 seconds after the message appears, it will be blanked-out.

This will work for ANY class of course - not just Rogues - so your first task is to work out how to make it work ONLY for Rogues I guess

Hope this helps

*waits for people to come along and critique his code*
  Reply With Quote
09-11-08, 11:57 PM   #3
Selite
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 20
This might just be my lack of LUA experience, but when are the timers told to start timing, i.e. what makes those variables timers, and not just variables with a value of 0.

Otherwise, it looks good there kerrang.
  Reply With Quote
09-12-08, 06:43 PM   #4
kerrang
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 109
Originally Posted by Selite View Post
This might just be my lack of LUA experience, but when are the timers told to start timing, i.e. what makes those variables timers, and not just variables with a value of 0.
They're just variables which store a time at which something happened - we then check that against the current time regularly and when the correct 'delay' has happened, we run our code.

The OnUpdate event fires a LOT you see - once per frame (so if you have 40fps it fires 40 times a second) so we need to avoid running all our code EVERY time (or we'll chew up loads of CPU time)...
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Can someone help me?


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