Luacheck linting for TheoTown

The Lua scripting language allows you to give your plugin more advanced features.

Moderator: Plugin Moderators

User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Luacheck linting for TheoTown

#1

Post by Bearbear76 »

Hello!
If you ever wanted to use linting in your text editor but do not like the fact the every TheoTown global is linted as an warning, I got the plugin for you!
This plugin will let Luacheck identify all the TheoTown specific globals.

Installation
First you would have to download Luacheck found here: https://github.com/mpeterv/luacheck
follow the instructions there to install Luacheck onto your device. If you have any trouble with installing ask me! :)
Windows/Linux/Mac only!

Implementation
This plugin is basically a config file that contains all TheoTown globals inside (i.e. those that were listed on the Reference).
Download the zip file provided below and extract the ".luacheckrc" file from it.
The placement of the file should be in the plugin folder of the TheoTown folder (assuming that you will develop plugins from there).
If for some reason you develop your plugins in your Downloads folder put it in there.

downloaded the file but it doesn't appear?
If you downloaded the file but you can't find it, it's because the file starts with a "." which means it hidden. You would need to
enable the "show hidden files" option on your file explorer.

Without this plugin:
All the yellow underlines are warnings :/
All the yellow underlines are warnings :/
Edit: ignore the local house mistake

With this plugin:
Much cleaner! :D
Much cleaner! :D
Download
Download from here:
luacheck-theotown.zip
Version 4.1
(2.94 KiB) Downloaded 146 times
Show
Full changelog
[26/5/2020] Version: 2
4 added, 0 fixed

[26/5/2020] Version: 3
0 added, 1 fixed

[10/2/2021] Version: 4
107 added, 1 fixed

[10/2/2021] Version: 4.1
0 added, 2 fixed

Found a bug?
All the globals were manually typed and I would be lying if I told you I checked every global, so if you find a global that highlights as a warning
tell me and I will fix it as soon as possible!

So far tested with Visual Studio Code and Sublime Text 3 and Atom

:jb: Bear out!
User avatar
Bevise
Micy's Assistant
Reactions:
Posts: 502
Joined: 27 Feb 2020, 15:39
Location: Phu Quoc Island, Vietnam
Plugins: Showcase Store
Version: Beta
Contact:

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#2

Post by Bevise »

I am an Android user, it's a sad news. :(
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#3

Post by Bearbear76 »

Update version: 2
  • Added City.execute()
  • Added TheoTown.daytime
  • Added TheoTown.getRegionCoins()
  • Added Builder.finishBuilding()
overall: 4 added, 0 fixed

Bear Out! :jb:
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#4

Post by Bearbear76 »

Bevise wrote: 26 May 2020, 02:30 I am an Android user, it's a sad news. :(
If you can use a PC I would recommend writing code on it, but if you only have android you can use "QuickEdit"
as it get the job done. :)
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#5

Post by Bearbear76 »

Update version: 3
  • Fixed major problem with standard globals.
note:
The config file was using "min" (intersection of globals of Lua 5.1, Lua 5.2 and LuaJIT 2.0) as the standard globals which
caused warnings on valid globals such as the table library. Since TheoTown runs on Luaj which is based
on lua 5.2 I have set the standard globals as "lua52" (globals of Lua 5.2). This should remove problems with
the table library and hopefully others.

I would highly recommend updating to this version

overall: 0 added, 1 fixed

Bear Out! :jb:
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#6

Post by Bearbear76 »

Update version: 4

It's been a while since I updated this and many things were added. So this is a huge update!
I would recommend updating to this version.
  • Arranged the order to match the official documentation (alphabetical)
  • Added commas to the end of tables for easier expansion
  • Replaced tabs as spaces
