|
01-29-15, 11:13 AM | #1 |
XML problem: Twice function call
Hi!
I'm new to addon programming and currently coding a LootCouncil-Addon for my guild. But as I said, I'm new to Lua and XML (not to programming in general) and since I've desperately tried to figure out what is wrong with my code, I've decided to ask people, who are more familiar with that. As english isn't my mother tongue, please forgive me my probably bad spelling. I have two addons, that consist of the same .lua-file with the exact identical code: Code:
local frame = CreateFrame("FRAME", "FooAddonFrame"); frame:RegisterEvent("PLAYER_ENTERING_WORLD"); frame:RegisterEvent("LOOT_OPENED"); local function eventHandler(self, event, ...) if (event == "PLAYER_ENTERING_WORLD") then print("Hello!"); end if (event == "LOOT_OPENED") then local texture, lootname, quantity, quality, locked = GetLootSlotInfo(1); print("You've found " .. lootname .. "!"); end end frame:SetScript("OnEvent", eventHandler); function Button1_OnClick() Frame1:Hide(); end Code:
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/"> <Script file="Frame.lua" /> <Frame name="Frame1" parent="UIParent" toplevel="true" movable="true" enableMouse="true"> <Size> <AbsDimension x="184" y="96" /> </Size> <Anchors> <Anchor point="CENTER"> <Offset x="-8" y="52" /> </Anchor> </Anchors> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11" /> </BackgroundInsets> <TileSize> <AbsValue val="32" /> </TileSize> <EdgeSize> <AbsValue val="32" /> </EdgeSize> </Backdrop> <Frames> <Button name="Button1" inherits="UIPanelButtonTemplate" text="Button1"> <Size> <AbsDimension x="75" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="50" y="-57" /> </Anchor> </Anchors> <Scripts> <OnClick>Button1_OnClick();</OnClick> </Scripts> </Button> </Frames> <Layers> <Layer level="OVERLAY"> <FontString name="FontString1" inherits="GameFontNormal" text="Hello, World!"> <Size> <AbsDimension x="80" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="50" y="-12" /> </Anchor> </Anchors> </FontString> </Layer> </Layers> </Frame> </Ui> Code:
<Ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.blizzard.com/wow/ui/"> <Script file="Frame.lua" /> <Frame name="ORC_FrameUser" hidden="true" parent="UIParent" toplevel="true" movable="true" enableMouse="true"> <Size> <AbsDimension x="514" y="514" /> </Size> <Anchors> <Anchor point="CENTER"> <Offset x="-6" y="-32" /> </Anchor> </Anchors> <Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true"> <BackgroundInsets> <AbsInset left="11" right="12" top="12" bottom="11" /> </BackgroundInsets> <TileSize> <AbsValue val="32" /> </TileSize> <EdgeSize> <AbsValue val="32" /> </EdgeSize> </Backdrop> <Frames> <Button name="ORC_UserSettings" inherits="UIPanelButtonTemplate" id="2" text="Settings"> <Size> <AbsDimension x="75" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="416" y="-17" /> </Anchor> </Anchors> <Scripts> <OnClick>ORC_UserSettings_OnClick();</OnClick> </Scripts> </Button> <Button name="ORC_UserNeed1" inherits="UIPanelButtonTemplate" id="5" text="Need"> <Size> <AbsDimension x="64" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="39" y="-330" /> </Anchor> </Anchors> </Button> <Button name="ORC_UserUpdate1" inherits="UIPanelButtonTemplate" id="6" text="Kl. Update"> <Size> <AbsDimension x="64" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="38" y="-359" /> </Anchor> </Anchors> <Scripts> <OnClick>ORC_UserUpdate_OnClick();</OnClick> </Scripts> </Button> <Button name="ORC_Button2nd1" inherits="UIPanelButtonTemplate" id="7" text="2nd"> <Size> <AbsDimension x="64" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="38" y="-389" /> </Anchor> </Anchors> </Button> <Button name="ORC_UserTransmogg1" inherits="UIPanelButtonTemplate" id="8" text="Transm."> <Size> <AbsDimension x="64" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="38" y="-419" /> </Anchor> </Anchors> </Button> <Button name="ORC_UserPass" inherits="UIPanelButtonTemplate" id="4" text="Passen"> <Size> <AbsDimension x="64" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="39" y="-301" /> </Anchor> </Anchors> <Scripts> <OnClick>ORC_UserPass_OnClick();</OnClick> </Scripts> </Button> <Button name="ORC_UserClose" inherits="UIPanelButtonTemplate" id="1" text="Schließen"> <Size> <AbsDimension x="75" y="23" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="233" y="-477" /> </Anchor> </Anchors> <Scripts> <OnClick>ORC_UserClose_OnClick();</OnClick> </Scripts> </Button> </Frames> <Layers> <Layer level="OVERLAY"> <FontString name="FontString1" inherits="GameFontNormal" text="Name:" justifyH="LEFT"> <Size> <AbsDimension x="80" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="12" y="-20" /> </Anchor> </Anchors> </FontString> <FontString name="ORC_UserName" inherits="GameFontNormal" text="Name" justifyH="LEFT"> <Size> <AbsDimension x="297" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="112" y="-20" /> </Anchor> </Anchors> </FontString> <FontString name="FontString2" inherits="GameFontNormal" text="Klasse:" justifyH="LEFT"> <Size> <AbsDimension x="80" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="12" y="-46" /> </Anchor> </Anchors> </FontString> <FontString name="ORC_UserClass" inherits="GameFontNormal" text="Class" justifyH="LEFT"> <Size> <AbsDimension x="297" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="112" y="-45" /> </Anchor> </Anchors> </FontString> <FontString name="Specc:" inherits="GameFontNormal" text="Specc:" justifyH="LEFT"> <Size> <AbsDimension x="80" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="12" y="-72" /> </Anchor> </Anchors> </FontString> <FontString name="ORC_UserSpecc" inherits="GameFontNormal" text="Specc" justifyH="LEFT"> <Size> <AbsDimension x="297" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="112" y="-72" /> </Anchor> </Anchors> </FontString> <FontString name="FontString3" inherits="GameFontNormal" text="Stat-Prio:" justifyH="LEFT"> <Size> <AbsDimension x="80" y="20" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="12" y="-112" /> </Anchor> </Anchors> </FontString> <FontString name="ORC_UserStatprio" inherits="GameFontNormal" text="Duxensteinigkeit > Bärtigkeit = STFU = kackamannistdoof" justifyV="TOP" justifyH="LEFT"> <Size> <AbsDimension x="474" y="60" /> </Size> <Anchors> <Anchor point="TOPLEFT"> <Offset x="12" y="-139" /> </Anchor> </Anchors> </FontString> </Layer> </Layers> </Frame> </Ui> Sincerly yours odjur84 |
|
01-29-15, 11:15 AM | #2 |
Check your toc file. Make sure your script is loaded in XML-File OR toc ... not in both.
__________________
The cataclysm broke the world ... and the pandas could not fix it! |
|
01-29-15, 11:23 AM | #3 |
Arg, I'm feeling so stupid.
Thank you very much! That did the trick. And I tought "no need to check the TOC-file.. what can go wrong with 3 lines?" |
|
01-29-15, 12:55 PM | #4 |
This is only the first trap when using xml I'd recommend to not use XML at all.
Lua can do most things that are needed without any XML.
__________________
The cataclysm broke the world ... and the pandas could not fix it! |
|
01-29-15, 02:18 PM | #5 |
Do you mean creating the XML-elements of the interface by using lua-code instead of using a separate XML-file? Or how do you create an interface without using XML at all?
|
|
01-29-15, 02:26 PM | #6 |
WoWInterface » Developer Discussions » Lua/XML Help » XML problem: Twice function call |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|