Thread Tools Display Modes
01-10-21, 04:24 PM   #1
Shabblahabbla
A Murloc Raider
Join Date: Jan 2021
Posts: 5
Creating a script that hide other addon frames

Code:
if memberExists = GetPartyMember(3) then
  	eBar_bar_4:SetAlpha(0)
  	eBar_bar_5:SetAlpha(0)
  	eBar_bar_6:SetAlpha(0)
  	eBar_bar_7:SetAlpha(0)
  	LoseControlparty1:SetAlpha(0)
  	LoseControlparty2:SetAlpha(0)
else
  	eBar_bar_4:SetAlpha(1)
  	eBar_bar_5:SetAlpha(1)
  	eBar_bar_6:SetAlpha(1)
  	eBar_bar_7:SetAlpha(1)
  	LoseControlparty1:SetAlpha(1)
  	LoseControlparty2:SetAlpha(1)
end
This doesnt work. I do not know much about lua.
Help me please make it work.

When Im in a party or raid with party3 exists I want to hide some frames.

I used to have macros for /run eBar_bar_4:SetAlpha(0) and /run eBar_bar_4:SetAlpha(1) for all bars. I just want it to work without macros as long as Im in the game.

Thank you for reading!
 
01-10-21, 07:34 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Your syntax is wrong. You're assigning to a variable on the line where you want to check it.

Just use:
Lua Code:
  1. if GetPartyMember(3) then
__________________
"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

 
01-10-21, 08:12 PM   #3
Shabblahabbla
A Murloc Raider
Join Date: Jan 2021
Posts: 5
Originally Posted by Seerah View Post
Your syntax is wrong. You're assigning to a variable on the line where you want to check it.

Just use:
Lua Code:
  1. if GetPartyMember(3) then
Hey, thanks!
So the thing I want it to do is still not happening with that correction.
Btw, the code i showed is my whole code for my core of my little addon.
I guess im missing something before the IF statement.
I see most addons have:

local function ...

as their first line for alot of things.
 
