------------------------------------------------------------------------------]] |
|
local _G = _G |
local addon = {} |
|
addon.eventframe = CreateFrame('Frame') |
|
local TL, TC, TR = 'TOPLEFT', 'TOP', 'TOPRIGHT' |
local ML, MC, MR = 'LEFT', 'CENTER', 'RIGHT' |
local BL, BC, BR = 'BOTTOMLEFT', 'BOTTOM', 'BOTTOMRIGHT' |
|
local eventframe = CreateFrame('Frame') |
local outputframe = _G.ChatFrame1 |
|
local ExperienceLeft |
local ExperienceGain |
local RepetitionsNeeded |
local ExperienceRested |
|
function addon:getExperienceLeft () |
local getExperienceLeft |
local Print |
local PLAYER_XP_UPDATE |
local PLAYER_LEVEL_UP |
local OnEvent |
|
function getExperienceLeft () |
return UnitXPMax('player') - UnitXP('player') |
end |
|
function addon:Print () |
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))) |
outputframe:AddMessage(('%s / %s = %s (%s %s%%)'):format(ExperienceLeft, ExperienceGain, RepetitionsNeeded, rested, math.floor(rested*100/ExperienceLeft))) |
else |
UIErrorsFrame:AddMessage(ExperienceLeft..' / '..ExperienceGain..' = '..RepetitionsNeeded) |
outputframe:AddMessage(ExperienceLeft..' / '..ExperienceGain..' = '..RepetitionsNeeded) |
end |
end |
|
function addon:PLAYER_XP_UPDATE () |
ExperienceGain = ExperienceLeft - self:getExperienceLeft() |
ExperienceLeft = self:getExperienceLeft() |
function PLAYER_XP_UPDATE () |
ExperienceGain = ExperienceLeft - getExperienceLeft() |
ExperienceLeft = getExperienceLeft() |
RepetitionsNeeded = math.ceil(ExperienceLeft / ExperienceGain) |
self:Print() |
Print() |
end |
|
function addon:PLAYER_LEVEL_UP () |
ExperienceLeft = self:getExperienceLeft() |
function PLAYER_LEVEL_UP () |
ExperienceLeft = getExperienceLeft() |
ExperienceGain = 0 |
RepetitionsNeeded = 0 |
end |
|
function addon.OnEvent (frame, event, ...) |
function OnEvent (frame, event, ...) |
ChatFrame1:AddMessage('DEBUG: '..event) |
if event == 'PLAYER_XP_UPDATE' then |
addon:PLAYER_XP_UPDATE(...) |
PLAYER_XP_UPDATE() |
elseif event == 'PLAYER_LEVEL_UP' then |
addon:PLAYER_LEVEL_UP(...) |
PLAYER_LEVEL_UP() |
end |
end |
|
ExperienceLeft = addon:getExperienceLeft() |
ExperienceLeft = getExperienceLeft() |
ExperienceGain = 0 |
RepetitionsNeeded = 0 |
|
SlashCmdList['IDEXPERIENCE_PRINTXP'] = addon:Print() |
SlashCmdList['IDEXPERIENCE_PRINTXP'] = Print |
SLASH_IDEXPERIENCE_PRINTXP1 = '/xp' |
|
addon.eventframe:SetScript('OnEvent', addon.OnEvent) |
addon.eventframe:RegisterEvent('PLAYER_XP_UPDATE') |
addon.eventframe:RegisterEvent('PLAYER_LEVEL_UP') |
eventframe:SetScript('OnEvent', OnEvent) |
eventframe:RegisterEvent('PLAYER_XP_UPDATE') |
eventframe:RegisterEvent('PLAYER_LEVEL_UP') |
|
_G.idExperience = addon |
|