Thread Tools Display Modes
12-09-11, 01:12 AM   #1
Alianka
A Wyrmkin Dreamwalker
 
Alianka's Avatar
Join Date: May 2011
Posts: 51
Event call ?

Hello,

recently i was trying to do a script that texts out how much time left untill out of mana and would like to have there also a call for being in combat so that script is working only in combat and not outside of combat.

I have read here on forums about events and come up with this

WoWEvents:Bind("PLAYER_REGEN_DISABLED", nil, combat);

To my knowlidge this above is call for the event. And with this above i was unable to print out any text while in combat regardless of what it was, anyone would know, when i have a text inside my local function combat, how to print that text out ? As of note without the event it works like a charm, but with it, no go.

Regards
Alianka

Last edited by Alianka : 12-09-11 at 01:30 AM.
  Reply With Quote
12-09-11, 02:11 AM   #2
Brainn
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 263
from what i remember the event should trigger the function when you enter combar, but not during combat.
now i dont completely understand what you want to achiev, do you want the function itself to just print out some stuff to the chatframe, or do you want to use in some unitframe as a text-variable ?

reading it again while writing this post, you are trying to poll if you are in combat via the WoWEvents:Register() stuff ?
that wont work, it just links the function call to the event so if the event gets fired (in this case when you enter combat) the function gets called one time, nothing else.
to just get a quick poll if you are in combat or not i would suggest you use InCombatLockdown(), the function returns true while in combat and false if not.
  Reply With Quote
12-09-11, 09:00 AM   #3
Narinka
A Chromatic Dragonspawn
Join Date: Oct 2008
Posts: 165
And I do it another way.
I just show-hide (Var IsInCombat?) frame or window that has such things. Not sure it is correct way but it worked for me ) From what I see - no window -> no repaint -> no script working.
And more clean screen out of combat But to be sure better use what Brainn suggests as double check.
  Reply With Quote
12-09-11, 09:47 AM   #4
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
Like this ?

Code:
VFL.print("Register events")
WoWEvents:Bind("PLAYER_REGEN_DISABLED", nil, function() VFL.print("Entering combat") end);
WoWEvents:Bind("PLAYER_REGEN_ENABLED", nil, function() VFL.print("Leaving combat") end);
__________________
RDX manager
Sigg
  Reply With Quote
12-09-11, 10:19 AM   #5
Brainn
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 263
i think what narinka trys goes more in the direction of this:
Code:
if IsCombatLockdown() then
   dostuff
else
   donothing
end
  Reply With Quote
12-09-11, 11:05 AM   #6
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
You mean something like this:
Code:
local COMBAT
WoWEvents:Bind("PLAYER_REGEN_DISABLED", nil, function() COMBAT = 1 end)
WoWEvents:Bind("PLAYER_REGEN_ENABLED", nil, function() COMBAT = nil end)
local function test()
  if COMBAT then
    print("You are in combat.")
  else
    print("You are not in combat.")
  end
end
The idea is that these 2 events that run set the COMBAT value to 1 or nil, so you can later in your addon code use that to know if you are in combat or not.

I've had some issues using IsCombatLockdown() myself, some times my code didn't work so I got fed up and started to use the method above, so set a variable to 1 or nil that my addon used to decide if in combat or not, not sure why the API doesn't always work like it should (had problems creating secure frames as it was not accurate as I thought it would be.)
  Reply With Quote

WoWInterface » Featured Projects » OpenRDX » OpenRDX Community » OpenRDX: Community Chat » Simple math test and fail


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