strict.lua, now available to find/fix Lua typos!

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
I've uploaded this for all you Lua modders. See thread here. It's really an extraordinary tool for finding typos and logical mistakes in your Lua code.

The example I give is this:
Code:
local bWrapX = Map.IsWrapX()
function AdjacentPlotIterator(plot)
	[COLOR="Silver"]< snip >[/COLOR]
	if bXWrap then
		[COLOR="Silver"]< snip >[/COLOR]
	end
end
A very nasty error that sat in my code for a very long time. This would never happen in C++ (or similar) but scripting languages are awful for letting you make this kind of error.

You can use strict.lua to identify these kind of mistakes. It would identify the above as assignment to an undeclared global (with global name and file/line# where it happened). You may be dismayed by how many of these are in your code if your mod has >1000s of lines of Lua.

And it can be used for table keys too! You can make a table "strict" allowing identification of cases where a misspelled key is causing you to get a nil or assign to a new key when you intended to assign to an existing key.

So have fun slaying those Lua typos!
 
Top Bottom