[tutorial] Using a Linter ("spellchecking" for Lua script)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
mswf
Master Bounty Hunter
Master Bounty Hunter
Posts: 1674
Joined: Tue Mar 31, 2009 3:40 pm
Location: Twello, The Netherlands
Contact:

[tutorial] Using a Linter ("spellchecking" for Lua script)

Post by mswf »

This is a short guide on a tool to assist you while you script. It will help you find several types of scripting errors without having to fire up the game!

Hello,

While browsing this forum and having done a lot of game development in Lua, I realised I had this tidbit of information that had not been mentioned on this forum. So here we go.

A code linter is a plugin for your script editor that tries to run parts of your script and will notify you what and where you probably made a mistake. It's quite limited in the type of mistakes it will catch for you, but at I noticed several help topics here where this technique would've found the mistake sooner.

Here's how to get rolling:
  • Install a code editor that supports plugins, like Atom (free, open-source) or Sublime Text (free trial)
  • Install a base Linter plugin (for Atom, or for Sublime Text). This will require you to find out how to install plugins for your text editor. For Atom it's buildin, for Sublime Text you will have to read the documentation on the website I linked to.
  • Install the Lua Linter (Atom, Sublime Text)
  • Type away!!
Image
  • Get told off by your editor!! (these error messages will appear as you type)
This has increased my own productivity immensely, I hope it may do the same for others.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: [tutorial] Using a Linter ("spellchecking" for Lua scrip

Post by Marth8880 »

Cool! Personally, I use the Lua Development Tools extension of Eclipse as a Lua IDE, but this sounds pretty neat too!

I'm still waiting for a decent and fully-featured Lua plugin for Visual Studio though, haha!
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [tutorial] Using a Linter ("spellchecking" for Lua scrip

Post by Anakin »

Don't think there will be ever a visual studio plugin. LUA scripting is more for hobby programmer (please correct me if I'm wrong) and visual studio for pros (because they have the money).
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: [tutorial] Using a Linter ("spellchecking" for Lua scrip

Post by Marth8880 »

Anakin wrote:Don't think there will be ever a visual studio plugin.
Well, technically there already are, but just not with IntelliSense or very advanced debugging.
Anakin wrote:LUA scripting is more for hobby programmer (please correct me if I'm wrong)
Depends on what you're developing for. CryEngine and Source both utilize Lua, whereas Unity utilizes C# (and JavaScript, too - LOL), UE4 utilizes a nearly illegible and impossible concoction of C++ (and Blueprint of course - though I've seen plugins for Lua and other scripting languages before in the Marketplace as well), and the UDK utilizes its own horrible scripting language, UnrealScript (and Kismet). :n Personally, I'd say a language like Python would be better-suited to categorize as a hobbyist language (although it is pretty commonly used as a scripting extension in 3D software), simply because it's not exactly optimized for speed (from what I've read, anyway).

Personally though, I've grown to hate Lua more and more over the past year-and-a-half while learning more and more C, C# and Java, simply due to its lack of many extremely common and useful aspects, such as proper switch statements, increment/decrement operators, arithmetic assignment operators (+=, -=, etc.) - and the list goes on.

But hey, at least Lua doesn't require you to declare a variable's type before assigning it, or declare a function's return type, or declare whether a variable or function is public, private, static, etc. Image
ZoomV
Rebel Warrant Officer
Rebel Warrant Officer
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set
Location: Belsavis, Maximum Security Ward

Re: [tutorial] Using a Linter ("spellchecking" for Lua scrip

Post by ZoomV »

Marth8880 wrote: I'd say a language like Python would be better-suited to categorize as a hobbyist language (although it is pretty commonly used as a scripting extension in 3D software), simply because it's not exactly optimized for speed (from what I've read, anyway).
It's not so much that Python is bad for speed, it's that if speed is what you care about there is zero point to using Python since the entirety of Python is actually implemented in C. Python is really just a additional layer overtop of C.
The other obnoxious bit about Python is how arbitrary importing other source files can be and how un-transparent the languages is about what is and isn't passed by reference.


But hey, at least Lua doesn't require you to declare a variable's type before assigning it, or declare a function's return type, or declare whether a variable or function is public, private, static, etc. Image
I'm taking a java course right now and well....
System.out.println
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [tutorial] Using a Linter ("spellchecking" for Lua scrip

Post by Anakin »

I "learned" a bit Java in school (with bluej). And in the university we use c, than c++, matlab and later some assembler. My favorite is c++. But maybe I just like it so much because I know the most important commands and did most of programming with c++.

(no idea how we went out of topic. sry for that)
Post Reply