Thread Tools Display Modes
09-17-09, 05:12 PM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
LFG joining/leaving

So im trying to make a button to join and leave the lfg channel but so far no luck. This is what i have so far, some may ask why i dont put leave on right mouse button well... simple something else is on right mousebutton. or is it left? well either way need to get the whole function in one click. I know right now their is some sort of error with the way i tried to link the if's, not sure how to put 2 separated if sets in one button click.

The other and more major error at the moment imo is that if i remove it so it only has the one command to SetLookingForGroup it does setup the LFG page and joins LFG but it does not actually join the LFG channel for what ever reason.

Any thoughts? here is the code i have so far.
Code:
if button == 'LeftButton' then
		if (GetNumPartyMembers()==0) then
			SetLookingForGroup(3, 5, 1);
			SetLFGComment("LFG-Channel enabled by GrimUI");
			UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
		elseif
			(UnitIsPartyLeader("player")==1) then
			SetLookingForMore(5, 1);
			SetLFGComment("LFG-Channel enabled by GrimUI");
			UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
		end
	else
		if (UnitIsPartyLeader("player")==nil) then
			ClearLookingForGroup()
			UIErrorsFrame:AddMessage("LookingForGroup Off", 1.0, 0.0, 0.0, 53, 3);
		elseif
			(n > 0) then
			ClearLookingForGroup()
			UIErrorsFrame:AddMessage("LookingForGroup Off", 1.0, 0.0, 0.0, 53, 3);
		end
    end
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-17-09, 05:32 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Grimsin View Post
So im trying to make a button to join and leave the lfg channel but so far no luck. This is what i have so far, some may ask why i dont put leave on right mouse button well... simple something else is on right mousebutton. or is it left? well either way need to get the whole function in one click. I know right now their is some sort of error with the way i tried to link the if's, not sure how to put 2 separated if sets in one button click.
Well, right now, you're telling it to join on left click and leave on any other click. Let me fix your lines/indentation to show you that:
Code:
if button == 'LeftButton' then
          if (GetNumPartyMembers()==0) then
                    SetLookingForGroup(3, 5, 1);
                    SetLFGComment("LFG-Channel enabled by GrimUI");
                    UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
          elseif
                    (UnitIsPartyLeader("player")==1) then
                    SetLookingForMore(5, 1);
                    SetLFGComment("LFG-Channel enabled by GrimUI");
                    UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
          end
else
          if (UnitIsPartyLeader("player")==nil) then
                    ClearLookingForGroup()
                    UIErrorsFrame:AddMessage("LookingForGroup Off", 1.0, 0.0, 0.0, 53, 3);
          elseif (n > 0) then          --have no clue what this n variable is, but I can guess what you mean to do...
                    ClearLookingForGroup()
                    UIErrorsFrame:AddMessage("LookingForGroup Off", 1.0, 0.0, 0.0, 53, 3);
          end
end
Here's how your code *should* read:
Code:
if button == 'LeftButton' then
          if IsInLFGQueue() then          --http://wowprogramming.com/docs/api/IsInLFGQueue
                    ClearLookingForGroup()          --leave LFG if already in it
                    UIErrorsFrame:AddMessage("LookingForGroup Off", 1.0, 0.0, 0.0, 53, 3)
          else          --if not in it, then join
                    if (GetNumPartyMembers()==0) then          --you're not in a party
                              SetLookingForGroup(3, 5, 1);
                              SetLFGComment("LFG-Channel enabled by GrimUI");
                              UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
                    elseif (UnitIsPartyLeader("player")==1) then
                              SetLookingForMore(5, 1);
                              SetLFGComment("LFG-Channel enabled by GrimUI");
                              UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
                    end
          end
end
Can't double check it atm, but that'll start you off.
__________________
"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
09-17-09, 05:34 PM   #3
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
oh wow. i had not seen that lfgqueue command that might make all the difference right their.

Well that for sure fixed the issues i had with my if statements. still no luck on it actually joining the channel or not which makes no sense. /join LookingForGroup also does not function the way one would think it should...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 09-17-09 at 05:44 PM.
  Reply With Quote
09-17-09, 06:03 PM   #4
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Okay got it to work, its because i had used the /join command at one point so it was not doing anything. It does join it now without a problem. What it does not do is leave the channel or clear the lfg.....
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-17-09, 06:53 PM   #5
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
OKay so i think the issue might be with IsInLFGQueue, i think that returns a value right? dont we need to return that value somewhere and do the if on th at? so it reads if IsInLFGQueue's returned value is such n such do this?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-17-09, 07:00 PM   #6
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
ah nope IsInLFGQueue() is not valid for this.... because you dont actually join the autojoin queue. i think GetLookingForGroup is what i need to base things on.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 09-17-09 at 07:11 PM.
  Reply With Quote
09-17-09, 07:21 PM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Ah, yep. Skimmed past that one. I was trying to type out my post in the, like, 2 minutes before my next student arrived.
__________________
"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
09-17-09, 07:44 PM   #8
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
What do you teach?

and also added this to it ClearLookingForMore()

i have not figured out how to do the calculation yet to make it check the GetLookingForGroup command yet.... it can return a lot of variables.....
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-17-09, 08:15 PM   #9
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
This is the line i think that does it in leafLFG im trying to understand how it works....

