Thanks Phanx. Now i have one more small(ish) problem.
I changed my TOC to:
Code:
## Interface: 40300
## Title: Tribal XP Bar
## Notes: Tribally XP Bar of Prettiness
## Author: Othgar
## Version: 1.0b
## SavedVariablesPerCharacter: TXPVisible, TXPLocked, TXPTexture
TXP.lua
and changed the Lua file to:
Code:
-- Tribal Experience Bar
-- By: Othgar
-- Copyleft All Rights Reversed
-- Default state
TXPVisible = true;
TXPLocked = true;
-- Constants
local ThousandSeparator = ","
local TipTitle = "Tribal XP"
local _, class = UnitClass("player")
local r,g,b = RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b
local function FmtBigNum(n)
local left, num, right = string.match(n .. "", '^([^%d]*%d)(%d*)(.-)')
return left..(num:reverse():gsub('(%d%d%d)', '%1'.. ","):reverse())..right
end
local TribalExperienceBar = CreateFrame("StatusBar","TribalExperienceBar",UIParent)
TribalExperienceBar:SetSize(675, 150)
TribalExperienceBar:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
TribalExperienceBar:SetFrameStrata("MEDIUM");
TribalExperienceBar:SetClampedToScreen(1);
TribalExperienceBar:SetBackdrop({bgFile="Interface\\Tooltips\\UI-Tooltip-Background", edgeFile="", tile=1, tileSize=10, edgeSize=10, insets={left=2, right=2, top=2, bottom=2}});
TribalExperienceBar:SetBackdropColor(r,g,b,0)
TribalExperienceBar:SetMovable(1);
TribalExperienceBar:EnableMouse(1);
TribalExperienceBar:SetStatusBarTexture("TXPTexture")
TribalExperienceBar:SetStatusBarColor(r,g,b)
TribalExperienceBar:SetAlpha(.75)
local TXPBarText = TribalExperienceBar:CreateFontString("TXPBarText","OVERLAY");
TXPBarText:SetFontObject(GameFontNormal)
TXPBarText:SetTextColor(r,g,b)
TXPBarText:SetPoint("CENTER", TribalExperienceBar, "BOTTOM", 0, 0);
TXPBarText:SetJustifyH("CENTER");
TXPBarText:SetJustifyV("CENTER");
--Register Events
TribalExperienceBar:RegisterEvent("PLAYER_ENTERING_WORLD");
TribalExperienceBar:RegisterEvent("PLAYER_XP_UPDATE");
TribalExperienceBar:RegisterEvent("PLAYER_LOGIN");
TribalExperienceBar:RegisterEvent("PLAYER_LEVEL_UP");
--Event handling
TribalExperienceBar:SetScript("OnEvent", function(self, event, ...)
local curxp = UnitXP("player")
local levelmax = UnitXPMax("player")
local perc = string.format("%.1f%%", (100*(curxp/levelmax)))
local perbox = levelmax / 20
local mystr = string.format("%.1fb - %.1fb tnl | %s", curxp / perbox, (levelmax - curxp) / perbox, perc)
TXPBarText:SetText(mystr)
TribalExperienceBar:SetMinMaxValues(0, levelmax)
TribalExperienceBar:SetValue(curxp)
if TXPVisible then
TribalExperienceBar:Show()
else
TribalExperienceBar:Hide()
end
end)
-- move me
TribalExperienceBar:SetScript("OnMouseDown", function()
if not TXPLocked then
TribalExperienceBar:StartMoving()
else
TribalExperienceBar:StopMovingOrSizing()
end
end)
TribalExperienceBar:SetScript("OnMouseUp", function() TribalExperienceBar:StopMovingOrSizing() end)
-- register slash commands
SLASH_TXP1 = '/TXP';
local COMMAND_PARAMS = {
hide = function()
if TXPVisible then
TXPVisible=false
TribalExperienceBar:Hide()
print("Experience hidden, type /TXP show to show.")
end
end,
show = function()
if not TXPVisible then
TXPVisible=true
TribalExperienceBar:Show()
print("Experience displayed, type /TXP hide to hide.")
end
end,
rested = function()
if GetXPExhaustion() == nil then
print("You have no rested EXP.")
else
print("You have "..GetXPExhaustion().." rested EXP remaining.")
end
end,
lock = function()
if TXPLocked == true then
TXPLocked = false
print("TXP UNlocked")
elseif TXPLocked == false then
TXPLocked = true
print("TXP Locked")
end
end,
curve = function()
if TXPTexture == "curve" then
TribalExperienceBar:SetStatusBarTexture("Interface\\AddOns\\TXP\\media\\curve")
print("Texture already set to Curve")
else
TribalExperienceBar:SetStatusBarTexture("Interface\\AddOns\\TXP\\media\\curve")
TXPTexture = "curve"
print("Texture set to Curve")
end
end,
simple = function()
if TXPTexture == "simple" then
TribalExperienceBar:SetStatusBarTexture("Interface\\AddOns\\TXP\\media\\simple")
print("Texture already set to Simple")
else
TribalExperienceBar:SetStatusBarTexture("Interface\\AddOns\\TXP\\media\\simple")
TXPTexture = "simple"
print("Texture set to Simple")
end
end,
split = function()
if TXPTexture == "split" then
TribalExperienceBar:SetStatusBarTexture("Interface\\AddOns\\TXP\\media\\split")
print("Texture already set to Split")
else
TribalExperienceBar:SetStatusBarTexture("Interface\\AddOns\\TXP\\media\\split")
TXPTexture = "split"
print("Texture set to Split")
end
end,
}
local function slashcmdhandler(param)
if COMMAND_PARAMS[param] then
COMMAND_PARAMS[param]()
return
end
print("Valid commands are:");
print("/TXP show (Show the experience bar.)");
print("/TXP hide (Hide the experience bar.)");
print("/TXP rested (Shows the amount of rested XP.)");
print("/TXP Lock (Locks the experience bar if it is unlocked, Unlocks it if it is locked.")
print("/TXP Curve (Sets the status bar texture to Curve.")
print("/TXP Simple (Sets the bar texture to Simple")
print("/TXP Split (Sets the Bar texture to Split")
end
SlashCmdList["TXP"] = slashcmdhandler;
--Tooltip
local function OnEnter(self)
GameTooltip:Show()
end
local function OnLeave(self)
GameTooltip:Hide()
end
--hide @ 85
if UnitLevel("player") >= 85 then
TribalExperienceBar:Hide() print("Experience bar hidden, type /TXP show to show.")
TXPVisible = false
end
and it's saving the texture as a variable I think because I set the texture simple (for example) and do /rl, and I get "Texture already set simple." printed in the chat window. However the texture isn't showing up until I set it again with the slash command, and after another /rl I have to set it again.
Edit: After some more testing it seems that the texture remains set and appears after changing zones, but a /rl or logout requires me to reset the texture via slash command.