Hello,
It seems I need all the help I can get. Will the version 2.0 editor highlight unused variables?
I’ve spent ages trying to work out why my code didn’t work, only to find I’d typed a variable as nextx instead of nextX
Thanks,
David
Hello,
It seems I need all the help I can get. Will the version 2.0 editor highlight unused variables?
I’ve spent ages trying to work out why my code didn’t work, only to find I’d typed a variable as nextx instead of nextX
Thanks,
David
I have not tried them, but there are existing Lua linters which can be used with editors such as Atom.
Ok thanks, I may give one a try. I also (every now and then) lose my way in find which if matches an end.
There are many ways to catch things like this. One way is as @Pkeod says to use a Lua linter to perform static code analysis to detect unused variables, accidental global assignments etc. Linters exist in many different forms. You can fins them as plugins to existing editors such as Atom and Sublime. You can also find them fully integrated in the editor from the start such as in LDT or Sylvanaar (Editor 2.0 will have a linter integrated). You can also find stand-alone versions of linters that you can run from the command line (LuaCheck and LuaInspect are the most popular). Stand alone linters are perfect for integration in a build pipeline on a CI system.
Another way to detect mistyped variable names such as in your example is by locking the Lua global table through a metatable with control of the __index and __newindex metamethods. You can read more about this approach here: http://lua-users.org/wiki/DetectingUndefinedVariables
Thanks very much…