Thread Tools Display Modes
10-19-16, 04:54 PM   #1
Twitchy250
A Deviate Faerie Dragon
Join Date: Aug 2016
Posts: 14
Attempt to Index Global

Hello Wow Interface,

I am new at add-on development and came here in the hope to get some help, all help is appreciated!

First off I want to note am vaguely familiar with event handling and have not gotten to that part yet.

I am working on a simple Auction House Add-on for different search function-ability.

So far I have managed to hook my code into the Blizzards Auction UI, I have successfully created a new tab in the auction house but got overlapped by other add-ons, so I decided to have a separate frame that opens with the AH (which I was successful) and added the new tab to the new frame.

What I'm having troubles with is, when I click the tab the auction house will change tabs successfully (I don't know why, but good), but when I add an onlcick handler to the tab button the AH loses the ability to change tabs and gives an error. I assume the onlick handler is what will hide content on the ah and display the new content

The Code:

Urchin.toc
Code:
## Interface: 70000
## Title: Urchin
## Version: 0.1
## LoadOnDemand: 1
## LoadWith: Blizzard_AuctionUI

Urchin.xml
Urchin.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Urchin.lua"/>
<Script file="UI/AdvancedSellTab.xml"/>
   <Frame
       name="myTabContainerFrame"
       toplevel="true"
       frameStrata="DIALOG"
       movable="true"
       enableMouse="true"
       hidden="false"
       parent="AuctionFrame">
       <Size>
           <AbsDimension x="480" y="325"/>
       </Size>
       <Anchors>
           <Anchor point="CENTER">
               <Offset><AbsDimension x="-200" y="200"/></Offset>
           </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>
       <Layers>
           <Layer level="ARTWORK">
               <Texture name="myFrameHeader" file="Interface\DialogFrame\UI-DialogBox-Header">
                   <Size>
                       <AbsDimension x="356" y="64"/>
                   </Size>
                   <Anchors>
                       <Anchor point="TOP">
                           <Offset>
                               <AbsDimension x="0" y="12"/>
                           </Offset>
                       </Anchor>
                   </Anchors>
               </Texture>
               <FontString inherits="GameFontNormal" text="My Frame">
                   <Anchors>
                       <Anchor point="TOP" relativeTo="myFrameHeader">
                           <Offset>
                               <AbsDimension x="0" y="-14"/>
                           </Offset>
                       </Anchor>
                   </Anchors>
               </FontString>
           </Layer>
       </Layers>
       <Frames>
       			<Button name="AuctionFrameTab4" inherits="AuctionTabTemplate" id="4" text="New">
				<Anchors>
					<Anchor point="TOPLEFT" relativePoint="TOPRIGHT">
						<Offset>
							<AbsDimension x="-8" y="0"/>
						</Offset>
					</Anchor>
				</Anchors>
				  <Scripts>
                                     <OnClick>AdvancedSellTabFrame:show();</OnClick>
                                  </Scripts>
			</Button>
	</Frames>
        <Scripts>
  <OnLoad>self:RegisterForDrag("LeftButton");</OnLoad>
  <OnDragStart>self:StartMoving();</OnDragStart>
  <OnDragStop>self:StopMovingOrSizing();</OnDragStop>
 </Scripts>
   </Frame>
</Ui>
Urchin.lua is blank

AdvancedSellTab.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
   <Frame
       name="AdvancedSellTabFrame"
       toplevel="true"
       frameStrata="DIALOG"
       movable="true"
       enableMouse="true"
       hidden="true"
       parent="AuctionFrame">
       <Size>
           <AbsDimension x="480" y="325"/>
       </Size>
       <Anchors>
           <Anchor point="CENTER">
               <Offset><AbsDimension x="-200" y="200"/></Offset>
           </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>
       <Layers>
           <Layer level="ARTWORK">
               <Texture name="myFrameHeader" file="Interface\DialogFrame\UI-DialogBox-Header">
                   <Size>
                       <AbsDimension x="356" y="64"/>
                   </Size>
                   <Anchors>
                       <Anchor point="TOP">
                           <Offset>
                               <AbsDimension x="0" y="12"/>
                           </Offset>
                       </Anchor>
                   </Anchors>
               </Texture>
               <FontString inherits="GameFontNormal" text="My Frame">
                   <Anchors>
                       <Anchor point="TOP" relativeTo="myFrameHeader">
                           <Offset>
                               <AbsDimension x="0" y="-14"/>
                           </Offset>
                       </Anchor>
                   </Anchors>
               </FontString>
           </Layer>
       </Layers>
       <Frames>
			</Frames>
   </Frame>
</Ui>
I know it looks and feels a little different/funny, but in my overall goal that frame that acts external will be a separate window within the AH allowing multitasking. The tab hanging off of the right of the window will influence the actual AH shown frames, and eventually at the bottom of the new window will have separate tabs specifically for the floating window.