Code:
local function GetLFGStatus()
 	local _, _, _, _, _, _, _, _, _, _, lfg, lfm = GetLookingForGroup()
	return lfg or lfm, lfg, lfm
end
I have no idea though how that line there works haha i know it later goes into play with this line...

Code:
if GetLFGStatus() then
			playerDisable = GetGroupStatus()
			Leave()
Leave() is defined with the ClearLookingForGroup() ClearLookingForMore() tags.

Attempting to write something similar as we speak....
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-17-09, 08:22 PM   #10
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
figured it out still curious what you teach?
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
09-17-09, 09:16 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I teach piano and voice lessons privately.

Code:
 	local _, _, _, _, _, _, _, _, _, _, lfg, lfm = GetLookingForGroup()
With so many return values, and the ones you want being all the way at the end, you could use select() for readability. Would add an extra function call to your code, but I don't think you'll be calling it often enough to matter.

Code:
local lfg, lfm = select(11, GetLookingForGroup())
This gives you returns 11+. Also, I don't think this line
Code:
	return lfg or lfm, lfg, lfm
does what you think it does. That line there returns 3 values. 1. lfg or lfm (whichever is valid first, left to right), 2. the value of lfg, and 3. the value of lfm. But you're trying to use it as just a basic check. Instead, do this:
Code:
local lfg, lfm = select(11, GetLookingForGroup())
if lfg or lfm then
			playerDisable = GetGroupStatus()
			Leave()

/edit: I should note that the addon SaneLFG allows a person to be in both LFG *and* LFM.
__________________
"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


Last edited by Seerah : 09-17-09 at 09:19 PM.
  Reply With Quote
09-17-09, 10:45 PM   #12
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
hmm in both at once does it make a difference? really all im after is the lfg channel toggle. something i just noticed to is that if the party is full the code i used does not allow you to turn on the lfg channel. ill post the entirety of it right now you can take a look. i have not tried using the code you just posted above yet. obviously...

Code:
-------------------------
--     LFG HotPoint    --
-------------------------
local function GetGroupStatus()
	local raidnum = GetRealNumRaidMembers()
	local partynum = GetRealNumPartyMembers()
	if raidnum > 0 then
		return 'Raid', (raidnum ~= 40) and IsRaidLeader()
	elseif partynum > 0 then
		return 'Party', (partynum ~= 5) and IsPartyLeader'player'
	else
		return 'Solo', true
	end
end
local function GetLFGStatus()
 	local _, _, _, _, _, _, _, _, _, _, lfg, lfm = GetLookingForGroup()
	return lfg or lfm, lfg, lfm
end

local LFGHotPoint = CreateFrame('Button', "LFGHotPoint", UIParent)
LFGHotPoint:SetPoint('TOPRIGHT', GrimUIcoreArtB1, 'TOPRIGHT', -82, 0)
LFGHotPoint:SetHeight(15)
LFGHotPoint:SetWidth(15)
LFGHotPoint:RegisterForClicks('LeftButtonUp', 'RightButtonUp')
LFGHotPoint:SetNormalTexture("none")
LFGHotPoint:SetScript('OnClick', function(self, button)
	if button == "RightButton" then
		if _G.GetCVar("autoLootDefault") == "0" then
			_G.SetCVar("autoLootDefault", "1")
			UIErrorsFrame:AddMessage("AutoLoot On", 0.0, 1.0, 0.0, 53, 3);
		elseif _G.GetCVar("autoLootDefault") == "1" then
			_G.SetCVar("autoLootDefault", "0")
			UIErrorsFrame:AddMessage("AutoLoot Off", 1.0, 0.0, 0.0, 53, 3);
		end
	end
	if button == 'LeftButton' then
					if GetLFGStatus() then
					playerDisable = GetGroupStatus()
					ClearLookingForGroup()          --leave LFG if already in it
					ClearLookingForMore()        --http://wowprogramming.com/docs/api/IsInLFGQueue
                    
                    UIErrorsFrame:AddMessage("LookingForGroup Off", 1.0, 0.0, 0.0, 53, 3)
          else          --if not in it, then join
                    if (GetNumPartyMembers()==0) then          --you're not in a party
                              SetLookingForGroup(1, 5, 1);
                              SetLFGComment("LFG-Channel enabled by GrimUI");
                              UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
                    elseif (UnitIsPartyLeader("player")==1) then
                              SetLookingForMore(5, 1);
                              SetLFGComment("LFG-Channel enabled by GrimUI");
                              UIErrorsFrame:AddMessage("LookingForGroup On", 0.0, 1.0, 0.0, 53, 3);
                    end
          end
	end
end)

local function OnEnter(self)
	if self.tooltip then
		GameTooltip:ClearLines()
	else
		GameTooltip:SetOwner(self, 'ANCHOR_TOP', 200, 4)
	end
	GameTooltip:AddLine("|cffeda55fLeft Click|r toggle LFG channel", 0.2, 1, 0.2)
	GameTooltip:AddLine("|cffeda55fRight Click|r toggle AutoLoot", 0.2, 1, 0.2)
	if not self.tooltip then
		GameTooltip:Show()
		self.tooltip = true
	end
end
LFGHotPoint:SetScript('OnEnter', OnEnter)

LFGHotPoint:SetScript('OnLeave', function(self)
	GameTooltip:Hide()
	self.tooltip = nil
end)
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » LFG joining/leaving


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