Thread Tools Display Modes
11-30-12, 03:56 PM   #1
Voragaz
A Murloc Raider
Join Date: Nov 2012
Posts: 5
Lua noob with function issues

Hi!

I'm a lua beginner, trying to make a simple addon work as desired. It's a miniature panel that lets me queue for random bgs, arenas and LFDs through a simple click. I'm having a problem with the battleground queue. It works initially, queues me up for a bg if solo, and also queues when in group. However, when I leave the battleground it wont let me re-queue unless I reload the UI. I have tried variants of
Code:
self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
but don't really know what to do. The function itself looks like this:

Code:
function Qup_NumCall(arg1)

     local location = nil

     if     (arg1==1) then
        if(CanJoinBattlefieldAsGroup()) then
        JoinBattlefield(0,1) -- join battlefield as group
        else
    JoinBattlefield(0,0) -- join battlefield as single player
    end 
    elseif (arg1==2) then
         JoinArena()
     elseif (arg1==3) then
         LFDQueueFrame_Join()                
    end
 end
And an Onload function looking like this (don't ask me why)

Code:
function Qup_OnLoad(self)
---------
    self:RegisterEvent("ADDON_LOADED")
	self:RegisterEvent("VARIABLES_LOADED")
    self:RegisterEvent("ZONE_CHANGED_NEW_AREA")
end
In my xml, there's scrips for OnLoad and OnEvent.

Any ideas? Thanks!
  Reply With Quote
11-30-12, 04:59 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Please post your entire Lua and XML files. If they are fairly short (eg. less than 30 lines each) just post each one inside its own [code] tags. If they are longer, attach them to your post.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-30-12, 05:36 PM   #3
Voragaz
A Murloc Raider
Join Date: Nov 2012
Posts: 5
Hello, thanks for the reply.

I just read about blizzard move to protect the joinbattlefield function:
http://us.battle.net/wow/en/forum/topic/7199643338#1

And I now get an error message even trying to queue the first time "Has been blocked from an action only available to the blizzard UI". This makes me think JoinBattlefield functions won't work at all, unless there's a way around it?

Here's code attached in any case
Attached Files
File Type: lua Qup.lua (1.4 KB, 365 views)
File Type: xml Qup.xml (4.0 KB, 396 views)
  Reply With Quote
11-30-12, 06:14 PM   #4
Voragaz
A Murloc Raider
Join Date: Nov 2012
Posts: 5
Also, I'm aware that some parts of the code are unnecessary or just plain wrong - I've basically just hijacked different code and played around with it.
  Reply With Quote
11-30-12, 06:44 PM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Originally Posted by Voragaz View Post
I now get an error message even trying to queue the first time "Has been blocked from an action only available to the blizzard UI". This makes me think JoinBattlefield functions won't work at all, unless there's a way around it?
What the error is describing is that the function is now a protected function. There is a system in place known as the SecureActionButtonTemplate that allows some actions to be made that essentially have the same functionality as a macro on a button. As Blizzard doesn't have any secure slash commands defined to accomplish the same thing, it's out of reach of that system.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 11-30-12 at 06:49 PM.
  Reply With Quote
11-30-12, 11:57 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Actually, you could do this pretty easily by having your button simply click the join button on the battleground queue frame. Type "/fstack" to get the name of the button, and then use "/click NameOfTheButton" to click it.

Code:
local button = CreateFrame("Button", "JoinPvPQueue", UIParent, "SecureActionButtonTemplate,ActionButtonTemplate")
button.icon:SetTexture("Interface\\ICONS\\ACHIEVEMENT_ARENA_2V2_1")
button:SetPoint("CENTER")
button:SetSize(64, 64)
button:SetMovable(true)
button:RegisterForDrag("LeftButton")

button:SetAttribute("type", "macro")
button:SetAttribute("macrotext", "/click NameOfTheButton")
You might need to /click some other things first (eg. select the right tab on the frame); if so, just use /fstack to get their names and add them on separate lines:

Code:
button:SetAttribute("macrotext", [[/click NameOfTheTab
/click NameOfTheOtherThing
/click NameOfTheButton]])
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
12-01-12, 05:43 AM   #7
Voragaz
A Murloc Raider
Join Date: Nov 2012
Posts: 5
Originally Posted by Phanx View Post

You might need to /click some other things first (eg. select the right tab on the frame); if so, just use /fstack to get their names and add them on separate lines:
Ahh... I did try the click-button method by finding it with framestack, but I didn't think about having to do the above too. Willl try it.

Thanks Phanx!
  Reply With Quote
12-01-12, 06:16 AM   #8
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
The problem is you might be able to :Click() or /click with your own secure button, BUT when it comes to battlegrounds, you first tell the server "I wish to do WSG" then you get PVPQUEUE_ANYWHERE_SHOW and NOW you can JoinBattlefield but the thing is by then it's no longer a hardware event, so you minimum would need to click twice to queue, ASSUMING you can :Click() or /click the PVPFrameLeftButton (or Right one for group) to trigger the queue. I myself got my actions blocked, any altering of PVPFrame broke the queue function from working.

Also noticed in the process they also break the queue dropdown if you show it via an addon, it has to be shown using the default game UI, otherwise your addon will break the queue dropdown from working, lol.

Love patch changes that break our stuff.
__________________
Profile: Curse | Wowhead
  Reply With Quote
12-01-12, 06:54 AM   #9
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Not exactly related to your problem (probably). But perhaps the system is not working as it should and prohibits reentering after you were in the first bg.
http://us.battle.net/wow/en/forum/topic/7199643338
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Lua noob with function issues


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