Thread Tools Display Modes
06-19-11, 03:15 PM   #1
Bleckpan
A Fallenroot Satyr
 
Bleckpan's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 22
SetTexture not working

I need some help with trying to figure out what event I need to register in order for my texture to display.
Code:
TBFrame:SetScript("OnEvent", function()

 SetMapByID(708)
 name, description, textureIndex, x, y = GetMapLandmarkInfo(1)
  if textureIndex == 46 then
   red = 0
   blue = 1
   green = 0
   Time:SetTextColor(red, green, blue)
   TBTexture:SetTexture("Interface/PVPFrame/PVP-Currency-Alliance")
  end
end)
I have the same thing for horde side also.

The event that I have this triggering off of is "PLAYER_ENTERING_WORLD". The little image doesn't show up until I either type in "/reload ui" or drag the frame. I can't think of any way this would happen, as the font ends up being colored correctly.

Any help would be appreciated greatly.

Last edited by Bleckpan : 06-19-11 at 04:04 PM. Reason: Typo
  Reply With Quote
06-19-11, 03:22 PM   #2
Neal
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 2
Try...

Code:
:SetTexture("Interface\\PVPFrame\\PVP-Currency-Alliance")
.. -_- havn't read until the end..

Try to load the texture outside the func
Code:
local texx = "Interface\\PVPFrame\\PVP-Currency-Alliance"

TBFrame:SetScript("OnEvent", function()

 SetMapByID(708)
 name, description, textureIndex, x, y = GetMapLandmarkInfo(1)
  if textureIndex == 46 then
   red = 0
   blue = 1
   green = 0
   Time:SetTextColor(red, green, blue)
   TBTexture:SetTexture(texx)
  end
end)

Last edited by Neal : 06-19-11 at 03:26 PM.
  Reply With Quote
06-19-11, 03:22 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
All you're doing is calling a pre-existing UI texture and there should be no problem, whenever you set the texture. Where is the rest of your code?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-19-11, 03:56 PM   #4
Bleckpan
A Fallenroot Satyr
 
Bleckpan's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 22
Originally Posted by Seerah View Post
All you're doing is calling a pre-existing UI texture and there should be no problem, whenever you set the texture. Where is the rest of your code?
This is all my code, sorry it is so messy, couldn't seem to find a website to paste it on.

Edit: http://pastebin.com/gjkHYY9z Thanks for the link!
Attached Files
File Type: lua timer.lua (3.7 KB, 643 views)

Last edited by Bleckpan : 06-19-11 at 05:00 PM.
  Reply With Quote
06-19-11, 04:06 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Neal View Post
Try...

Code:
:SetTexture("Interface\\PVPFrame\\PVP-Currency-Alliance")
Oh wow - I totally missed that. No wonder your texture doesn't show.

/edit: http://pastebin.com/
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-19-11, 04:11 PM   #6
Bleckpan
A Fallenroot Satyr
 
Bleckpan's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 22
Originally Posted by Seerah View Post
Oh wow - I totally missed that. No wonder your texture doesn't show.
It doesn't seem to fix my problem. It was working an hour ago with just a single forward slash instead of double backslashes.
  Reply With Quote
06-19-11, 04:15 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
It shouldn't have been. Hmm... maybe because it was forward-slash rather than back-slash? Just to be clear, did you try making the change?
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-19-11, 04:22 PM   #8
Bleckpan
A Fallenroot Satyr
 
Bleckpan's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 22
After reading through it a few times, I found:
Code:
 TBFrame:SetScript("OnEvent", function()
SetMapByID(708)
name, description, textureIndex, x, y = GetMapLandmarkInfo(1)
					
 if textureIndex == 46 then
   red = 0
   blue = 1
   green = 0
   Time:SetTextColor(red, green, blue)
   TBTexture:SetTexture(Ally)
 end
					
 if textureIndex == 48 then
   red = 1.0
   blue = 0
   green = 0
   Time:SetTextColor(red, green, blue)
   TBTexture:SetTexture(Horde)
 end	
 _,_,_,_,WaitTime,_ = GetWorldPVPAreaInfo(2)
TBTexture:SetTexture(Faction)
end)
So that puts me right where I started. No image upon login, but it works fine after a reloading of the ui, or a dragging of the frame.

I did make the change from one forward-slash to two back-slashes for both file paths. The only thing that I would think would be the problem is it not being able to access the map when it is being triggered. I am pulling the time from the PvP frame, so you may not have access to the map until a later time.

Last edited by Bleckpan : 06-19-11 at 04:28 PM. Reason: Forward to Back, Logic
  Reply With Quote
06-19-11, 04:37 PM   #9
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
All regions need a size and at least one anchor to render properly. Your code doesn't give TBTexture a size though, implicitly or explicitly. If you want TBTexture to fill TBFrame exactly, you can use TBTexture:SetAllPoints() instead of your SetPoint call on line 111.
  Reply With Quote
06-19-11, 04:43 PM   #10
Bleckpan
A Fallenroot Satyr
 
Bleckpan's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 22
Originally Posted by Saiket View Post
All regions need a size and at least one anchor to render properly. Your code doesn't give TBTexture a size though, implicitly or explicitly. If you want TBTexture to fill TBFrame exactly, you can use TBTexture:SetAllPoints() instead of your SetPoint call on line 111.
Thank you, that seems to have solved it for me. But, I have one more question. Why was this affecting the image only when I logged in, rather than all the time? (Reloading the UI and/or dragging the frame)
  Reply With Quote
06-20-11, 03:44 PM   #11
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
Originally Posted by Bleckpan View Post
Thank you, that seems to have solved it for me. But, I have one more question. Why was this affecting the image only when I logged in, rather than all the time? (Reloading the UI and/or dragging the frame)
That confused me too, since frames normally stay hidden until they have a size. It seems like textures behave slightly different though: They automatically resize to match their image file's dimensions if their size is undefined. I'm not sure, but I'd blame your hidden texture problem on a bug with this auto-size behavior.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SetTexture not working


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