WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Creating a script that hide other addon frames (https://www.wowinterface.com/forums/showthread.php?t=58541)

Shabblahabbla 01-10-21 04:24 PM

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!

Seerah 01-10-21 07:34 PM

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

Shabblahabbla 01-10-21 08:12 PM

Quote:

Originally Posted by Seerah (Post 338255)
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.

Kanegasi 01-10-21 09:09 PM

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.

Shabblahabbla 01-10-21 09:34 PM

Quote:

Originally Posted by Kanegasi (Post 338257)
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!

Kanegasi 01-10-21 11:04 PM

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.

Shabblahabbla 01-10-21 11:51 PM

Quote:

Originally Posted by Kanegasi (Post 338260)
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?

Seerah 01-11-21 12:51 PM

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.


All times are GMT -6. The time now is 07:30 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI