1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-11 18:00:29 +00:00

Reformat bracketed expressions in Lua

- Parenthesised expressions (function calls, arguments, etc...) should
   never have spaces in them.
 - Tables always will have spaces inside.
This commit is contained in:
SquidDev 2020-04-18 10:09:40 +01:00
parent f9f94b8304
commit 865fc239a0
78 changed files with 2168 additions and 2159 deletions

View File

@ -25,6 +25,8 @@
(at /
(linters
syntax:string-index
;; It'd be nice to avoid this, but right now there's a lot of instances of
;; it.
-var:set-loop
@ -36,7 +38,14 @@
;; Suppress a couple of documentation comments warnings for now. We'll
;; hopefully be able to remove them in the future.
-doc:undocumented -doc:undocumented-arg -doc:unresolved-reference
-var:unresolved-member))
-var:unresolved-member)
(lint
(bracket-spaces
(call no-space)
(function-args no-space)
(parens no-space)
(table space)
(index no-space))))
;; We disable the unused global linter in bios.lua and the APIs. In the future
;; hopefully we'll get illuaminate to handle this.

View File

@ -390,7 +390,7 @@ local function getRoom( x, y, z, dontCreate )
["west"] = true,
}
if math.random(1, 8) == 1 then
room.exits["down"] = true
room.exits.down = true
room.items["a cave entrance"] = items["a cave entrance"]
end
@ -412,8 +412,8 @@ local function getRoom( x, y, z, dontCreate )
if y == -1 then
local above = getRoom(x, y + 1, z)
if above.exits["down"] then
room.exits["up"] = true
if above.exits.down then
room.exits.up = true
room.items["an exit to the surface"] = items["an exit to the surface"]
end
else
@ -608,7 +608,7 @@ local tMatches = {
local commands = {}
local function doCommand(text)
if text == "" then
commands[ "noinput" ]()
commands.noinput()
return
end
@ -626,7 +626,7 @@ local function doCommand( text )
end
end
end
commands[ "badinput" ]()
commands.badinput()
end
function commands.wait()
@ -761,24 +761,24 @@ function commands.dig( _sDir, _sTool )
end
if _sDir == "north" then
room.exits["north"] = true
room.exits.north = true
z = z + 1
getRoom( x, y, z ).exits["south"] = true
getRoom(x, y, z).exits.south = true
elseif _sDir == "south" then
room.exits["south"] = true
room.exits.south = true
z = z - 1
getRoom( x, y, z ).exits["north"] = true
getRoom(x, y, z).exits.north = true
elseif _sDir == "east" then
room.exits["east"] = true
room.exits.east = true
x = x - 1
getRoom( x, y, z ).exits["west"] = true
getRoom(x, y, z).exits.west = true
elseif _sDir == "west" then
room.exits["west"] = true
room.exits.west = true
x = x + 1
getRoom( x, y, z ).exits["east"] = true
getRoom(x, y, z).exits.east = true
elseif _sDir == "up" then
if y == 0 then
@ -786,14 +786,14 @@ function commands.dig( _sDir, _sTool )
return
end
room.exits["up"] = true
room.exits.up = true
if y == -1 then
room.items["an exit to the surface"] = items["an exit to the surface"]
end
y = y + 1
room = getRoom(x, y, z)
room.exits["down"] = true
room.exits.down = true
if y == 0 then
room.items["a cave entrance"] = items["a cave entrance"]
end
@ -804,14 +804,14 @@ function commands.dig( _sDir, _sTool )
return
end
room.exits["down"] = true
room.exits.down = true
if y == 0 then
room.items["a cave entrance"] = items["a cave entrance"]
end
y = y - 1
room = getRoom(x, y, z)
room.exits["up"] = true
room.exits.up = true
if y == -1 then
room.items["an exit to the surface"] = items["an exit to the surface"]
end

View File

@ -18,8 +18,8 @@ local tProgramStack = {}
local shell = {}
local function createShellEnv(sDir)
local tEnv = {}
tEnv[ "shell" ] = shell
tEnv[ "multishell" ] = multishell
tEnv.shell = shell
tEnv.multishell = multishell
local package = {}
package.loaded = {
@ -100,8 +100,8 @@ local function createShellEnv( sDir )
error(sError, 2)
end
tEnv["package"] = package
tEnv["require"] = require
tEnv.package = package
tEnv.require = require
return tEnv
end
@ -132,7 +132,7 @@ local function run( _sCommand, ... )
local sDir = fs.getDir(sPath)
local env = createShellEnv(sDir)
env[ "arg" ] = { [0] = _sCommand, ... }
env.arg = { [0] = _sCommand, ... }
local result = os.run(env, sPath, ...)
tProgramStack[#tProgramStack] = nil