View Single Post
06-02-20, 10:06 PM   #6
AreGee
A Defias Bandit
Join Date: Jun 2020
Posts: 3
Thank you for pointing me in the right direction!

I think you are right, although the function HandleLuaWarning(...) did not do anything visible at all. It did not stop execution of the script either, so it is definitely a valid function.

I will leave in your modified code for now as it seems that you are right that the code 0 is a script error. Now I need to locate where I put in those mistakes... I think I put them in on purpose but I don't remember where, lol.

EDIT:

A bit of research reveals the HandleLuaWarning function:

Code:
function HandleLuaWarning(warnType, warningMessage)
	local cvarName = "scriptWarnings";
	if ( warnType == LUA_WARNING_TREAT_AS_ERROR ) then
		cvarName = "scriptErrors";
	end

	DisplayMessageInternal(cvarName, warnType, warningMessage, MESSAGE_TYPE_WARNING);
end
So it seems all you need to do is your first suggestion to only call the function to handle the error/warning as the test is done in there anyway.

Either way, a warning message of nil is not much of help anyway.

EDIT 2:
Also, I found that the reason I never get any error messages no matter why, apart from this problem, is because WoW does not display script errors per default.

It can be turned on by the following, but I assume this is not new to anyone here:

Code:
/console scriptErrors 1
It was a script error, by the way. A part that I left out where I copy pasted and forgot to change the name of a variable made me call a function from nil.

I have a theory that script errors are treated like they are (0 (null)) because you can enable them like above to have the game show you the error message anyway. After all the name is LUA_WARNINGS, not -ERRORS.

My final version, for completeness:

Code:
local function AST_Event_LUAWarning(self, event, ...)
 local warnType, warningText = ...
 if warnType == LUA_WARNING_TREAT_AS_ERROR then
  print("ERROR: To see errors, type '/console scriptErrors 1' in the chat window, then reload your AddOn.")
 else
  print("Warning: " .. event .. ", type: " .. tostring(warnType) .. ", text: " .. tostring(warningText))
 end
end

Last edited by AreGee : 06-02-20 at 10:43 PM.
  Reply With Quote