New to Addons : Issue with SetTexture
I am new to LUA and creating addons, but I am not new to programming in general. I am working on an extremely simple addon to begin to figure things out. All I am trying to do at the moment is create a big red box in the middle of the game screen. Here is the code I have.
Code:
SLASH_RELOADUI1 = "/rl" As far as I can tell, this should work. When I take a look at the frame stack, the frame is there but it isn't showing anything. I've included a link below to a screenshot of what I see with frame stack activated. I have bug grabber installed and it shows no errors. https://www.dropbox.com/scl/fi/v9q5h...f5k11dnwa&dl=0 If anyone could point out what I am doing wrong here, I would greatly appreciate it. |
Install BugGrabber and BugSack to help with debugging. They work together.
You should be getting an error Code:
local testFrame = CreateFrame("Frame", testFrame, UIParent) Code:
local testFrame.texture = testFrame:CreateTexture() Use: Code:
testFrame.texture = testFrame:CreateTexture() That and Code:
testFrame.texture:SetColorTexture(1,0,0,0.5) |
so, just to make sure I'm understanding this correctly. Please excuse my .Net (i know.. i know..) terminology.
the syntax testFrame.texture = testFrame:CreateTexture() is using the texture property of the testFrame (table) and then creating the texture to be applied to that property. is that right? If that is correct, then I completely understand why it wasn't working. Thank you! |
Any time you see local in front of a variable name, you're creating a new variable (type to be determined on the other side of the =).
Code:
local testFrame = CreateFrame("Frame", testFrame, UIParent) Lua Code:
Lua Code:
But you can't add a key to a table that hasn't been created which is what Code:
local testFrame.texture = testFrame:CreateTexture() |
Quote:
string value = "Something" (some other code) string value = "Nothing" This would throw an exception, whereas if you wanted to change the value it would look more like: string value = "Something" (some other code) value = "Nothing" However, in Lua, variables are not typed, so we just declare if it's a local. If you don't add the local then it defaults as a global and is accessible inside all of WoW |
Is your understanding of the syntax "testFrame.texture = testFrame:CreateTexture()" accurate, where it utilizes the texture property of the testFrame (table) and creates the texture to be applied to that property?
|
The .texture part is just making a table key, it could be anything. The :CreateTexture() creates the texture region and by using testFrame:CreateTexture() just means that testFrame will automatically be the parent of the new texture.
Code:
testFrame.SomethingToPutAPrettyPictureIn = testFrame:CreateTexture() Code:
testFrame["SomethingToPutAPrettyPictureIn"] = testFrame:CreateTexture() |
All times are GMT -6. The time now is 10:52 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI