Thread Tools Display Modes
04-14-18, 05:52 PM   #1
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
IsInGroup not working

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

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.
  Reply With Quote
04-14-18, 06:15 PM   #2
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
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)
__________________
AddOns: Tim @ WoWInterface
Characters: Mage, Priest, Devoker, Pally
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
04-14-18, 06:58 PM   #3
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
nice, it works now,

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.
  Reply With Quote
04-14-18, 07:01 PM   #4
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
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

Last edited by Ammako : 04-14-18 at 07:11 PM.
  Reply With Quote
04-14-18, 07:05 PM   #5
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
ì worked before in weakauras, there was no need for untrigger, but i have no clue how to do it native
  Reply With Quote
04-14-18, 07:11 PM   #6
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
i did it, now work fine
texture:Show()

else

texture:Hide()

Last edited by GreyFox777 : 04-14-18 at 07:26 PM.
  Reply With Quote
04-14-18, 07:36 PM   #7
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
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)
__________________
AddOns: Tim @ WoWInterface
Characters: Mage, Priest, Devoker, Pally
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List

Last edited by Tim : 04-14-18 at 07:38 PM.
  Reply With Quote
04-14-18, 07:50 PM   #8
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
Tim, are you sure? I just tested, it works in combat also.

As far i know, only secure frames doesen't work in combat.
  Reply With Quote
04-14-18, 07:54 PM   #9
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
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.
__________________
AddOns: Tim @ WoWInterface
Characters: Mage, Priest, Devoker, Pally
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
04-14-18, 07:55 PM   #10
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
wait, please tell me how can i create an another texture over my circle and anchor it? It need the default leader icon
  Reply With Quote
04-14-18, 08:15 PM   #11
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
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.
__________________
AddOns: Tim @ WoWInterface
Characters: Mage, Priest, Devoker, Pally
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
04-14-18, 08:16 PM   #12
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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.
  Reply With Quote
04-14-18, 08:24 PM   #13
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
Originally Posted by Tim View Post
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.
  Reply With Quote
04-14-18, 08:28 PM   #14
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
So? You can anchor it to your circle frame just by changing the self in the setpoint to the name of your circle frame.
__________________
AddOns: Tim @ WoWInterface
Characters: Mage, Priest, Devoker, Pally
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
04-14-18, 08:36 PM   #15
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
Originally Posted by Tim View Post
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?

Last edited by GreyFox777 : 04-14-18 at 11:31 PM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » IsInGroup not working

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