Thread Tools Display Modes
08-29-08, 10:09 AM   #1
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
Unhappy How to fill a dropdownbutton with the guild roster

i have this:

Code:
    PlayerDropDownMenu = CreateFrame("Frame", "PlayerDropDownMenu", Frame, "UIDropDownMenuTemplate"); 
    PlayerDropDownMenu:SetPoint("Left",Frame, 120, -198)
    UIDropDownMenu_SetWidth(80, PlayerDropDownMenu)
    UIDropDownMenu_SetButtonWidth(20, PlayerDropDownMenu)
    UIDropDownMenu_Initialize(PlayerDropDownMenu, PlayerDropDownMenu_Initialise)
Code:
function PlayerDropDownMenu_Initialise() 
	level = 1
    local info = UIDropDownMenu_CreateInfo(); 
	for i=0,GetNumGuildMembers(true) do
		name, rank, rankIndex, level, class, zone, note, officernote, online, status = GetGuildRosterInfo(i)
		info.text = name
		info.value = name
		info.func = function() PlayerDropDownMenu_OnClick() end
		info.owner = this:GetParent()
		info.checked = nil; 
		UIDropDownMenu_AddButton(info, level)
	end
end
static loading works, only the guild roster wont work.

Anyone has an idea what i might do wrong?
  Reply With Quote
08-29-08, 10:13 AM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Do the index for GetGuildRosterInfo() really starts with 0? Not with 1?
  Reply With Quote
08-29-08, 10:31 AM   #3
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
Originally Posted by Duugu View Post
Do the index for GetGuildRosterInfo() really starts with 0? Not with 1?
doesnt work with 1 either
  Reply With Quote
08-29-08, 10:35 AM   #4
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Where's PlayerDropDownMenu_OnClick() ?
  Reply With Quote
08-29-08, 10:38 AM   #5
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
Originally Posted by Duugu View Post
Where's PlayerDropDownMenu_OnClick() ?
Code:
function PlayerDropDownMenu_OnClick()
	UIDropDownMenu_SetSelectedValue(this.owner, this.value)
end
  Reply With Quote
08-29-08, 11:00 AM   #6
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Move
Code:
function PlayerDropDownMenu_Initialise()...end
before
Code:
UIDropDownMenu_Initialize(PlayerDropDownMenu, PlayerDropDownMenu_Initialise)
It's nil otherwise.
  Reply With Quote
08-29-08, 11:26 AM   #7
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
Originally Posted by Duugu View Post
Move
Code:
function PlayerDropDownMenu_Initialise()...end
before
Code:
UIDropDownMenu_Initialize(PlayerDropDownMenu, PlayerDropDownMenu_Initialise)
It's nil otherwise.
doesnt solve the problem. Static loading works. But when i try to load the guild roster nothing appears
  Reply With Quote
08-29-08, 11:31 AM   #8
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
No error messages? oO
  Reply With Quote
08-29-08, 11:40 AM   #9
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
Originally Posted by Duugu View Post
No error messages? oO
No nothing, the dropdownbutton just remains empty while the static loaded one above it got filled
  Reply With Quote
08-29-08, 11:52 AM   #10
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
If I add the code from you first post to an empty addon and move PlayerDropDownMenu_Initialise() before UIDropDownMenu_Initialize() I get the error message "... attempt to index global 'this' (a nil value)".

This means there are three possible options:
1. There's other code you didn't show up to now
2. The shown code isn't up-to-date
3. Your lua error messages are deactivated

Please choose and fix.
  Reply With Quote
08-29-08, 12:03 PM   #11
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
Originally Posted by Duugu View Post
If I add the code from you first post to an empty addon and move PlayerDropDownMenu_Initialise() before UIDropDownMenu_Initialize() I get the error message "... attempt to index global 'this' (a nil value)".

This means there are three possible options:
1. There's other code you didn't show up to now
2. The shown code isn't up-to-date
3. Your lua error messages are deactivated

Please choose and fix.
1. theres is other code which has nothing to do with this subject
2. that code is currently in my project
3. I use !swatter to grab my bugs.

