/
--[[---------------------------------------------------------------------------- |
Copyright (c) 2007, Tom Wieland |
Copyright (c) 2008, Tom Wieland |
All rights reserved. |
Redistribution and use in source and binary forms, with or without |
POSSIBILITY OF SUCH DAMAGE. |
------------------------------------------------------------------------------]] |
local lib = LibStub('idLibrary-1.1') |
local _G = _G |
local frame = CreateFrame('Frame') |
local TL, TC, TR = 'TOPLEFT', 'TOP', 'TOPRIGHT' |
local ML, MC, MR = 'LEFT', 'CENTER', 'RIGHT' |
local RepetitionsNeeded |
local ExperienceRested |
local function getExperienceLeft() |
local function getExperienceLeft () |
return UnitXPMax('player') - UnitXP('player') |
end |
local function print() |
local function print () |
local rested = GetXPExhaustion() |
if rested then |
UIErrorsFrame:AddMessage(('%s / %s = %s (%s %s%%)'):format(ExperienceLeft, ExperienceGain, RepetitionsNeeded, rested, math.floor(rested*100/ExperienceLeft))) |
ChatFrame1:AddMessage(('%s / %s = %s (%s %s%%)'):format(ExperienceLeft, ExperienceGain, RepetitionsNeeded, rested, math.floor(rested*100/ExperienceLeft))) |
else |
UIErrorsFrame:AddMessage(ExperienceLeft..' / '..ExperienceGain..' = '..RepetitionsNeeded) |
ChatFrame1:AddMessage(ExperienceLeft..' / '..ExperienceGain..' = '..RepetitionsNeeded) |
end |
end |
local function PLAYER_XP_UPGRADE () |
local function PLAYER_XP_UPDATE () |
ExperienceGain = ExperienceLeft - getExperienceLeft() |
ExperienceLeft = getExperienceLeft() |
RepetitionsNeeded = math.ceil(ExperienceLeft / ExperienceGain) |
RepetitionsNeeded = 0 |
end |
local function initialize(name) |
local function ADDON_LOADED (name) |
if name ~= 'idExperience' then return end |
ExperienceLeft = getExperienceLeft() |
ExperienceGain = 0 |
RepetitionsNeeded = 0 |
end |
local function enable() |
local function PLAYER_LOGIN () |
SlashCmdList['ZEXPERIENCE_PRINTXP'] = print |
SLASH_ZEXPERIENCE_PRINTXP1 = '/xp' |
end |
local function OnEvent (frame, event, ...) |
if event == 'ADDON_LOADED' then |
ADDON_LOADED(...) |
elseif event == 'PLAYER_LOGIN' then |
PLAYER_LOGIN(...) |
elseif event == 'PLAYER_XP_UPDATE' then |
PLAYER_XP_UPDATE(...) |
elseif event == 'PLAYER_LEVEL_UP' then |
PLAYER_LEVEL_UP(...) |
end |
end |
lib:RegisterEvent('idExperience-Initialize', 'ADDON_LOADED', initialize) |
lib:RegisterEvent('idExperience-Enable', 'PLAYER_LOGIN', enable) |
lib:RegisterEvent('idExperience', 'PLAYER_XP_UPDATE', PLAYER_XP_UPDATE) |
lib:RegisterEvent('idExperience', 'PLAYER_LEVEL_UP', PLAYER_LEVEL_UP) |
frame:SetScript('OnEvent', OnEvent) |
frame:RegisterEvent('ADDON_LOADED') |
frame:RegisterEvent('PLAYER_LOGIN') |
frame:RegisterEvent('PLAYER_XP_UPDATE') |
frame:RegisterEvent('PLAYER_LEVEL_UP') |
## Interface: 20300 |
## Title: Industrial: Experience |
## Credits: Industrial |
## Notes: Experience and kills left display |
Libraries\LibStub.lua |
Libraries\idLibrary-1.1.lua |
Addon.lua |
## Interface: 20401 |
## Notes: Experience and kills left display |
Addon.lua |