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 / (at /
(linters (linters
syntax:string-index
;; It'd be nice to avoid this, but right now there's a lot of instances of ;; It'd be nice to avoid this, but right now there's a lot of instances of
;; it. ;; it.
-var:set-loop -var:set-loop
@ -36,7 +38,14 @@
;; Suppress a couple of documentation comments warnings for now. We'll ;; Suppress a couple of documentation comments warnings for now. We'll
;; hopefully be able to remove them in the future. ;; hopefully be able to remove them in the future.
-doc:undocumented -doc:undocumented-arg -doc:unresolved-reference -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 ;; We disable the unused global linter in bios.lua and the APIs. In the future
;; hopefully we'll get illuaminate to handle this. ;; hopefully we'll get illuaminate to handle this.

View File

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

View File

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