Code:
frame=CreateFrame("Frame", "BagBuddy", UIParent)
In the .XML example the frame would
Code:
inherit="SomeTemplate"
When using
CreateFrame, the 4th argument is used to specify the templates the frame should enherit. Because you didn't include the template, you only created a base "blank" frame.
You seem to be trying to "re-create" the template in .lua which is doable but you would need to follow ALL the frames/regions and attributes of the template (notably, the .portrait texture at least is missing so SetPortraitToTexture() will fail).
Pretty much every attribute used in XML has an equivalent method to use with .lua code (usually [frame]:Setxxx()). The Wiki and game UI code is the best resource along with other addons. Templates are a bit different (like the frame name) because they have to be applied when the frame is created.
With createTexture(), this just created a base "blank" texture. You would need too
Code:
BagBuddy.texture1=BagBuddy:CreateTexture() -- Create the texure
BagBuddy.texture1:SetTexture("Interface\\BankFrame\\UI-BankFrame-TopLeft") -- Set it to show
BagBuddy.texture1:SetSize(xx, xx) -- give it a size
BagBuddy.texture1:SetPoint("TOPLEFT")-- Anchor to something (it's parent by default)
You can use multiple anchors instead of sizing. The same approach goes for any widget (FontStrings...).
Lua is case sensitive so while an XML attibute will use camel case, .lua Set methods don't
xxx:SetSomeAttribute()
Also, should use:
Lua Code:
local frame=CreateFrame("Frame", "BagBuddy", UIParent)
Where the
local declaration prevents cluttering up the global table especially with such a common name for a variable such as
frame.
How in the world do people learn this?!?!
|
Time and practice and not assuming that just because it's for a game, it's going to or should be "easy". Not trying to be mean, many people (especially if comming from other programming languages) make this assumption.