Thread Tools Display Modes
09-22-09, 09:29 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
...index more then once.

can you do a ..index more then once? and if so what would the local have to be then? in other words could i do something like this...
bgFile = "Interface\\AddOns\\!GrimUI\\Art\\Skin"..index\\Bottom"..index,

and if i can do that then what does the () look like? (#,#) ?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-22-09, 09:44 PM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Grimsin View Post
can you do a ..index more then once? and if so what would the local have to be then? in other words could i do something like this...
bgFile = "Interface\\AddOns\\!GrimUI\\Art\\Skin"..index\\Bottom"..index,

and if i can do that then what does the () look like? (#,#) ?
I have no idea what you mean by (#,#), but this is how you'd do what you're asking.

Code:
local index = 1

bgFile = "Interface\\AddOns\\!GrimUI\\Art\\Skin"..index.."\\Bottom"..index
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-22-09, 09:51 PM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
i have that part the part im not sure about is this...
local art1 = createBottomArt(1) <---- should the one which is the index of Bottom"...index now read (1,1) or what ever the index numbers are to represent both index's?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-23-09, 01:00 AM   #4
Katae
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 208
Not sure if I'm getting your meaning, but the first argument (index) can be used as many times as you want, it will always be the same within your function.

Code:
local function func(index)
  return index, index, index
end

local var1, var2, var3 = func(3) -- 3, 3, 3
  Reply With Quote
09-23-09, 03:56 AM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
lua Code:
  1. local function createBottomArt(skinnr, bottomnr)
  2.   local bgFile = "Interface\\AddOns\\!GrimUI\\Art\\Skin"..skinnr.."\\Bottom"..bottomnr
  3. end
Something like that?

or maybe you are looking for something like this:

lua Code:
  1. local function createBottomArt(skinnr, numparts)
  2.   for i = 1, numparts do
  3.     local bgFile = "Interface\\AddOns\\!GrimUI\\Art\\Skin"..skinnr.."\\Bottom"..i
  4.   end
  5. end

Last edited by ravagernl : 09-23-09 at 04:04 AM.
  Reply With Quote
09-23-09, 07:43 AM   #6
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Suppose i should explain a little more. So im setting up the skinning for GrimUI. i have put the skins within directory's called skin1 skin2 so on and so forth. The primary art is then called bottom1.blp bottom2.blp so on and so forth. What im trying to do is get the following code to read bgFile="Interface\\AddOns\\!GrimUI\\Art\\Skin"..index\\Bottom"..index

then what im wanting to do is make the skin index a variable somehow so when the skin is selected on the option panel it would switch and save the variable.

Right now the code looks like this,
Code:
local function createBottomArt(index) 
	        local frame = CreateFrame("Frame", "GrimUIcoreArtB"..index, UIParent) 
	        frame:SetHeight(238) 
	        frame:SetFrameStrata("BACKGROUND") 
	        frame:SetBackdrop{ 
	            bgFile = "Interface\\AddOns\\!GrimUI\\Art\\Bottom"..index, 
	            edgeFile = nil, tile = false, tileSize = 0, edgeSize = 0, 
	            insets = { left = 0, right = 0, top = 0, bottom = 0 } 
	        } 
	        -- We return the frame back, so we can do more with it later  
	        return frame 
	    end 
	    -- Now let's call our newly created function for art1  
	    local art1 = createBottomArt(1) 
	    art1:SetWidth(468) 
	    art1:SetPoint("BOTTOMLEFT") 
	 
	    local art4 = createBottomArt(4) 
	    art4:SetWidth(474) 
	    art4:SetPoint("BOTTOMRIGHT") 
	    	 
	    local art2 = createBottomArt(2) 
	    art2:SetPoint("LEFT", GrimUIcoreArtB1, "RIGHT") 
		art2:SetPoint("RIGHT", UIParent, "CENTER")
		art2:SetPoint("BOTTOM")
		
	    local art3 = createBottomArt(3) 
	    art3:SetPoint("RIGHT", GrimUIcoreArtB4, "LEFT") 
		art3:SetPoint("LEFT", UIParent, "CENTER")
		art3:SetPoint("BOTTOM")
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-23-09, 01:35 PM   #7
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
You could try something like:
Code:
local bottom = CreateFrame('Frame', "GrimUIcoreArtB", UIParent)
bottom:SetAllPoints()
bottom:SetFrameStrata('BACKGROUND')

bottom[1] = bottom:CreateTexture("GrimUIcoreArtB1", 'BACKGROUND')
bottom[1]:SetWidth(468)
bottom[1]:SetPoint('BOTTOMLEFT')

bottom[2] = bottom:CreateTexture("GrimUIcoreArtB2", 'BACKGROUND')
bottom[2]:SetPoint('LEFT', bottom[1], 'RIGHT')
bottom[2]:SetPoint('RIGHT', bottom, 'CENTER')

bottom[4] = bottom:CreateTexture("GrimUIcoreArtB4", 'BACKGROUND')
bottom[4]:SetWidth(474)
bottom[4]:SetPoint('BOTTOMRIGHT')

bottom[3] = bottom:CreateTexture("GrimUIcoreArtB3", 'BACKGROUND')
bottom[3]:SetPoint('RIGHT', bottom[4], 'LEFT')
bottom[3]:SetPoint('LEFT', bottom[2], 'RIGHT')

for index = 1, #bottom do
	bottom[index]:SetHeight(238)
end

function GrimUI_LoadSkin(name)
	local path = [[Interface\AddOns\!GrimUI\Art\]] .. name .. [[\Bottom]]
	for index = 1, #bottom do
		bottom[index]:SetTexture(path .. index)
	end
end
And if your textures will always basically be horizontally flipped copies of each other you could change it to:
Code:
function GrimUI_LoadSkin(name)
	local path = [[Interface\AddOns\!GrimUI\Art\]] .. name .. [[\Bottom]]
	bottom[1]:SetTexture(path .. 1)
	bottom[2]:SetTexture(path .. 2)
	bottom[3]:SetTexture(path .. 2)
	bottom[4]:SetTexture(path .. 1)
	bottom[3]:SetTexCoord(1, 0, 0, 1)
	bottom[4]:SetTexCoord(1, 0, 0, 1)
end
That will allow you to only need 2 textures per skin vice 4.
  Reply With Quote
09-23-09, 02:55 PM   #8
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
hmm thats actually a good idea. I dont see any reason not to. although let me think on it a bit. About to go see Michial Franti and Spearhead at a local venu so ill look at it more then i get back. Still have an issue with the minimap art and the target cave art code getting in there. And i cant get my darn dropdownmenu buttons to onclick right! anyhow im going to head for the show ill be back late tonight.

BTW If you have downloaded the latest version of the ui the files in their for the art are not what im using anymore. i removed all the extra button setup stuff from the art file so it was just the primary art frame setup so it was easier to debug things till i get the code right...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-26-09, 10:10 PM   #9
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
okay so atempting to use a dif texture twice and to the flipflop on it but its not working at all keeps telling me it is a nil value for settexture.

this is what i worked up so far. Btw the art file works fine on frames...

Code:
local aggroR = CreateFrame("Frame", "GrimUIArtAggroR", UIParent) 
	    aggroR:CreateTexture("GrimUIArtAggroR", 'LOW')
		aggroR:SetTexture("Interface\\AddOns\\!GrimUI\\Art\\Aggro");
		aggroR:SetTexCoord(1, 0, 0, 1)
		aggroR:SetAlpha(0.5) 
	    aggroR:SetFrameStrata("LOW") 
	    aggroR:SetFrameLevel(2) 
	    aggroR:SetWidth(285) 
	    aggroR:SetHeight(170) 
	    aggroR:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", 0, 0)
	        
				aggroR:Hide()
any ideas?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-26-09, 11:20 PM   #10
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
You aren't keeping the frame and texture components properly seperated. You only need one frame but two textures (no point creating a seperate frame for each texture).

Code:
local aggro = CreateFrame("Frame", "GrimUIArtAggro", UIParent) 
aggro:SetPoint("BOTTOMLEFT")
aggro:SetPoint("BOTTOMRIGHT")
aggro:SetFrameStrata("LOW") 
aggro:SetFrameLevel(2) 
aggro:SetAlpha(0.5) 
aggro:Hide()

aggro.L = aggro:CreateTexture("GrimUIArtAggroL", 'LOW')
aggro.L:SetPoint("BOTTOMLEFT")
aggro.L:SetTexture("Interface\\AddOns\\!GrimUI\\Art\\Aggro")
aggro.L:SetHeight(170)
aggro.L:SetWidth(285)

aggro.R = aggro:CreateTexture("GrimUIArtAggroR", 'LOW')
aggro.R:SetPoint("BOTTOMRIGHT")
aggro.R:SetTexture("Interface\\AddOns\\!GrimUI\\Art\\Aggro")
aggro.R:SetHeight(170)
aggro.R:SetWidth(285)
aggro.R:SetTexCoord(1, 0, 0, 1)
Edit: Bad cut-and-paste

Last edited by Vrul : 09-27-09 at 11:30 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ...index more then once.

Thread Tools
Display Modes

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