[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

Master Bounty Hunter
User avatar
Posts: 1693
Joined: Tue Mar 31, 2009 3:40 pm
Location: Twello, The Netherlands

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

Postby mswf » Thu Dec 03, 2015 11:58 am

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.

Resistance Leader
User avatar
Posts: 5205
Joined: Tue Feb 09, 2010 8:43 pm
Location: Edinburgh, UK
Projects :: EVERYWHERE + Zero Munge + TCW
Games I'm Playing :: The Forest
xbox live or psn: Marth8880

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

Postby Marth8880 » Sat Dec 05, 2015 4:50 am

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!

Master of the Force
User avatar
Posts: 4761
Joined: Sat Sep 19, 2009 11:37 am
Location: Mos Espa (germany)
Projects :: Republic Commando Side Mod

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

Postby Anakin » Sat Dec 05, 2015 9:07 am

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).

Resistance Leader
User avatar
Posts: 5205
Joined: Tue Feb 09, 2010 8:43 pm
Location: Edinburgh, UK
Projects :: EVERYWHERE + Zero Munge + TCW
Games I'm Playing :: The Forest
xbox live or psn: Marth8880

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

Postby Marth8880 » Sat Dec 05, 2015 3:13 pm

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

Rebel Warrant Officer
User avatar
Posts: 308
Joined: Thu Aug 15, 2013 11:27 am
Location: Belsavis, Maximum Security Ward
Projects :: Old Republic Map pack
Games I'm Playing :: BF2 SWTOR and GW2
xbox live or psn: No gamertag set

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

Postby ZoomV » Sat Dec 05, 2015 4:54 pm

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

Master of the Force
User avatar
Posts: 4761
Joined: Sat Sep 19, 2009 11:37 am
Location: Mos Espa (germany)
Projects :: Republic Commando Side Mod

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

Postby Anakin » Sat Dec 05, 2015 6:09 pm

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)

Return to SWBF2 Modding

Who is online

Users browsing this forum: No registered users and 1 guest