Thread Tools Display Modes
10-22-10, 09:30 PM   #1
braininblack
A Murloc Raider
 
braininblack's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 8
SetTexture(path, false) = nil Value?

Hi guys,

i want to use SetTexture on the my XML-Button-Template:
Code:
<!-- Template -->
<Button name="ToolbarButtonTemplate" virtual="true">
	<Size>
		<AbsDimension x="26" y="26" />
	</Size>
	<Layers>
		<Layer level="ARTWORK">
			<Texture name="$parentIcon">
				<Size>
					<AbsDimension x="20" y="20" />
				</Size>
				<Anchors>
					<Anchor point="CENTER" />
				</Anchors>
			</Texture>
		</Layer>
	</Layers>
	<Backdrop edgeFile="Interface\AddOns\MarkBar\tex\border.tga" tile="false">
		<EdgeSize>
			<AbsValue val="10" />
		</EdgeSize>
	</Backdrop>
	<Scripts>
		<OnLoad>
			MarkBar.MarkOnLoad(self);
		</OnLoad>
	</Scripts>
	<!-- Some More Scripts -->
</Button>

<!-- Button -->
<Button name="MarkBarMarkM1" inherits="ToolbarButtonTemplate" id="1">
	<Anchors>
		<Anchor point="TOPLEFT">
			<Offset>
				<AbsDimension x="186" y="-4"/>
			</Offset>
		</Anchor>
	</Anchors>
</Button>

OnLoad run this script:
Code:
function MarkBar.MarkOnLoad(self)
	local frame = self:GetName();
	local id = self:GetID();
	local icon = frame.."Icon";
	local path = "Interface\\AddOns\\MarkBar\\tex\\"..id..".tga";

	self:SetTexture(path, false);
end
And some other stuff, but have nothing to do with the SetTexture() stuff.


With this code, i getting a nil value for SetTexture(), even when i hardcode the path ("Interface\\AddOns\\MarkBar\\tex\1.tga"). Whats wrong with that?


Sry for the bad english. itīs a quite while since i used english for describing a problem
  Reply With Quote
10-22-10, 09:37 PM   #2
Taroven
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 49
Button objects don't use SetTexture. You can probably get away with using self:SetNormalTexture('TexturePathHere'). There's no second argument to it, nor would you need one anyway if it's always going to be nil/false.
__________________
Former author of EventHorizon Continued and Other Releases.
  Reply With Quote
10-23-10, 09:39 AM   #3
braininblack
A Murloc Raider
 
braininblack's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 8
Originally Posted by Taroven View Post
Button objects don't use SetTexture. You can probably get away with using self:SetNormalTexture('TexturePathHere'). There's no second argument to it, nor would you need one anyway if it's always going to be nil/false.
Thanks for the info... but doesenīt work as i hoped. Used the long way now
  Reply With Quote
10-27-10, 03:20 AM   #4
braininblack
A Murloc Raider
 
braininblack's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2008
Posts: 8
After some hours of research, i find a way to use SetTexture() on Buttons:

XML Template:
Code:
<!-- Template -->
<Button name="Template" virtual="true">
	<!-- other stuff -->
	<Layers>
		<Layer level="ARTWORK">
			<Texture parentKey="icon">
				<Size>
					<AbsDimension x="20" y="20" />
				</Size>
				<Anchors>
					<Anchor point="CENTER" />
				</Anchors>
			</Texture>
		</Layer>
	</Layers>
	<!-- more other stuff -->
</Button>
Just use the "parentKey" attribute instead of the "name" attribute.


Lua:
Code:
frame.icon:SetTexture(path);
Very simple
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetTexture(path, false) = nil Value?


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