WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   buttons and textures (a pro post on getting help) (from Phanx) (#needsalife)) (https://www.wowinterface.com/forums/showthread.php?t=51826)

10leej 02-03-15 02:23 AM

buttons and textures (a pro post on getting help) (from Phanx) (#needsalife))
 
DISCLAIMER! (In big red text!)
I'm really really really bored! So I attempted to make a good post for Phanx's sake


Anyways:

I feel like my buttons are screwed up somewhere >.> or I missed another stupid thing. Or I really did forget how to do stuff lua or rather in general.

Phanx (or someone else ;) ) please point out the error in my ways! all my buttons are the same texture even though they should be diffeent colors!

code (because I'm a good OP like that!)

Lua Code:
  1. local use_Minimap = false --disabling this forces Click Menu to make a button
  2. local button_location = { "CENTER", UIParent, "CENTER", 0, 0 }
  3. local blizzard_theme = false
  4. local color_normal = { 1, 1, 1, 0.5 }
  5. local color_hover = { 1, 0, 1, 0.5 }
  6. local color_pushed = { 1, 1, 0, 0.5 }
  7.  
  8.   local button = CreateFrame("Button", nil, mainframe)
  9.   button:SetPoint(unpack(button_location))
  10.   button:SetWidth(50)
  11.   button:SetHeight(25)
  12.  
  13.   button:SetText("Menu")
  14.   button:SetNormalFontObject("GameFontNormal")
  15.  
  16.   local ntex = button:CreateTexture()
  17.   if blizzard_theme then
  18.     ntex:SetTexture("Interface/Buttons/UI-Panel-Button-Up")
  19.   else
  20.     ntex:SetTexture("Interface\\Buttons\\WHITE8x8")
  21.     ntex:SetVertexColor("color_normal")
  22.   end
  23.   ntex:SetTexCoord(0, 0.625, 0, 0.6875)
  24.   ntex:SetAllPoints()
  25.   button:SetNormalTexture(ntex)
  26.  
  27.   local htex = button:CreateTexture()
  28.   if blizzard_theme then
  29.     htex:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight")
  30.   else
  31.     htex:SetTexture("Interface\\Buttons\\WHITE8x8")
  32.     htex:SetVertexColor("color_hover")
  33.   end
  34.   htex:SetTexCoord(0, 0.625, 0, 0.6875)
  35.   htex:SetAllPoints()
  36.   button:SetHighlightTexture(htex)
  37.  
  38.   local ptex = button:CreateTexture()
  39.   if blizzard_theme then
  40.     ptex:SetTexture("Interface/Buttons/UI-Panel-Button-Down")
  41.   else
  42.     ptex:SetTexture("Interface\\Buttons\\WHITE8x8")
  43.     ptex:SetVertexColor("color_pushed")
  44.   end
  45.   ptex:SetTexCoord(0, 0.625, 0, 0.6875)
  46.   ptex:SetAllPoints()
  47.   button:SetPushedTexture(ptex)
  48.  
  49.   button:SetScript('OnMouseUp', function(self, button)
  50.     if button == "LeftButton" or button == "RightButton" then
  51.       securecall(EasyMenu, menuList, menuFrame, self, 27, 190, 'MENU', 8)
  52.     end
  53.   end)
  54. end

TL;DR
I need to go to bed and get some sleep been up for well over 48 hours at this point.....

10leej 02-03-15 02:30 AM

for a more common style help post

Quote:

Me: "My button textures are all broke can I getz help"
Phanx: "post your code!"
Seerah: "post your code!"
Someone Else: "post your code!"
Me: It's this
Lua Code:
  1. frame:SetTexture("texturename")
Phanx: /facepalm "Need MOAR CODEZ"
Me: I'm sorry Phanx I don't understand what mmore you need I gave you plenty!"
Phanx: Insert long rant about why Phanx should just give up and stop helping 10leej
Me: BUT I WANTZ HELP!
Seerah: "Post more code next time" /closethread
Dammit I'm going to sleep I'll let this all play out and look at all the replays later before I start posting more hypothetical scenarios for Phanx......

Choonstertwo 02-03-15 03:07 AM

lua Code:
  1. ntex:SetVertexColor("color_normal")

You're passing a string to SetVertexColor instead of the RGBA values it expects.

This is what you want:
lua Code:
  1. ntex:SetVertexColor(unpack(color_normal))

This unpacks the color_normal table into the four numbers expected by SetVertexColor.

10leej 02-04-15 12:05 AM

Quote:

Originally Posted by Choonstertwo (Post 306003)
lua Code:
  1. ntex:SetVertexColor("color_normal")

You're passing a string to SetVertexColor instead of the RGBA values it expects.

This is what you want:
lua Code:
  1. ntex:SetVertexColor(unpack(color_normal))

This unpacks the color_normal table into the four numbers expected by SetVertexColor.

Ah it's a
Quote:

I missed another stupid thing. Or I really did forget how to do stuff lua or rather in general.
type of thing then....

(I feel like Phanx is avoiding me now...)

Phanx 02-04-15 12:19 AM

Quote:

Originally Posted by 10leej (Post 306045)
(I feel like Phanx is avoiding me now...)

No point in replying when someone else already answered the question.


All times are GMT -6. The time now is 12:51 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI