Thread Tools Display Modes
07-20-08, 05:57 PM   #1
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
Help with tables

I'm using tables to display art on the screen with an addon I'm writing, and was wondering if this would work:

Code:
local textures = {
    { name = "Self and Target Frame",
      bgFile = "Interface\\AddOns\\Chimaine\\PlainBackdrop",
      EdgeFile = "Interface\\Addons\\Tooltip\\UI-Tooltip-Border",
      tile = false, 
      tileSize = 0, 
      edgeSize = 32,
      insets = { left = 0, right = 0, top = 0, bottom = 0 }
      width = "108",
      height = "108",
      scale = "143"
    },
}

for id, entry in ipairs(textures) do
   chimaine.CreateTexture(entry.name, id, entry.file)
   chimaine.SetWidth(entry.width)
   chimaine.SetHeight(entry.height)
   -- I don't know the rest
end
Would that work if I used it in-game? I'm asking because I need to do it with about 10 textures and don't want to code them all and not have the work.

Thanks for any help.
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
07-20-08, 06:19 PM   #2
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
That is actually a very preferable way to do it, except that "entry.file" does not exist. The general design idea, though, is solid.
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote
07-20-08, 08:48 PM   #3
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
Alright, thanks Shirik.

The last part (and most of the structure of the code) I got from the WoW Programming book and was in a hurry so I just copied it real fast.
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
07-20-08, 09:53 PM   #4
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
When I try this in game though, I get this error:

Code:
Interface\Addans\Chimaine\Chimaine.lua:27: attempt to index global 'chimaine' (a nile value)
Line 27 (and the rest of it's code block) is:
Code:
26    for id, entry in ipairs(textures) do 
27       chimaine.CreateTexture(entry.name, id) 
28       chimaine.SetWidth(entry.width) 
29       chimaine.SetHeight(entry.height) 
30     
31       entry.name:SetBackdrop{ 
32          bgFile = entry.bgFile, 
33          edgeFile = entry.EdgeFile, 
34          edgeSize = entry.EdgeSize, 
35          tile = entry.tile, tileSize = entry.tileSize, 
36          insets = entry.insets 
37        } 
38    end
What I'm doing wrong?
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
07-20-08, 10:23 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You haven't defined what chimaine is
__________________
"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
07-20-08, 10:39 PM   #6
Dreadlorde
A Pyroguard Emberseer
 
Dreadlorde's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 2,302
Would something like this work?
Code:
local chimaine = CreateFrame("frame",nil,UIParent)
__________________

Funtoo - Plan 9 - Windows 7
  Reply With Quote
07-21-08, 03:35 AM   #7
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Dreadlorde View Post
Would something like this work?
Code:
local chimaine = CreateFrame("frame",nil,UIParent)
Theres no point really you can create a frame using UIParent.

Code:
local tex = UIParent:CreateTexture(entry.name) 
tex:SetWidth(entry.width) 
tex:SetHeight(entry.height)
I personally wouldn't use a table for none dynamic frames. I would just create a function to set up a texture using args passed to it.

i.e.
Code:
local maketex(name, height, width, ...)
   local tex = UIParent:CreateTexture(name)
   tex:SetHeight(height)
   tex:SetWidth(width)
   tex:SetPoint(...)
end

maketex("Cow", 10, 10, "TOPLEFT", UIParent, "BOTTOMRIGHT", -1, 2)
--etc.
I would just like to point out chimaine.SetHeight(entry.height) does not equal chimaine:SetHeight(entry.height) but,

Code:
chimaine:SetHeight(entry.height)
=
Code:
chimaine.SetHeight(chimaine, entry.height)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Help with tables


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