01-10-21, 09:09 PM   #4
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Lua Code:
  1. local f=CreateFrame("frame")
  2. f:RegisterEvent("GROUP_ROSTER_UPDATE")
  3. f:SetScript("OnEvent",function()
  4.     if UnitName("party3") then
  5.         eBar_bar_4:SetAlpha(0)
  6.         eBar_bar_5:SetAlpha(0)
  7.         eBar_bar_6:SetAlpha(0)
  8.         eBar_bar_7:SetAlpha(0)
  9.         LoseControlparty1:SetAlpha(0)
  10.         LoseControlparty2:SetAlpha(0)
  11.     else
  12.         eBar_bar_4:SetAlpha(1)
  13.         eBar_bar_5:SetAlpha(1)
  14.         eBar_bar_6:SetAlpha(1)
  15.         eBar_bar_7:SetAlpha(1)
  16.         LoseControlparty1:SetAlpha(1)
  17.         LoseControlparty2:SetAlpha(1)
  18.     end
  19. end

Assuming you made the addon correctly, that code by itself only runs once when the UI loads. You need to have it run every time your group changes, so you create a frame, register it for the group change event, and then set the code to run with the OnEvent frame script. If you are unsure if you made the addon correctly, you can go to https://addon.bool.no to easily make it with this code.

Also, "GetPartyMember" doesn't exist, not sure where you got that, so we'll use UnitName here to check if party3 exists. Keep in mind that in a party, not a raid, a full group of players will be you with the unit "player", then the other four members as "party1", "party2", "party3", and "party4". This code is checking if the party has a fourth member. In a raid, "player" still exists, but you will also have a "raid#" unit with no guarantee which number.
 
01-10-21, 09:34 PM   #5
Shabblahabbla
A Murloc Raider
Join Date: Jan 2021
Posts: 5
Originally Posted by Kanegasi View Post
Lua Code:
  1. local f=CreateFrame("frame")
  2. f:RegisterEvent("GROUP_ROSTER_UPDATE")
  3. f:SetScript("OnEvent",function()
  4.     if UnitName("party3") then
  5.         eBar_bar_4:SetAlpha(0)
  6.         eBar_bar_5:SetAlpha(0)
  7.         eBar_bar_6:SetAlpha(0)
  8.         eBar_bar_7:SetAlpha(0)
  9.         LoseControlparty1:SetAlpha(0)
  10.         LoseControlparty2:SetAlpha(0)
  11.     else
  12.         eBar_bar_4:SetAlpha(1)
  13.         eBar_bar_5:SetAlpha(1)
  14.         eBar_bar_6:SetAlpha(1)
  15.         eBar_bar_7:SetAlpha(1)
  16.         LoseControlparty1:SetAlpha(1)
  17.         LoseControlparty2:SetAlpha(1)
  18.     end
  19. end

Assuming you made the addon correctly, that code by itself only runs once when the UI loads. You need to have it run every time your group changes, so you create a frame, register it for the group change event, and then set the code to run with the OnEvent frame script. If you are unsure if you made the addon correctly, you can go to https://addon.bool.no to easily make it with this code.

Also, "GetPartyMember" doesn't exist, not sure where you got that, so we'll use UnitName here to check if party3 exists. Keep in mind that in a party, not a raid, a full group of players will be you with the unit "player", then the other four members as "party1", "party2", "party3", and "party4". This code is checking if the party has a fourth member. In a raid, "player" still exists, but you will also have a "raid#" unit with no guarantee which number.
Hey thank you!
That looks good, Im starting to understand more. But it still doesnt set those frames ingame to alpha 0.
Im starting to wonder if just having those lines after "then" with the bars/frames name (taken from /framestack) is not enough or is not the same. Since I can do /run eBar_bar_4:SetAlpha(0) in game and it works there.
And if it is the same thing as /run then Im missing something even more basic. Also if its not the same thing then I wonder how I can make the addon so that it do the /run lines on each frame for me without me typing it in a macro each time party3 exists and then alpha 1 lines when party3 does not exists.
Even if this is clunkier and ugly. I do not care, im just about the practicality of make it work, means to an end.
Thank you anyway!
 
01-10-21, 11:04 PM   #6
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
I was curious what addon had those ebars, googling brought me to your unanswered reddit thread. Since you want to check if the group has 4 or more players, checking the number of members is better.

Lua Code:
  1. local f=CreateFrame("frame")
  2. f:RegisterEvent("GROUP_ROSTER_UPDATE")
  3. f:SetScript("OnEvent",function()
  4.     if GetNumGroupMembers()>3 then
  5.         eBar_bar_4:SetAlpha(0)
  6.         eBar_bar_5:SetAlpha(0)
  7.         eBar_bar_6:SetAlpha(0)
  8.         eBar_bar_7:SetAlpha(0)
  9.         LoseControlparty1:SetAlpha(0)
  10.         LoseControlparty2:SetAlpha(0)
  11.     else
  12.         eBar_bar_4:SetAlpha(1)
  13.         eBar_bar_5:SetAlpha(1)
  14.         eBar_bar_6:SetAlpha(1)
  15.         eBar_bar_7:SetAlpha(1)
  16.         LoseControlparty1:SetAlpha(1)
  17.         LoseControlparty2:SetAlpha(1)
  18.     end
  19. end

However, after looking for eBar and LoseControl and stumbling on what I believe is your thread in a certain other forum, I have a hunch this code won't work for you since the event GROUP_ROSTER_UPDATE was added in Battle for Azeroth and GetNumGroupMembers() was added in Mists of Pandaria.
 
01-10-21, 11:51 PM   #7
Shabblahabbla
A Murloc Raider
Join Date: Jan 2021
Posts: 5
Originally Posted by Kanegasi View Post
I was curious what addon had those ebars, googling brought me to your unanswered reddit thread. Since you want to check if the group has 4 or more players, checking the number of members is better.

Lua Code:
  1. local f=CreateFrame("frame")
  2. f:RegisterEvent("GROUP_ROSTER_UPDATE")
  3. f:SetScript("OnEvent",function()
  4.     if GetNumGroupMembers()>3 then
  5.         eBar_bar_4:SetAlpha(0)
  6.         eBar_bar_5:SetAlpha(0)
  7.         eBar_bar_6:SetAlpha(0)
  8.         eBar_bar_7:SetAlpha(0)
  9.         LoseControlparty1:SetAlpha(0)
  10.         LoseControlparty2:SetAlpha(0)
  11.     else
  12.         eBar_bar_4:SetAlpha(1)
  13.         eBar_bar_5:SetAlpha(1)
  14.         eBar_bar_6:SetAlpha(1)
  15.         eBar_bar_7:SetAlpha(1)
  16.         LoseControlparty1:SetAlpha(1)
  17.         LoseControlparty2:SetAlpha(1)
  18.     end
  19. end

However, after looking for eBar and LoseControl and stumbling on what I believe is your thread in a certain other forum, I have a hunch this code won't work for you since the event GROUP_ROSTER_UPDATE was added in Battle for Azeroth and GetNumGroupMembers() was added in Mists of Pandaria.
Ye, I see what you are saying.

I wonder if there is another event or condition that I can try, maybe with your help?

How do I write all of this but instead of checking for a partyunit I just want these frames to always be hidden but shown when I enter arena.
I mean Arena for 2v2 or 3v3 and not in a BG.

How would that look like?
 
01-11-21, 12:51 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
If you're looking for assistance with an addon for a private server, then there is nothing we can do for you here.

We are an official Blizzard Fan Site. Posts about private servers, beyond anything that is theoretical, are against Blizzard's rules as well as our own rules. Threads requesting assistance with private servers will be locked. Repeated requests will result in bans.
__________________
"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

 

WoWInterface » Developer Discussions » Lua/XML Help » Creating a script that hide other addon frames

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