Thread Tools Display Modes
09-15-09, 08:36 AM   #1
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
I need help debugging this please

Hi all,


I wrote a really simple addon with autoresponses to whisper. There are some filters to select different automessage but that's not the point.

The problem is that when I recieve a whisper (and the addon is active), game almost freeze. Fps drops to 2, and addon memory usage goes from 63MB to 80MB.

So it looks like and endless loop or something, but I can't find it. Is there any tool I could use to debug? With breakpoints and that stuff... (i guess no).

Or maybe can you see anything wrong in this code?

This function is called when a whisper is recieved:
Code:
function evAYChatWhisp(sender, msg)	
	isinstance, instancetype = IsInInstance();
	if fixedMsgEnabled==true then 
		SendChatMessage("Automessage: " .. parseAYMessage(FixedMsgText), "WHISPER", nil, sender);
	elseif -- Not relevant code
end
This function is called from the previous function:
Code:
function parseAYMessage(msg, sender)
	instancenamename, type, difficulty = GetInstanceInfo()

	if string.find(msg, "@user") == nil then else
		msg = string.gsub(msg, "@user", sender);
	end
	
	if string.find(msg, "@instance") == nil then else
		msg = string.gsub(msg, "@instance", instancenamename);
	end
	
	return msg;
end
  Reply With Quote
09-15-09, 08:50 AM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Your current code doesn't show anything that could cause a freeze - please post your full code. (maybe via pastey.net)

By the way:
if string.find(msg, "@instance") == nil then else
is better written as:
if string.find(msg, "@instance") then

I never encountered a "then else" without anything in between

You are also missing "local" before your "isinstance"- and "instancenamename"-variables.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
09-15-09, 09:00 AM   #3
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
What caused the freeze was GetInstanceInfo() function while I was OUTSIDE any instance :S

I expected to get a nil, not this but.. it's solved now.

As for
if string.find(msg, "@instance") == nil then else
is better written as:
if string.find(msg, "@instance") then
Are oposite things :P I didn't find a "not-equal operator" it is "!=" maybe?

I'm really confused with lua, as I always use c# at work.. :S
  Reply With Quote
09-15-09, 09:02 AM   #4
v6o
An Onyxian Warder
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 399
Originally Posted by MigGat View Post
Are oposite things :P I didn't find a "not-equal operator" it is "!=" maybe?
Not equal is ~= or you can put "if not string.find" for example.

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

You seem to be only feeding your function parseAYMessage() with one parameter yet it's not coded to check if both are set or not ?
__________________
I stopped playing back World of Warcraft in 2010 and I have no plans on returning.
This is a dead account and if you want to continue any of my addons or make a fork then feel free to do so.
This is your permission slip.

If you need to contact me, do so on Twitter @v6ooo

Best regards, v6.

Last edited by v6o : 09-15-09 at 09:11 AM.
  Reply With Quote
09-15-09, 09:09 AM   #5
MigGat
A Fallenroot Satyr
Join Date: Sep 2009
Posts: 27
Thanks! Argument error fired when I solved the GetInstanceInfo() thing, and now it's working just fine.

Thank you all again
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » I need help debugging this please


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