And yes i got that error as well if i swap the positions
  Reply With Quote
08-29-08, 03:06 PM   #12
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
when does this run? are you confirming that the guild roster has loaded from the server first (after "GUILD_ROSTER_UPDATE")?
  Reply With Quote
08-29-08, 04:03 PM   #13
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
Originally Posted by Akryn View Post
when does this run? are you confirming that the guild roster has loaded from the server first (after "GUILD_ROSTER_UPDATE")?
got it to work. But now i cant filter the "veteran alt"s out. this is the code

Code:
function PlayerDropDownMenu_Initialise() 
	level = 1
    local info = UIDropDownMenu_CreateInfo(); 
	for i=1,GetNumGuildMembers(true) do
		local name = GetGuildRosterInfo(i)
		local rank = GetGuildRosterInfo(i)
		if (rank=="Veteran Alt") then
			info.text = "------------------"
			info.value = "------------------"
			info.func = function() PlayerDropDownMenu_OnClick() end
			info.owner = this:GetParent()
			info.checked = nil; 
			UIDropDownMenu_AddButton(info, level)
		else
			info.text = name
			info.value = name
			info.func = function() PlayerDropDownMenu_OnClick() end
			info.owner = this:GetParent()
			info.checked = nil; 
			UIDropDownMenu_AddButton(info, level)
		end
	end
end

Last edited by loopylama : 08-29-08 at 04:07 PM.
  Reply With Quote
08-29-08, 04:13 PM   #14
Tristanian
Andúril
Premium Member
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 279
local name, rank = GetGuildRosterInfo(i)

eliminate the other GetGuildRosterInfo(index) call.

Edit: Better yet, call the function properly with all args :

local name, rank, rankIndex, level, class, zone, note, officernote, online, status = GetGuildRosterInfo(i);

and do an : if online then...end before adding the buttons in your loop. If you are only interested in the name and rank you can also it omit the other args :

local name, rank, _, _, _, _, _, _, online, _ = GetGuildRosterInfo(i);

Last edited by Tristanian : 08-29-08 at 04:17 PM.
  Reply With Quote
08-29-08, 04:16 PM   #15
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by loopylama View Post
got it to work. But now i cant filter the "veteran alt"s out. this is the code

Code:
       local name = GetGuildRosterInfo(i)
       local rank = GetGuildRosterInfo(i)
should be:

local name, rank = GetGuildRosterInfo(i)
  Reply With Quote
08-30-08, 03:42 AM   #16
loopylama
A Murloc Raider
Join Date: Aug 2008
Posts: 8
now i have this:

Code:
function PlayerDropDownMenu_Initialise() 
	level = 1
    local info = UIDropDownMenu_CreateInfo(); 
	for i=1,GetNumGuildMembers(true) do
		local name, rank, rankIndex, level, class, zone, note, officernote, online, status = GetGuildRosterInfo(i)
		if (rank~="Member Alt") then
			info.text = name
			info.value = name
			info.func = function() PlayerDropDownMenu_OnClick() end
			info.owner = this:GetParent()
			info.checked = nil;
			UIDropDownMenu_AddButton(info, level) 
		end	
	end
end
error:

Code:
Error occured in: Global
Count: 6
Message: ..\FrameXML\UIDropDownMenu.lua line 207:
   attempt to index local 'listFrame' (a nil value)
Debug:
   Ace2\AceAddon-2.0\AceAddon-2.0.lua:27:
      Ace2\AceAddon-2.0\AceAddon-2.0.lua:25
   Ace2\AceAddon-2.0\AceAddon-2.0.lua:614: InitializeAddon()
   Ace2\AceAddon-2.0\AceAddon-2.0.lua:486:
      Ace2\AceAddon-2.0\AceAddon-2.0.lua:463
   [C]: ?
   Ace2\AceEvent-2.0\AceEvent-2.0.lua:298: TriggerEvent()
   Ace2\AceEvent-2.0\AceEvent-2.0.lua:910:
      Ace2\AceEvent-2.0\AceEvent-2.0.lua:903
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to fill a dropdownbutton with the guild roster


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