08-03-05, 12:29 AM | #1 |
A lil help please
Hi there, if you guys have used CT_mod or Insomniax, youve probably seen the class box on top of the target frame showing the class of your target.
Im trying to make a simple addon that would make a similar box that is draggable which i can use with whatever mod i want. A standalone you might say. I tried ripping code from the old money_display and CT_unitframes and came up with this. The xml file: <Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/"> <Script file="Myown.lua"/> <Frame name="MyownFrame" frameStrata="BACKGROUND" toplevel="true" enableMouse="false" movable="true" parent="UIParent"> <Size> <AbsDimension x="125" y="25"/> </Size> <Backdrop name="MyownBackdrop" bgFile="Interface\TutorialFrame\TutorialFrameBackground" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true"> <EdgeSize> <AbsValue val="16"/> </EdgeSize> <TileSize> <AbsValue val="16"/> </TileSize> <BackgroundInsets> <AbsInset left="3" right="5" top="3" bottom="5"/> </BackgroundInsets> </Backdrop> <Layers> <Layer level="ARTWORK"> <FontString name="MyownText" hidden="false" inherits="GameFontNormal" text=""> <Anchors> <Anchor point="CENTER"/> </Anchors> </FontString> </Layer> </Layers> <Scripts> <OnLoad> this:SetBackdropColor(0, 0, 1, 0.5); this:RegisterEvent("UNIT_FACTION"); this:RegisterEvent("UNIT_DYNAMIC_FLAGS"); this:RegisterEvent("PLAYER_TARGET_CHANGED"); this:RegisterEvent("PARTY_MEMBERS_CHANGED"); </OnLoad> <OnEvent> Myown_SetTargetClass(); if event == "VARIABLES_LOADED" then MO_LoadVariables(); end </OnEvent> <OnMouseDown> if ( arg1 == "LeftButton" ) then MyownFrame:StartMoving(); end </OnMouseDown> <OnMouseUp> if ( arg1 == "LeftButton" ) then MyownFrame:StopMovingOrSizing(); MO_SavePosition(); end </OnMouseUp> </Scripts> </Frame> </Frame> </Ui> The Lua file: function Myown_SetTargetClass() if ( not UnitExists("target") ) then return; end local r, g, b; r = 0; g = 0; b = 1; if ( UnitPlayerControlled("target") ) then if ( UnitCanAttack("target", "player") ) then -- Hostile players are red if ( not UnitCanAttack("player", "target") ) then r = 0.0; g = 0.0; b = 1.0; else r = UnitReactionColor[2].r; g = UnitReactionColor[2].g; b = UnitReactionColor[2].b; end elseif ( UnitCanAttack("player", "target") ) then -- Players we can attack but which are not hostile are yellow r = UnitReactionColor[4].r; g = UnitReactionColor[4].g; b = UnitReactionColor[4].b; elseif ( UnitIsPVP("target") ) then -- Players we can assist but are PvP flagged are green r = UnitReactionColor[6].r; g = UnitReactionColor[6].g; b = UnitReactionColor[6].b; else -- All other players are blue (the usual state on the "blue" server) r = 0.0; g = 0.0; b = 1.0; end else local reaction = UnitReaction("target", "player"); if ( reaction ) then r = UnitReactionColor[reaction].r; g = UnitReactionColor[reaction].g; b = UnitReactionColor[reaction].b; else r = 0; g = 0; b = 1; end end if ( r == 1 and g == 0 and b == 0 ) then MyownFrame:SetBackdropColor(1, 0, 0, 1); else MyownFrame:SetBackdropColor(r, g, b, 0.5); end if ( UnitClass("target") ) then MyownText:SetText(UnitClass("target")); end end function MO_LoadVariables() if not MO_Save then MO_Save = { }; MO_Save.x = GetScreenWidth()/2; MO_Save.y = 50; end getglobal("MyownFrame"):ClearAllPoints(); getglobal("MyownFrame"):SetPoint("BOTTOMLEFT", "UIParent", "BOTTOMLEFT", MD_Save.x, MD_Save.y); end function MO_SavePosition() MO_Save.x = getglobal("MyownFrame"):GetLeft(); MO_Save.y = getglobal("MyownFrame"):GetBottom(); end The toc file: ## Interface: 4150 ## Title: Myown ## Notes: Display class ## OptionalDeps: ## Dependencies: ## SavedVariables: MO_Save Myown.xml I tried that but nothing appeared. Not even a small box. My initial comments would be that i removed an anchor from the main frame, is this a bad thing? Secondly, the top line of my XML may be truncated coz the usual thing i see is <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/ C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd"> Is that also a cause of problems? Like i said, i cant even see a box which i thought the initial frame in my XML would create (MyownFrame) Thanks. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » A lil help please |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|