WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   IsInGroup not working (https://www.wowinterface.com/forums/showthread.php?t=56152)

GreyFox777 04-14-18 05:52 PM

IsInGroup not working
 
Can someone give me an advice how can i run this code only if player are in group?

Quote:

local smallcircle5 = CreateFrame("Frame", "SmallCircleTopCenter", self)
smallcircle5:SetFrameLevel(self.Health:GetFrameLevel() + 5)
local smallcircle5texture = smallcircle5:CreateTexture(nil, "ARTWORK")
smallcircle5texture:SetTexture(m.textures.smallcircle)
smallcircle5texture:SetPoint('CENTER', self, 46, 35)
smallcircle5texture:SetSize(26,26)
smallcircle5texture:SetTexCoord(0, 1, 0, 1)
I tried like if IsInGroup('player') then

CODE

end

But it doesen't take a effect, until i reload my ui.

Tim 04-14-18 06:15 PM

IsInGroup works and the only reason why it's only working for you on a reload is you need to register the event PLAYER_ENTERING_WORLD / GROUP_ROSTER_UPDATE and once either of those are fired then you check to see if you're in a group.

Code:

local smallcircle5 = CreateFrame("Frame", "SmallCircleTopCenter")
smallcircle5:SetFrameLevel(self.Health:GetFrameLevel() + 5)

local smallcircle5texture = smallcircle5:CreateTexture(nil, "ARTWORK")
smallcircle5texture:SetTexture(m.textures.smallcircle)
smallcircle5texture:SetPoint('CENTER', self, 46, 35)
smallcircle5texture:SetSize(26, 26)
smallcircle5texture:SetTexCoord(0, 1, 0, 1)
smallcircle5:SetAlpha(0)

smallcircle5:RegisterEvent("PLAYER_ENTERING_WORLD")
smallcircle5:RegisterEvent("GROUP_ROSTER_UPDATE")
smallcircle5:SetScript("OnEvent", function(self, event, ...)

  if IsInGroup() then
      self:SetAlpha(1)
  else
      self:SetAlpha(0)
  end

end)


GreyFox777 04-14-18 06:58 PM

nice, it works now,

Quote:

local smallcircle5 = CreateFrame("Frame", "SmallCircleTopCenter", self)
smallcircle5:RegisterEvent("GROUP_ROSTER_UPDATE")

smallcircle5:SetFrameLevel(self.Health:GetFrameLevel() + 5)
local smallcircle5texture = smallcircle5:CreateTexture(nil, "ARTWORK")

smallcircle5:SetScript("OnEvent", function(self, event, ...)
if IsInGroup(unit) then
smallcircle5texture:SetTexture(m.textures.smallcircle)
end
end)
smallcircle5texture:SetPoint('CENTER', self, 46, 35)
smallcircle5texture:SetSize(26,26)
smallcircle5texture:SetTexCoord(0, 1, 0, 1)
But the texture stays, even if im not in group anymore.

Ammako 04-14-18 07:01 PM

Why are you doing your own thing when you were given code that already should do everything right?

You're setting the texture for when you are in a group, but not doing anything to remove it once you're not in a group anymore. So it stays.

Also, I recommend you look up some general guidelines on code quality and readability, and at the least, use [highlight="lua"] tags with proper indentation when adding code snippets to posts.

http://lua-users.org/wiki/LuaStyleGuide

GreyFox777 04-14-18 07:05 PM

ì worked before in weakauras, there was no need for untrigger, but i have no clue how to do it native :D

GreyFox777 04-14-18 07:11 PM

i did it, now work fine
Quote:

texture:Show()

else

texture:Hide()

Tim 04-14-18 07:36 PM

texture:Show and Hide will not work in combat. Change your coding to this...

Code:

local smallcircle5 = CreateFrame("Frame", "SmallCircleTopCenter")
smallcircle5:SetFrameLevel(self.Health:GetFrameLevel() + 5)

local smallcircle5texture = smallcircle5:CreateTexture(nil, "ARTWORK")
smallcircle5texture:SetTexture(nil)
smallcircle5texture:SetPoint('CENTER', self, 46, 35)
smallcircle5texture:SetSize(26, 26)
smallcircle5texture:SetTexCoord(0, 1, 0, 1)

smallcircle5:RegisterEvent("PLAYER_ENTERING_WORLD")
smallcircle5:RegisterEvent("GROUP_ROSTER_UPDATE")
smallcircle5:SetScript("OnEvent", function(self, event, ...)

  if IsInGroup() then
      smallcircle5texture:SetTexture(m.textures.smallcircle)
  else
      smallcircle5texture:SetTexture(nil)
  end

end)


GreyFox777 04-14-18 07:50 PM

Tim, are you sure? I just tested, it works in combat also.

As far i know, only secure frames doesen't work in combat.

Tim 04-14-18 07:54 PM

Yeah you're right. I'm out of it.. I had to alter my post 3 times bc I put things in the wrong spots and forgot code. I should go to bed, lol.

GreyFox777 04-14-18 07:55 PM

wait, please tell me how can i create an another texture over my circle and anchor it? It need the default leader icon

Tim 04-14-18 08:15 PM

If you're trying to add role, etc. icons onto your unit frames you can just use the built-in ones for oUF.

https://github.com/oUF-wow/oUF/blob/...rindicator.lua

Code:

    -- Position and size
    local LeaderIndicator = self:CreateTexture(nil, 'OVERLAY')
    LeaderIndicator:SetSize(16, 16)
    LeaderIndicator:SetPoint('BOTTOM', self, 'TOP')

    -- Register it with oUF
    self.LeaderIndicator = LeaderIndicator


Go up 1 tree to: https://github.com/oUF-wow/oUF/tree/master/elements and there's the other built-in elements for oUF.

Kanegasi 04-14-18 08:16 PM

IsInGroup does not accept units. It is only to check if you are in a group. The only argument it has is to check realm groups or instance groups.

https://wow.gamepedia.com/API_IsInGroup

If it doesn't matter what kind of group you are in, just IsInGroup() is fine.

GreyFox777 04-14-18 08:24 PM

Quote:

Originally Posted by Tim (Post 327544)
If you're trying to add role, etc. icons onto your unit frames you can just use the built-in ones for oUF.

https://github.com/oUF-wow/oUF/blob/...rindicator.lua

Code:

    -- Position and size
    local LeaderIndicator = self:CreateTexture(nil, 'OVERLAY')
    LeaderIndicator:SetSize(16, 16)
    LeaderIndicator:SetPoint('BOTTOM', self, 'TOP')

    -- Register it with oUF
    self.LeaderIndicator = LeaderIndicator

Go up 1 tree to: https://github.com/oUF-wow/oUF/tree/master/elements and there's the other built-in elements for oUF.

Yea, have already found that code, but it need to be anchored to a circle frame.

Tim 04-14-18 08:28 PM

So? You can anchor it to your circle frame just by changing the self in the setpoint to the name of your circle frame.

GreyFox777 04-14-18 08:36 PM

Quote:

Originally Posted by Tim (Post 327547)
So? You can anchor it to your circle frame just by changing the self in the setpoint to the name of your circle frame.

I did it already, but the texture are not showing, i think it's a layering problem. Need somehow to set framelevel



Anyone know how do i change the strata level of the elements in ouf?

And if there any way for smoothing text positioning?


All times are GMT -6. The time now is 08:06 PM.

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