Hallo, ich will für den
Hunter ein Addon schreiben, welches NUR den Zufriedenheitsframe des Pets anzeigt. hier sind die LUA und XML dateien:
Code:
function.lua
local happiness;
function out(text)
DEFAULT_CHAT_FRAME:AddMessage(text)
end
function error(textmsg)
UIErrorsFrame:AddMessage(textmsg, 1.0, 1.0, 0, 1, 10)
end
function FaraFrames_OnLoad()
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("PLAYER_LOGIN");
this:RegisterEvent("PLAYER_PET_CHANGED");
this:RegisterEvent("UNIT_AURA");
this:RegisterEvent("UNIT_COMBAT");
this:RegisterEvent("UNIT_DISPLAYPOWER");
this:RegisterEvent("UNIT_FOCUS");
this:RegisterEvent("UNIT_HAPPINESS");
this:RegisterEvent("UNIT_HEALTH");
this:RegisterEvent("UNIT_LEVEL");
this:RegisterEvent("UNIT_MANA");
this:RegisterEvent("UNIT_MAXFOCUS");
this:RegisterEvent("UNIT_MAXHEALTH");
this:RegisterEvent("UNIT_MAXMANA");
this:RegisterEvent("UNIT_MODEL_CHANGED");
this:RegisterEvent("UNIT_NAME_UPDATE");
this:RegisterEvent("UNIT_PET");
this:RegisterEvent("UNIT_PET_EXPERIENCE");
this:RegisterEvent("UNIT_PORTRAIT_UPDATE");
this:RegisterEvent("UNIT_SPELLMISS");
out("Pet Satisfaction erfolgreich geladen.");
SLASH_FARAFRAMES1 = "/petsatisfaction";
SLASH_FARAFRAMES2 = "/ps";
SlashCmdList["FARAFRAMES"] = function(msg)
FaraFrames_SlashCommandHandler(msg);
end
this:SetAttribute("unit", "pet");
end
function Pet_Satisfaction_Events:UNIT_HAPPINESS()
Pet_Satisfaction_Set_Happiness();
end
function Pet_Satisfaction_Set_Happiness()
happiness = GetPetHappiness();
if (happiness == 1) then
Pet_Satisfaction_Texture:SetTexCoord(0.375, 0.5625, 0, 0.359375);
elseif (happiness == 2) then
Pet_Satisfaction_Texture:SetTexCoord(0.1875, 0.375, 0, 0.359375);
elseif (happiness == 3) then
Pet_Satisfaction_Texture:SetTexCoord(0, 0.1875, 0, 0.359375);
end
end
function FaraFrames_SlashCommandHandler(msg)
FaraFrames_Toggle(msg);
end
function FaraFrames_Toggle(num)
local frame = getglobal("FaraFrames" .. num)
if (frame) then
if( frame:IsVisible() ) then
frame:Hide();
else
frame:Show();
end
end
end
Code:
interface.xml
<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/">
<Script file="functions.lua"/>
<!-- Here the Scripts that have to be Executed -->
<Frame name="FaraFrames_GeneralScripts" hidden="true">
<Scripts> <OnLoad> FaraFrames_OnLoad(); </OnLoad></Scripts>
</Frame>
<Frame name="FaraFrames" hidden="true" virtual="true" parent="UIParent">
<!-- set the size of the frame -->
<Size>
<AbsDimension x="200" y="200"/>
</Size>
<!-- set where the frame will be anchored -->
<Anchors>
<Anchor point="CENTER" />
</Anchors>
<!-- set the parameters for the layers of the frame -->
<Layers>
<Layer level="BACKGROUND">
<Texture name="$parent_Background" setAllPoints="true">
<!-- Texture has blue color wit 50% alpha -->
<Color r="0" g="0" b="1" a="0.5" />
</Texture>
</Layer>
</Layers>
<!-- event handling -->
</Frame>
<!-- We now create a new Template with frameStrata="DIALOG" the Backdrop Border definitions work only correctly with the Dialog type of Frame -->
<Frame name="FaraFramesDialog" hidden="true" toplevel="true" virtual="true" frameStrata="DIALOG" parent="UIParent">
<Size>
<AbsDimension x="24" y="23"/>
</Size>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
<Backdrop tile="true">
<TileSize>
<AbsValue val="32"/>
</TileSize>
<EdgeSize>
<AbsValue val="32"/>
</EdgeSize>
<BackgroundInsets>
<AbsInset left="11" right="12" top="12" bottom="11"/>
</BackgroundInsets>
</Backdrop>
</Frame>
<Frame name="FaraFramesshow" inherits="FaraFramesDialog" movable="true" enableMouse="true">
<Size>
<AbsDimension x="24" y="23"/>
</Size>
<Anchors>
<Anchor point="TOP">
<Offset>
<AbsDimension x="0" y="-5"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="BACKGROUND">
<Texture name="Pet_Satisfaction_Texture" file="Interface\PetPaperDollFrame\UI-PetHappiness" setAllPoints="true">
<Size>
<AbsDimension x="24" y="23"/>
</Size>
<TexCoords left="0" right="0.1875" top="0" bottom="0.359375"/>
</Texture>
</Layer>
</Layers>
<Scripts>
<OnMouseDown> this:StartMoving(); </OnMouseDown>
<OnMouseUp> this:StopMovingOrSizing(); </OnMouseUp>
<OnDragStop> this:StopMovingOrSizing(); </OnDragStop>
</Scripts>
</Frame>
</Ui>
Code:
PetSatisfaction.toc
## Interface: 20400
## Title: PetSatisfaction
## Notes: Die Petzufriedenheits Frame.
## SavedVariablesPerCharacter: Pet_Satisfaction_Save
## Version: 1.0
## Author: uddy
interface.xml
Ich hoffe auf schnelle antwort