Thread Tools Display Modes
11-04-05, 10:28 AM   #1
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
I hate lua.

Code:
function GetGuilNumbers()
    numGuildMembers = GetNumGuildMembers();
	for i=1,numGuildMembers do
	name[i], _, _, _, _, _, _, _, _, _= GetGuildRosterInfo(i);
	end
end

function SetTicketNumberToNil()
	for k,v pairs do
		name[k]=name[v]
	end
end

Does the above set the name table's keys as it's values, and it's values as it's keys,making it look like this:
Code:
Keys        Values
name1       1
name2       2
name3       3
.......         ...
.......         ...
nameN       N
Or does it change it to the following
Code:

Keys        Values
name1     name1
name2     name2
name3     name3
.......         ...
.......         ...
nameN       nameN
  Reply With Quote
11-04-05, 12:26 PM   #2
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Second question:

Code:
local name{}
function GetGuilNumbers()
    numGuildMembers = GetNumGuildMembers();
	for i=1,numGuildMembers do
	name[i], _, _, _, _, _, _, _, _, _= GetGuildRosterInfo(i);
	end
end

function SetTicketNumberToNil()
	for k,v pairs do
		name[k]=name[v]
		name[v]=0
	end
	for i=1,numguildMembers do
		table.insert(EasierFrameShowing[i],name[i])
end
Will I end up with a table which would look like this:

Code:
EasierFrameShowing
      |-Key=1 Value=Name 
                                      | Key = Name[1]  (for example shouryuu)
                                      | Value = Name[1] (should be 0)
Or something else?
  Reply With Quote
11-04-05, 03:01 PM   #3
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 1,935
The first question is.. what are you trying to accomplish.

The first example looks like you'd get the folllowing:

You have name, which you populate with numerically indexed names of the members in the raid. So if its you and I.. we'd be:

Code:
name = {[1] = "Cladhaire", [2] = "Shouryuu"]}
Then your code does something that I'm not understanding. You go through and set the table to the following:

Code:
name = {[1] = nil, [2] = nil};
Because name[v] doesn't have a value. if you're looking to make a double-reverse-lookup table, you can use:

Code:
function SetTicketNumberToNil()
	for k,v in name do
		name[v]=name[k]
	end
end
But I'm not sure exactly what you're looking for. My code would give you:

Code:
name = {
[1] = "Cladhaire",
[2] = "Shouryuu",
["Cladhaire"] = 1,
["Shouryuu"] = 2,
};

Last edited by Cladhaire : 11-04-05 at 03:05 PM.
  Reply With Quote
11-04-05, 03:08 PM   #4
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Hummm ponder ponder... I'll take some time to think about this and hit ya with another question if I fail :P
  Reply With Quote
11-04-05, 03:11 PM   #5
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 1,935
It more comes down to what you're trying to accomplish =).
  Reply With Quote
11-04-05, 09:40 PM   #6
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
It's simple enough I want to inverse a table's keys and values. I want the keys to become the values, and the values to become the keys.

Would something along these lines work?
Code:
function SetTicketNumberToNil()
	for k,v pairs do
		table.insert(name, name[i], i)
	end
end
This only work, if it does, because the keys are simple: 1,2,3,4,5... But how do I do that if I have keys like zdfs and gkfslg; or djakf?

Last edited by shouryuu : 11-04-05 at 09:43 PM.
  Reply With Quote
11-04-05, 03:08 PM   #7
Cladhaire
Salad!
 
Cladhaire's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Jul 2005
Posts: 1,935
Second Question

First step, you build the table indexed by raidnumber. All is well and good.

Then you go through and do the same thing as before, setting name[1] and name[2] to nil.
Then you go and set name["Cladhaire"] and name["Shouryuu"] to 0;

The last bit of code makes the following in EasierFrameShowing:

Code:
EasierFrameShowing = {[1] = nil, [2] = nil};
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » I hate lua.

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