09-14-06, 07:48 PM | #1 |
a stats panel
ok im new to wow interfaces. used to do eq2 iu and it was easy they have a neat little prog that shows a pic of the changes you make. well im giving my have at wow now and im trying to make a stat panel with str agi and what nots on it. though it i could copy and past some stuff from the paperdoll xml and lua files but to know avai. any ways here is what my code looks like and stuff but anytime i try to bring it up with a / command i get the msg in the chat window to do /help for a list of commands. can someone take a look and see where my problem is? also looking to abreviate the words. well here are my files and a screen of what im looking for. also these are just text files of my xml lua and toc files in my addon folder they do not have the .txt on them
thanks in advance chop |
|
09-23-06, 05:44 PM | #2 |
ok i sat down and made some changes in everything but i have a few problems.
1. i get an error when i first log on and the screenshot labled error1 will show you 2 my backgroud isnt quite lined up but i will be able to fix that so i dont think it is a big problem right now anyways 3 no text and an error when i move the cursor over where text is suposed to be. 4 an it is always up and my /stats command doent work nor is it moveable like im trying to do im going to post some screen shots along with my code that im using hopefully someone could help me out a bit stats.lua Code:
NUM_STATS = 5; function stats_OnLoad() this:RegisterEvent("UNIT_STATS"); -- Registers Slash Commands SLASH_stats = "/stats"; end function stats_OnEvent(event, unit) if ( event == "PLAYER_ENTERING_WORLD" ) then CharacterModelFrame:SetUnit("player"); return; end if ( not this:IsVisible() ) then return; end if ( unit and unit == "player" ) then if ( event == "UNIT_MODEL_CHANGED" ) then CharacterModelFrame:SetUnit("player"); elseif ( event == "UNIT_STATS" ) then stats_SetStats(); end end end --[[ Just in case they change their minds function statsFrame_SetCharacterPoints() local cp1 = UnitCharacterPoints("player"); CharacterPointsText1:SetText(cp1); end ]] function stats_SetStats() for i=1, NUM_STATS, 1 do local label = getglobal("CharacterStatFrame"..i.."Label"); local text = getglobal("CharacterStatFrame"..i.."StatText"); local frame = getglobal("CharacterStatFrame"..i); local stat; local effectiveStat; local posBuff; local negBuff; label:SetText(TEXT(getglobal("SPELL_STAT"..(i-1).."_NAME"))..":"); stat, effectiveStat, posBuff, negBuff = UnitStat("player", i); -- Set the tooltip text local tooltipText = HIGHLIGHT_FONT_COLOR_CODE..getglobal("SPELL_STAT"..(i-1).."_NAME").." "; if ( ( posBuff == 0 ) and ( negBuff == 0 ) ) then text:SetText(effectiveStat); frame.tooltip = tooltipText..effectiveStat..FONT_COLOR_CODE_CLOSE; else tooltipText = tooltipText..effectiveStat; if ( posBuff > 0 or negBuff < 0 ) then tooltipText = tooltipText.." ("..(stat - posBuff - negBuff)..FONT_COLOR_CODE_CLOSE; end if ( posBuff > 0 ) then tooltipText = tooltipText..FONT_COLOR_CODE_CLOSE..GREEN_FONT_COLOR_CODE.."+"..posBuff..FONT_COLOR_CODE_CLOSE; end if ( negBuff < 0 ) then tooltipText = tooltipText..RED_FONT_COLOR_CODE.." "..negBuff..FONT_COLOR_CODE_CLOSE; end if ( posBuff > 0 or negBuff < 0 ) then tooltipText = tooltipText..HIGHLIGHT_FONT_COLOR_CODE..")"..FONT_COLOR_CODE_CLOSE; end frame.tooltip = tooltipText; -- If there are any negative buffs then show the main number in red even if there are -- positive buffs. Otherwise show in green. if ( negBuff < 0 ) then text:SetText(RED_FONT_COLOR_CODE..effectiveStat..FONT_COLOR_CODE_CLOSE); else text:SetText(GREEN_FONT_COLOR_CODE..effectiveStat..FONT_COLOR_CODE_CLOSE); end end end end function stats_OnShow() stats_SetStats(); end function stats_OnHide() --CharacterFrameCharacterTabButton:Enable(); -- for i=1, NUM_SHOPPING_TOOLTIPS, 1 do -- getglobal("ShoppingTooltip"..i):Hide(); -- end end function statsStatTooltip(unit, stat) if ( not unit ) then unit = "player"; end -- Get class specific tooltip for that stat local temp, classFileName = UnitClass(unit); local classStatText = getglobal(strupper(classFileName).."_"..stat.."_".."TOOLTIP"); -- If can't find one use the default if ( not classStatText ) then classStatText = getglobal("DEFAULT".."_"..stat.."_".."TOOLTIP"); end GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); GameTooltip:SetText(this.tooltip); GameTooltip:AddLine(classStatText, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1); GameTooltip:Show(); end function statsFormatStat(name, base, posBuff, negBuff, frame, textString) local effective = max(0,base + posBuff + negBuff); local text = HIGHLIGHT_FONT_COLOR_CODE..name.." "..effective; if ( ( posBuff == 0 ) and ( negBuff == 0 ) ) then text = text..FONT_COLOR_CODE_CLOSE; textString:SetText(effective); else if ( posBuff > 0 or negBuff < 0 ) then text = text.." ("..base..FONT_COLOR_CODE_CLOSE; end if ( posBuff > 0 ) then text = text..FONT_COLOR_CODE_CLOSE..GREEN_FONT_COLOR_CODE.."+"..posBuff..FONT_COLOR_CODE_CLOSE; end if ( negBuff < 0 ) then text = text..RED_FONT_COLOR_CODE.." "..negBuff..FONT_COLOR_CODE_CLOSE; end if ( posBuff > 0 or negBuff < 0 ) then text = text..HIGHLIGHT_FONT_COLOR_CODE..")"..FONT_COLOR_CODE_CLOSE; end -- if there is a negative buff then show the main number in red, even if there are -- positive buffs. Otherwise show the number in green if ( negBuff < 0 ) then textString:SetText(RED_FONT_COLOR_CODE..effective..FONT_COLOR_CODE_CLOSE); else textString:SetText(GREEN_FONT_COLOR_CODE..effective..FONT_COLOR_CODE_CLOSE); end end frame.tooltip = text; end Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd"> <Script file="stats.lua"/> <Frame name="AttributeFrameTemplate" virtual="true"> <Size> <AbsDimension x="104" y="13"/> </Size> <Layers> <Layer level="BACKGROUND"> <FontString name="$parentLabel" inherits="GameFontNormalSmall"> <Anchors> <Anchor point="LEFT"/> </Anchors> </FontString> </Layer> </Layers> <Frames> <Frame name="$parentStat"> <Size> <AbsDimension x="30" y="13"/> </Size> <Anchors> <Anchor point="RIGHT"/> </Anchors> <Layers> <Layer level="BACKGROUND"> <FontString name="$parentText" inherits="GameFontHighlightSmall" justifyH="RIGHT"> <Anchors> <Anchor point="RIGHT"/> </Anchors> </FontString> </Layer> </Layers> </Frame> </Frames> </Frame> <Frame name="CharacterAttributesFrame"> <Size> <AbsDimension x="230" y="78"/> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="67" y="-291"/> </Offset> </Anchor> </Anchors> <Layers> <Layer level="BACKGROUND"> <Texture name="PlayerStatBackgroundTop" file="Interface\PaperDollInfoFrame\UI-Character-StatBackground"> <Size> <AbsDimension x="115" y="16"/> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <TexCoords left="0" right="0.8984375" top="0" bottom="0.125"/> </Texture> <Texture name="PlayerStatBackgroundMiddle" file="Interface\PaperDollInfoFrame\UI-Character-StatBackground"> <Size> <AbsDimension x="115" y="53"/> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="PlayerStatBackgroundTop" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <TexCoords left="0" right="0.8984375" top="0.125" bottom="0.1953125"/> </Texture> <Texture name="PlayerStatBackgroundBottom" file="Interface\PaperDollInfoFrame\UI-Character-StatBackground"> <Size> <AbsDimension x="115" y="16"/> </Size> <Anchors> <Anchor point="TOPLEFT" relativeTo="PlayerStatBackgroundMiddle" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <TexCoords left="0" right="0.8984375" top="0.484375" bottom="0.609375"/> </Texture> </Layer> </Layers> <Frames> <Frame name="CharacterStatFrame1" inherits="AttributeFrameTemplate" id="1"> <Anchors> <Anchor point="TOPLEFT"> <Offset> <AbsDimension x="6" y="-3"/> </Offset> </Anchor> </Anchors> <Scripts> <OnEnter> statsStatTooltip("player", "STRENGTH"); </OnEnter> <OnLeave> GameTooltip:Hide(); </OnLeave> </Scripts> </Frame> <Frame name="CharacterStatFrame2" inherits="AttributeFrameTemplate" id="2"> <Anchors> <Anchor point="TOPLEFT" relativeTo="CharacterStatFrame1" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <Scripts> <OnEnter> statsStatTooltip("player", "AGILITY"); </OnEnter> <OnLeave> GameTooltip:Hide(); </OnLeave> </Scripts> </Frame> <Frame name="CharacterStatFrame3" inherits="AttributeFrameTemplate" id="3"> <Anchors> <Anchor point="TOPLEFT" relativeTo="CharacterStatFrame2" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <Scripts> <OnEnter> statsStatTooltip("player", "STAMINA"); </OnEnter> <OnLeave> GameTooltip:Hide(); </OnLeave> </Scripts> </Frame> <Frame name="CharacterStatFrame4" inherits="AttributeFrameTemplate" id="4"> <Anchors> <Anchor point="TOPLEFT" relativeTo="CharacterStatFrame3" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <Scripts> <OnEnter> statsStatTooltip("player", "INTELLECT"); </OnEnter> <OnLeave> GameTooltip:Hide(); </OnLeave> </Scripts> </Frame> <Frame name="CharacterStatFrame5" inherits="AttributeFrameTemplate" id="5"> <Anchors> <Anchor point="TOPLEFT" relativeTo="CharacterStatFrame4" relativePoint="BOTTOMLEFT"> <Offset> <AbsDimension x="0" y="0"/> </Offset> </Anchor> </Anchors> <Scripts> <OnEnter> statsStatTooltip("player", "SPIRIT"); </OnEnter> <OnLeave> GameTooltip:Hide(); </OnLeave> </Scripts> </Frame> </Frames> <Scripts> <OnLoad> statsFrame_OnLoad(); </OnLoad> <OnEvent> statsFrame_OnEvent(event, arg1); </OnEvent> <OnShow> statsFrame_OnShow(); </OnShow> <OnHide> statsFrame_OnHide(); </OnHide> </Scripts> </Frame> </Ui> well thanks in advace hopefully someone can help me out here chop |
|
WoWInterface » Developer Discussions » General Authoring Discussion » a stats panel |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|