Show
Everything added (107 lines long!)
  • Added Builder.buildZone()
  • Added City.canSpend()
  • Added City.countBuildingsOfType()
  • Added City.getCommercialJobs()
  • Added City.getIncome()
  • Added City.getDayPart()
  • Added City.getIndustrialJobs()
  • Added City.getRegionId()
  • Added City.getRegionName()
  • Added City.getResidentialSpace()
  • Added City.openInfo()
  • Added City.playSound()
  • Added City.showNotification()
  • Added City.HAPPINESS_EDUCATION
  • Added City.HAPPINESS_ENVIRONMENT
  • Added City.HAPPINESS_FIREDEPARTMENT
  • Added City.HAPPINESS_FREETIME
  • Added City.HAPPINESS_GENERAL
  • Added City.HAPPINESS_HEALTH
  • Added City.HAPPINESS_LEVEL
  • Added City.HAPPINESS_PARK
  • Added City.HAPPINESS_POLICE
  • Added City.HAPPINESS_RELIGION
  • Added City.HAPPINESS_SPORT
  • Added City.HAPPINESS_SUPPLY
  • Added City.HAPPINESS_TAXES
  • Added City.HAPPINESS_TRANSPORT
  • Added City.HAPPINESS_WASTE
  • Added City.HAPPINESS_ZONE
  • Added City.INFO_AIRPORT
  • Added City.INFO_BUDGET
  • Added City.INFO_EDUCATION
  • Added City.INFO_ENERGY
  • Added City.INFO_GENERAL
  • Added City.INFO_HEALTH
  • Added City.INFO_LOAN
  • Added City.INFO_NEIGHBOR
  • Added City.INFO_RANK
  • Added City.INFO_RATING
  • Added City.INFO_RCI
  • Added City.INFO_STATISTICS
  • Added City.INFO_WATER
  • Added DSA.getSupplies()
  • Added DSA.isInMoon()
  • Added Draft.append()
  • Added Draft.merge()
  • Added Draft:getPluginId()
  • Added Draft:getPreviewFrame()
  • Added Draft:getPreviewFrameCount()
  • Added Draft:isPlugin()
  • Added Draft:isUnlocked()
  • Added Draft:setPreviewFrame()
  • Added Drawing.drawNinePatch
  • Added Drawing.drawRect()
  • Added Drawing.Triangle()
  • Added Drawing.getImageHandle()
  • Added Drawing.resetClipping()
  • Added Drawing.setClipping()
  • Added GUI.createDialog()
  • Added GUI.createMenu()
  • Added GUI.createRenameDialog()
  • Added GUI.get()
  • Added GUI.getRoot()
  • Added GUI:addHotkey()
  • Added GUI:countChildren()
  • Added GUI:delete()
  • Added GUI:getAbsoluteParent()
  • Added GUI:getAbsoluteX()
  • Added GUI:getAbsoluteY()
  • Added GUI:getChild()
  • Added GUI:getChildIndex()
  • Added GUI:getClientHeight()
  • Added GUI:getClientWidth()
  • Added GUI:getFont()
  • Added GUI:getHeight()
  • Added GUI:getId()
  • Added GUI:getPadding()
  • Added GUI:getParent()
  • Added GUI:getText()
  • Added GUI:getTouchPoint()
  • Added GUI:getWidth()
  • Added GUI:getWidth()
  • Added GUI:getX()
  • Added GUI:getY()
  • Added GUI:isEnabled()
  • Added GUI:isValid()
  • Added GUI:isVisible()
  • Added GUI:layout()
  • Added GUI:removeHotkey()
  • Added GUI:setChildIndex()
  • Added GUI:setEnabled()
  • Added GUI:setFont()
  • Added GUI:setId()
  • Added GUI:setPadding()
  • Added GUI:setPosition()
  • Added GUI:setSize()
  • Added GUI:setText()
  • Added GUI:setVisible()
  • Added Script.EVENT_TOOL_LEAVE
  • Added script:buildCityGUI()
  • Added script:drawCity()
  • Added script:finishInformationDialog()
  • Added script:settings()
  • Added TheoTown.getUserName()
  • Added Tile.isBuildingUntouchable()
  • Added Tile.isBuildingWorking()
  • Added Tile.setBuildingUntouchable()
  • Fixed (Typo) Tile.abandomBuilding() -> Tile.abandonBuilding()
overall: 107 added, 1 fixed

Bear Out! :jb:
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#7

Post by Bearbear76 »

Update version: 4.1

This is quick fix. I found 2 typos during writing the changelog for version 4.
  • Fixed (Typo) GUI:getChildHeight() -> GUI:getClientHeight()
  • Fixed (Typo) GUI:getChildWidth() -> GUI:getClientWidth()
overall: 0 added, 2 fixed

Bear Out! :jb:
User avatar
JustAnyone
Developer
Reactions:
Posts: 3474
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: Luacheck linting for TheoTown

#8

Post by JustAnyone »

This a good thing, I like it
User avatar
Wekabu city
Inhabitant of a Megalopolis
Reactions:
Posts: 586
Joined: 29 Aug 2017, 21:07
Location: Germany, Hessia
Plugins: Showcase Store
Version: Beta

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#9

Post by Wekabu city »

Bearbear76 wrote: 24 May 2020, 09:00 <snip>
Windows/Lunix/Mac only!
<snip>
You mean LinuxUNIX, right?
This looks interesting and worth using I must say, keep up the effort.
Last edited by Wekabu city on 10 Feb 2021, 12:29, edited 1 time in total.
User avatar
JustAnyone
Developer
Reactions:
Posts: 3474
Joined: 23 Jul 2017, 12:45
Location: Easter Island
Plugins: Showcase Store

Platform

Re: Luacheck linting for TheoTown

#10

Post by JustAnyone »

Wekabu city wrote: 10 Feb 2021, 11:55 You mean Linux, right?
This looks interesting and worth using I must say, keep up the effort.
Show
Short reply
Lunix sounds like a distro that could actually exist
Show
Long reply
I'd just like to interject for a moment. What you’re referring to as Linux, is in fact, GNU/Linux, or as I’ve recently taken to calling it, GNU plus Linux. Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called “Linux”, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project. There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine’s resources to the other programs that you run. The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux. All the so-called “Linux” distributions are really distributions of GNU/Linux.
User avatar
Bearbear76
Former Bearbear65
Reactions:
Posts: 5730
Joined: 10 Feb 2017, 14:53
Location: L2 cache
Plugins: Showcase Store

Plugin Creator

Platform

Re: Luacheck linting for TheoTown

#11

Post by Bearbear76 »

Wekabu city wrote: 10 Feb 2021, 11:55
Bearbear76 wrote: 24 May 2020, 09:00 <snip>
Windows/Lunix/Mac only!
<snip>
You mean Linux, right?
This looks interesting and worth using I must say, keep up the effort.
Oof I'm going to fix that and thanks!
Post Reply Previous topicNext topic

Return to “Lua Scripting”