When I get rid of the OnClick for the tab button the AH changes tabs successfully, but when I use the OnClick to show the new AH frame that overlays the AH (not the floating window) I just get an error

Code:
Message: [string "AuctionFrameTab4:OnClick"]:1: attempt to index global 'AdvancedSellTabFrame' (a nil value)
Time: 10/19/16 17:22:22
Count: 4
Stack: [string "*:OnClick"]:1: in function <[string "*:OnClick"]:1>

Locals: self = AuctionFrameTab4 {
 0 = <userdata>
}
button = "LeftButton"
down = false
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to index global 'AdvancedSellTabFrame' (a nil value)"
Also to note that the frame code was ripped from wowwiki for the time being (just my way of getting a hold of things)

I do have prior experience with php

I hope this was explanatory enough, thank you for any help
  Reply With Quote
10-19-16, 05:05 PM   #2
Twitchy250
A Deviate Faerie Dragon
Join Date: Aug 2016
Posts: 14
Also forgot to note, the floating window is dragable and loads in a weird spot as of now. Just drag and move and both the window and the AH should be visible
  Reply With Quote
10-19-16, 05:30 PM   #3
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
I'm not sure that this is valid:
Code:
<Script file="UI/AdvancedSellTab.xml"/>
Try loading that file in the ToC instead. If it isn't valid, then AdvancedSellTabFrame would never have been created, which is what the error implies.

When you say it doesn't change the tab, I assume you mean that its appearance isn't updated so that it looks like a selected tab? Most likely that is because the template for the auction tabs has an OnClick handler that does that, which you replace when you set your own OnClick handler. You'll want to include the original behaviour somehow. You could for example do this:
Code:
<OnClick>
	AuctionFrameTab_OnClick(self, button)
	AdvancedSellTabFrame:Show()
</OnClick>
Note the capital S in :Show(), too!
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-19-16, 05:39 PM   #4
Twitchy250
A Deviate Faerie Dragon
Join Date: Aug 2016
Posts: 14
This worked excellent! Thank you very much.

It is greatly appreciated
  Reply With Quote
10-19-16, 05:47 PM   #5
Twitchy250
A Deviate Faerie Dragon
Join Date: Aug 2016
Posts: 14
Now I am presented with another problem.

The Auction window displays when the tab is clicked, but when clicking on another AH tab the frame doesn't have a way of hiding and covers the content of other tabs
  Reply With Quote
10-19-16, 05:52 PM   #6
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
[quote=Lombra;320018]I'm not sure that this is valid:
Code:
<Script file="UI/AdvancedSellTab.xml"/>
That is valid XML syntax, used for including other XML files. I do this in a few of my AddOns.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
10-19-16, 06:00 PM   #7
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Torhal View Post
Originally Posted by Lombra View Post
I'm not sure that this is valid:
Code:
<Script file="UI/AdvancedSellTab.xml"/>
That is valid XML syntax, used for including other XML files. I do this in a few of my AddOns.
Right, come to think of it, "embeds" files do this all the time. But with "Include", though. Are you sure "Script" works?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-19-16, 06:11 PM   #8
Twitchy250
A Deviate Faerie Dragon
Join Date: Aug 2016
Posts: 14
I found a work around. I just created a new button to hide the frame. It looks a little messy but it will work
  Reply With Quote
10-19-16, 06:14 PM   #9
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Twitchy250 View Post
Now I am presented with another problem.

The Auction window displays when the tab is clicked, but when clicking on another AH tab the frame doesn't have a way of hiding and covers the content of other tabs
Looks like you should be able to do this as a convenient hack.
Code:
AuctionFrameTab4:SetScript("OnEnable", function(self)
	AdvancedSellTabFrame:Hide()
end)
When you select a tab it gets disabled (unclickable) and the other tabs get enabled, so you can use that to detect when yours become inactive.

Put the code in your Lua file, or in some OnLoad script, and make sure it executes after AuctionFrameTab4 has been created.

Edit: Wait what am I talking about?! Since you're already using XML, you can of course do it directly on the tab, as well.
Code:
<OnEnable>
	AdvancedSellTabFrame:Hide()
</OnEnable>
__________________
Grab your sword and fight the Horde!

Last edited by Lombra : 10-19-16 at 06:16 PM.
  Reply With Quote
10-19-16, 06:36 PM   #10
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Lombra View Post
Right, come to think of it, "embeds" files do this all the time. But with "Include", though. Are you sure "Script" works?
Ah, you're correct - I didn't notice it said Script rather than Include. The former would be for .lua files.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
10-20-16, 03:14 AM   #11
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Instead of passing the old OnClick handler, I highly suggest using PreClick or PostClick. Those are script handlers specifically for us so we don't mess with OnClick handlers. They are called exactly as they are named, and are functionally the same as OnClick.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Attempt to Index Global


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off