mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-07 07:50:27 +00:00
Lint bios and the rom (#321)
We now use illuaminate[1]'s linting facilities to check the rom and bios.lua for a couple of common bugs and other problems. Right now this doesn't detect any especially important bugs, though it has caught lots of small things (unused variables, some noisy code). In the future, the linter will grow in scope and features, which should allow us to be stricter and catch most issues. As a fun aside, we started off with ~150 bugs, and illuaminate was able to fix all but 30 of them, which is pretty neat. [1]: https://github.com/SquidDev/illuaminate
This commit is contained in:
parent
0ae70fed13
commit
86e0330100
@ -11,5 +11,8 @@ insert_final_newline = true
|
|||||||
[*.md]
|
[*.md]
|
||||||
trim_trailing_whitespace = false
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.sexp]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
[*.properties]
|
[*.properties]
|
||||||
insert_final_newline = false
|
insert_final_newline = false
|
||||||
|
15
.github/workflows/main-ci.yml
vendored
15
.github/workflows/main-ci.yml
vendored
@ -4,6 +4,7 @@ on: [push, pull_request]
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
name: Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@ -16,3 +17,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew build --no-daemon
|
run: ./gradlew build --no-daemon
|
||||||
|
|
||||||
|
lint-lua:
|
||||||
|
name: Lint Lua
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Lint Lua code
|
||||||
|
run: |
|
||||||
|
test -d bin || mkdir bin
|
||||||
|
test -f bin/illuaminate || wget -q -Obin/illuaminate https://squiddev.cc/illuaminate/bin/illuaminate
|
||||||
|
chmod +x bin/illuaminate
|
||||||
|
GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} bin/illuaminate lint --github
|
||||||
|
25
illuaminate.sexp
Normal file
25
illuaminate.sexp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
; -*- mode: Lisp;-*-
|
||||||
|
|
||||||
|
(sources
|
||||||
|
/src/main/resources/assets/computercraft/lua/bios.lua
|
||||||
|
/src/main/resources/assets/computercraft/lua/rom/)
|
||||||
|
|
||||||
|
(at /
|
||||||
|
(linters
|
||||||
|
;; It'd be nice to avoid this, but right now there's a lot of instances of it.
|
||||||
|
-var:set-loop
|
||||||
|
|
||||||
|
;; It's useful to name arguments for documentation, so we allow this. It'd
|
||||||
|
;; be good to find a compromise in the future, but this works for now.
|
||||||
|
-var:unused-arg))
|
||||||
|
|
||||||
|
;; We disable the two global linters in bios.lua and the APIs. In the future
|
||||||
|
;; hopefully we'll get illuaminate to handle this.
|
||||||
|
(at
|
||||||
|
(/src/main/resources/assets/computercraft/lua/bios.lua
|
||||||
|
/src/main/resources/assets/computercraft/lua/rom/apis/)
|
||||||
|
(linters -var:set-global -var:unused-global))
|
||||||
|
|
||||||
|
;; These warnings are broken right now
|
||||||
|
(at completion.lua (linters -doc:malformed-type))
|
||||||
|
(at (bios.lua worm.lua) (linters -control:unreachable))
|
@ -184,7 +184,7 @@ function sleep( nTime )
|
|||||||
expect(1, nTime, "number", "nil")
|
expect(1, nTime, "number", "nil")
|
||||||
local timer = os.startTimer( nTime or 0 )
|
local timer = os.startTimer( nTime or 0 )
|
||||||
repeat
|
repeat
|
||||||
local sEvent, param = os.pullEvent( "timer" )
|
local _, param = os.pullEvent( "timer" )
|
||||||
until param == timer
|
until param == timer
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ function write( sText )
|
|||||||
newLine()
|
newLine()
|
||||||
end
|
end
|
||||||
term.write( text )
|
term.write( text )
|
||||||
text = string.sub( text, (w-x) + 2 )
|
text = string.sub( text, w-x + 2 )
|
||||||
x,y = term.getCursorPos()
|
x,y = term.getCursorPos()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -332,7 +332,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
|
|
||||||
local _, cy = term.getCursorPos()
|
local _, cy = term.getCursorPos()
|
||||||
term.setCursorPos( sx, cy )
|
term.setCursorPos( sx, cy )
|
||||||
local sReplace = (_bClear and " ") or _sReplaceChar
|
local sReplace = _bClear and " " or _sReplaceChar
|
||||||
if sReplace then
|
if sReplace then
|
||||||
term.write( string.rep( sReplace, math.max( #sLine - nScroll, 0 ) ) )
|
term.write( string.rep( sReplace, math.max( #sLine - nScroll, 0 ) ) )
|
||||||
else
|
else
|
||||||
@ -544,7 +544,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cx, cy = term.getCursorPos()
|
local _, cy = term.getCursorPos()
|
||||||
term.setCursorBlink( false )
|
term.setCursorBlink( false )
|
||||||
term.setCursorPos( w + 1, cy )
|
term.setCursorPos( w + 1, cy )
|
||||||
print()
|
print()
|
||||||
@ -775,7 +775,7 @@ if http then
|
|||||||
if not ok then return ok, err end
|
if not ok then return ok, err end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local event, url, ok, err = os.pullEvent( "http_check" )
|
local _, url, ok, err = os.pullEvent( "http_check" )
|
||||||
if url == _url then return ok, err end
|
if url == _url then return ok, err end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -808,8 +808,8 @@ function fs.complete( sPath, sLocation, bIncludeFiles, bIncludeDirs )
|
|||||||
expect(3, bIncludeFiles, "boolean", "nil")
|
expect(3, bIncludeFiles, "boolean", "nil")
|
||||||
expect(4, bIncludeDirs, "boolean", "nil")
|
expect(4, bIncludeDirs, "boolean", "nil")
|
||||||
|
|
||||||
bIncludeFiles = (bIncludeFiles ~= false)
|
bIncludeFiles = bIncludeFiles ~= false
|
||||||
bIncludeDirs = (bIncludeDirs ~= false)
|
bIncludeDirs = bIncludeDirs ~= false
|
||||||
local sDir = sLocation
|
local sDir = sLocation
|
||||||
local nStart = 1
|
local nStart = 1
|
||||||
local nSlash = string.find( sPath, "[/\\]", nStart )
|
local nSlash = string.find( sPath, "[/\\]", nStart )
|
||||||
@ -836,9 +836,9 @@ function fs.complete( sPath, sLocation, bIncludeFiles, bIncludeDirs )
|
|||||||
end
|
end
|
||||||
if sDir ~= "" then
|
if sDir ~= "" then
|
||||||
if sPath == "" then
|
if sPath == "" then
|
||||||
table.insert( tResults, (bIncludeDirs and "..") or "../" )
|
table.insert( tResults, bIncludeDirs and ".." or "../" )
|
||||||
elseif sPath == "." then
|
elseif sPath == "." then
|
||||||
table.insert( tResults, (bIncludeDirs and ".") or "./" )
|
table.insert( tResults, bIncludeDirs and "." or "./" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local tFiles = fs.list( sDir )
|
local tFiles = fs.list( sDir )
|
||||||
@ -867,7 +867,7 @@ end
|
|||||||
-- Load APIs
|
-- Load APIs
|
||||||
local bAPIError = false
|
local bAPIError = false
|
||||||
local tApis = fs.list( "rom/apis" )
|
local tApis = fs.list( "rom/apis" )
|
||||||
for n,sFile in ipairs( tApis ) do
|
for _,sFile in ipairs( tApis ) do
|
||||||
if string.sub( sFile, 1, 1 ) ~= "." then
|
if string.sub( sFile, 1, 1 ) ~= "." then
|
||||||
local sPath = fs.combine( "rom/apis", sFile )
|
local sPath = fs.combine( "rom/apis", sFile )
|
||||||
if not fs.isDir( sPath ) then
|
if not fs.isDir( sPath ) then
|
||||||
@ -881,7 +881,7 @@ end
|
|||||||
if turtle and fs.isDir( "rom/apis/turtle" ) then
|
if turtle and fs.isDir( "rom/apis/turtle" ) then
|
||||||
-- Load turtle APIs
|
-- Load turtle APIs
|
||||||
local tApis = fs.list( "rom/apis/turtle" )
|
local tApis = fs.list( "rom/apis/turtle" )
|
||||||
for n,sFile in ipairs( tApis ) do
|
for _,sFile in ipairs( tApis ) do
|
||||||
if string.sub( sFile, 1, 1 ) ~= "." then
|
if string.sub( sFile, 1, 1 ) ~= "." then
|
||||||
local sPath = fs.combine( "rom/apis/turtle", sFile )
|
local sPath = fs.combine( "rom/apis/turtle", sFile )
|
||||||
if not fs.isDir( sPath ) then
|
if not fs.isDir( sPath ) then
|
||||||
@ -896,7 +896,7 @@ end
|
|||||||
if pocket and fs.isDir( "rom/apis/pocket" ) then
|
if pocket and fs.isDir( "rom/apis/pocket" ) then
|
||||||
-- Load pocket APIs
|
-- Load pocket APIs
|
||||||
local tApis = fs.list( "rom/apis/pocket" )
|
local tApis = fs.list( "rom/apis/pocket" )
|
||||||
for n,sFile in ipairs( tApis ) do
|
for _,sFile in ipairs( tApis ) do
|
||||||
if string.sub( sFile, 1, 1 ) ~= "." then
|
if string.sub( sFile, 1, 1 ) ~= "." then
|
||||||
local sPath = fs.combine( "rom/apis/pocket", sFile )
|
local sPath = fs.combine( "rom/apis/pocket", sFile )
|
||||||
if not fs.isDir( sPath ) then
|
if not fs.isDir( sPath ) then
|
||||||
@ -946,7 +946,7 @@ end
|
|||||||
|
|
||||||
-- Set default settings
|
-- Set default settings
|
||||||
settings.set( "shell.allow_startup", true )
|
settings.set( "shell.allow_startup", true )
|
||||||
settings.set( "shell.allow_disk_startup", (commands == nil) )
|
settings.set( "shell.allow_disk_startup", commands == nil )
|
||||||
settings.set( "shell.autocomplete", true )
|
settings.set( "shell.autocomplete", true )
|
||||||
settings.set( "edit.autocomplete", true )
|
settings.set( "edit.autocomplete", true )
|
||||||
settings.set( "edit.default_extension", "lua" )
|
settings.set( "edit.default_extension", "lua" )
|
||||||
|
@ -33,9 +33,9 @@ local tNonNBTJSONCommands = {
|
|||||||
[ "title" ] = true
|
[ "title" ] = true
|
||||||
}
|
}
|
||||||
local tCommands = native.list()
|
local tCommands = native.list()
|
||||||
for n,sCommandName in ipairs(tCommands) do
|
for _,sCommandName in ipairs(tCommands) do
|
||||||
if env[ sCommandName ] == nil then
|
if env[ sCommandName ] == nil then
|
||||||
local bJSONIsNBT = (tNonNBTJSONCommands[ sCommandName ] == nil)
|
local bJSONIsNBT = tNonNBTJSONCommands[ sCommandName ] == nil
|
||||||
env[ sCommandName ] = function( ... )
|
env[ sCommandName ] = function( ... )
|
||||||
local sCommand = collapseArgs( bJSONIsNBT, sCommandName, ... )
|
local sCommand = collapseArgs( bJSONIsNBT, sCommandName, ... )
|
||||||
return native.exec( sCommand )
|
return native.exec( sCommand )
|
||||||
|
@ -62,7 +62,7 @@ end
|
|||||||
|
|
||||||
function stopAudio( name )
|
function stopAudio( name )
|
||||||
if not name then
|
if not name then
|
||||||
for n,sName in ipairs( peripheral.getNames() ) do
|
for _,sName in ipairs( peripheral.getNames() ) do
|
||||||
stopAudio( sName )
|
stopAudio( sName )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -13,7 +13,7 @@ local function trilaterate( A, B, C )
|
|||||||
local d = a2b:length()
|
local d = a2b:length()
|
||||||
local ex = a2b:normalize( )
|
local ex = a2b:normalize( )
|
||||||
local i = ex:dot( a2c )
|
local i = ex:dot( a2c )
|
||||||
local ey = (a2c - (ex * i)):normalize()
|
local ey = (a2c - ex * i):normalize()
|
||||||
local j = ey:dot( a2c )
|
local j = ey:dot( a2c )
|
||||||
local ez = ex:cross( ey )
|
local ez = ex:cross( ey )
|
||||||
|
|
||||||
@ -24,13 +24,13 @@ local function trilaterate( A, B, C )
|
|||||||
local x = (r1*r1 - r2*r2 + d*d) / (2*d)
|
local x = (r1*r1 - r2*r2 + d*d) / (2*d)
|
||||||
local y = (r1*r1 - r3*r3 - x*x + (x-i)*(x-i) + j*j) / (2*j)
|
local y = (r1*r1 - r3*r3 - x*x + (x-i)*(x-i) + j*j) / (2*j)
|
||||||
|
|
||||||
local result = A.vPosition + (ex * x) + (ey * y)
|
local result = A.vPosition + ex * x + ey * y
|
||||||
|
|
||||||
local zSquared = r1*r1 - x*x - y*y
|
local zSquared = r1*r1 - x*x - y*y
|
||||||
if zSquared > 0 then
|
if zSquared > 0 then
|
||||||
local z = math.sqrt( zSquared )
|
local z = math.sqrt( zSquared )
|
||||||
local result1 = result + (ez * z)
|
local result1 = result + ez * z
|
||||||
local result2 = result - (ez * z)
|
local result2 = result - ez * z
|
||||||
|
|
||||||
local rounded1, rounded2 = result1:round( 0.01 ), result2:round( 0.01 )
|
local rounded1, rounded2 = result1:round( 0.01 ), result2:round( 0.01 )
|
||||||
if rounded1.x ~= rounded2.x or rounded1.y ~= rounded2.y or rounded1.z ~= rounded2.z then
|
if rounded1.x ~= rounded2.x or rounded1.y ~= rounded2.y or rounded1.z ~= rounded2.z then
|
||||||
@ -66,7 +66,7 @@ function locate( _nTimeout, _bDebug )
|
|||||||
|
|
||||||
-- Find a modem
|
-- Find a modem
|
||||||
local sModemSide = nil
|
local sModemSide = nil
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for _,sSide in ipairs( rs.getSides() ) do
|
||||||
if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then
|
if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then
|
||||||
sModemSide = sSide
|
sModemSide = sSide
|
||||||
break
|
break
|
||||||
|
@ -37,7 +37,7 @@ function topics()
|
|||||||
for sPath in string.gmatch(sPath, "[^:]+") do
|
for sPath in string.gmatch(sPath, "[^:]+") do
|
||||||
if fs.isDir( sPath ) then
|
if fs.isDir( sPath ) then
|
||||||
local tList = fs.list( sPath )
|
local tList = fs.list( sPath )
|
||||||
for n,sFile in pairs( tList ) do
|
for _,sFile in pairs( tList ) do
|
||||||
if string.sub( sFile, 1, 1 ) ~= "." then
|
if string.sub( sFile, 1, 1 ) ~= "." then
|
||||||
if not fs.isDir( fs.combine( sPath, sFile ) ) then
|
if not fs.isDir( fs.combine( sPath, sFile ) ) then
|
||||||
if #sFile > 4 and sFile:sub(-4) == ".txt" then
|
if #sFile > 4 and sFile:sub(-4) == ".txt" then
|
||||||
@ -52,7 +52,7 @@ function topics()
|
|||||||
|
|
||||||
-- Sort and return
|
-- Sort and return
|
||||||
local tItemList = {}
|
local tItemList = {}
|
||||||
for sItem, b in pairs( tItems ) do
|
for sItem in pairs( tItems ) do
|
||||||
table.insert( tItemList, sItem )
|
table.insert( tItemList, sItem )
|
||||||
end
|
end
|
||||||
table.sort( tItemList )
|
table.sort( tItemList )
|
||||||
|
@ -147,8 +147,8 @@ function drawBox( startX, startY, endX, endY, nColour )
|
|||||||
drawPixelInternal( x, maxY )
|
drawPixelInternal( x, maxY )
|
||||||
end
|
end
|
||||||
|
|
||||||
if (maxY - minY) >= 2 then
|
if maxY - minY >= 2 then
|
||||||
for y=(minY+1),(maxY-1) do
|
for y=minY+1,maxY-1 do
|
||||||
drawPixelInternal( minX, y )
|
drawPixelInternal( minX, y )
|
||||||
drawPixelInternal( maxX, y )
|
drawPixelInternal( maxX, y )
|
||||||
end
|
end
|
||||||
|
@ -4,12 +4,12 @@ local native = peripheral
|
|||||||
|
|
||||||
function getNames()
|
function getNames()
|
||||||
local tResults = {}
|
local tResults = {}
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for _,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.isPresent( sSide ) then
|
if native.isPresent( sSide ) then
|
||||||
table.insert( tResults, sSide )
|
table.insert( tResults, sSide )
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
local tRemote = native.call( sSide, "getNamesRemote" )
|
local tRemote = native.call( sSide, "getNamesRemote" )
|
||||||
for n,sName in ipairs( tRemote ) do
|
for _,sName in ipairs( tRemote ) do
|
||||||
table.insert( tResults, sName )
|
table.insert( tResults, sName )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -23,7 +23,7 @@ function isPresent( _sSide )
|
|||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for _,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return true
|
return true
|
||||||
@ -38,7 +38,7 @@ function getType( _sSide )
|
|||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return native.getType( _sSide )
|
return native.getType( _sSide )
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for _,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return native.call( sSide, "getTypeRemote", _sSide )
|
return native.call( sSide, "getTypeRemote", _sSide )
|
||||||
@ -53,7 +53,7 @@ function getMethods( _sSide )
|
|||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return native.getMethods( _sSide )
|
return native.getMethods( _sSide )
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for _,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return native.call( sSide, "getMethodsRemote", _sSide )
|
return native.call( sSide, "getMethodsRemote", _sSide )
|
||||||
@ -69,7 +69,7 @@ function call( _sSide, _sMethod, ... )
|
|||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return native.call( _sSide, _sMethod, ... )
|
return native.call( _sSide, _sMethod, ... )
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for _,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return native.call( sSide, "callRemote", _sSide, _sMethod, ... )
|
return native.call( sSide, "callRemote", _sSide, _sMethod, ... )
|
||||||
@ -84,7 +84,7 @@ function wrap( _sSide )
|
|||||||
if peripheral.isPresent( _sSide ) then
|
if peripheral.isPresent( _sSide ) then
|
||||||
local tMethods = peripheral.getMethods( _sSide )
|
local tMethods = peripheral.getMethods( _sSide )
|
||||||
local tResult = {}
|
local tResult = {}
|
||||||
for n,sMethod in ipairs( tMethods ) do
|
for _,sMethod in ipairs( tMethods ) do
|
||||||
tResult[sMethod] = function( ... )
|
tResult[sMethod] = function( ... )
|
||||||
return peripheral.call( _sSide, sMethod, ... )
|
return peripheral.call( _sSide, sMethod, ... )
|
||||||
end
|
end
|
||||||
@ -98,7 +98,7 @@ function find( sType, fnFilter )
|
|||||||
expect(1, sType, "string")
|
expect(1, sType, "string")
|
||||||
expect(2, fnFilter, "function", "nil")
|
expect(2, fnFilter, "function", "nil")
|
||||||
local tResults = {}
|
local tResults = {}
|
||||||
for n,sName in ipairs( peripheral.getNames() ) do
|
for _,sName in ipairs( peripheral.getNames() ) do
|
||||||
if peripheral.getType( sName ) == sType then
|
if peripheral.getType( sName ) == sType then
|
||||||
local wrapped = peripheral.wrap( sName )
|
local wrapped = peripheral.wrap( sName )
|
||||||
if fnFilter == nil or fnFilter( sName, wrapped ) then
|
if fnFilter == nil or fnFilter( sName, wrapped ) then
|
||||||
|
@ -27,7 +27,7 @@ function close( sModem )
|
|||||||
peripheral.call( sModem, "close", CHANNEL_BROADCAST )
|
peripheral.call( sModem, "close", CHANNEL_BROADCAST )
|
||||||
else
|
else
|
||||||
-- Close all modems
|
-- Close all modems
|
||||||
for n,sModem in ipairs( peripheral.getNames() ) do
|
for _,sModem in ipairs( peripheral.getNames() ) do
|
||||||
if isOpen( sModem ) then
|
if isOpen( sModem ) then
|
||||||
close( sModem )
|
close( sModem )
|
||||||
end
|
end
|
||||||
@ -44,7 +44,7 @@ function isOpen( sModem )
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Check if any modem is open
|
-- Check if any modem is open
|
||||||
for n,sModem in ipairs( peripheral.getNames() ) do
|
for _,sModem in ipairs( peripheral.getNames() ) do
|
||||||
if isOpen( sModem ) then
|
if isOpen( sModem ) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -79,10 +79,10 @@ function send( nRecipient, message, sProtocol )
|
|||||||
sent = true
|
sent = true
|
||||||
else
|
else
|
||||||
-- Send on all open modems, to the target and to repeaters
|
-- Send on all open modems, to the target and to repeaters
|
||||||
for n,sModem in ipairs( peripheral.getNames() ) do
|
for _,sModem in ipairs( peripheral.getNames() ) do
|
||||||
if isOpen( sModem ) then
|
if isOpen( sModem ) then
|
||||||
peripheral.call( sModem, "transmit", nRecipient, nReplyChannel, tMessage );
|
peripheral.call( sModem, "transmit", nRecipient, nReplyChannel, tMessage )
|
||||||
peripheral.call( sModem, "transmit", CHANNEL_REPEAT, nReplyChannel, tMessage );
|
peripheral.call( sModem, "transmit", CHANNEL_REPEAT, nReplyChannel, tMessage )
|
||||||
sent = true
|
sent = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -47,7 +47,7 @@ end
|
|||||||
|
|
||||||
function getNames()
|
function getNames()
|
||||||
local result = {}
|
local result = {}
|
||||||
for k,v in pairs( tSettings ) do
|
for k in pairs( tSettings ) do
|
||||||
result[ #result + 1 ] = k
|
result[ #result + 1 ] = k
|
||||||
end
|
end
|
||||||
table.sort(result)
|
table.sort(result)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
local expect = dofile("rom/modules/main/cc/expect.lua").expect
|
local expect = dofile("rom/modules/main/cc/expect.lua").expect
|
||||||
|
|
||||||
local native = (term.native and term.native()) or term
|
local native = term.native and term.native() or term
|
||||||
local redirectTarget = native
|
local redirectTarget = native
|
||||||
|
|
||||||
local function wrap( _sFunction )
|
local function wrap( _sFunction )
|
||||||
|
@ -16,7 +16,7 @@ function slowWrite( sText, nRate )
|
|||||||
term.setCursorPos( x, y )
|
term.setCursorPos( x, y )
|
||||||
sleep( nSleep )
|
sleep( nSleep )
|
||||||
local nLines = write( string.sub( sText, 1, n ) )
|
local nLines = write( string.sub( sText, 1, n ) )
|
||||||
local newX, newY = term.getCursorPos()
|
local _, newY = term.getCursorPos()
|
||||||
y = newY - nLines
|
y = newY - nLines
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -54,11 +54,11 @@ local function makePagedScroll( _term, _nFreeLines )
|
|||||||
local nativeScroll = _term.scroll
|
local nativeScroll = _term.scroll
|
||||||
local nFreeLines = _nFreeLines or 0
|
local nFreeLines = _nFreeLines or 0
|
||||||
return function( _n )
|
return function( _n )
|
||||||
for n=1,_n do
|
for _=1,_n do
|
||||||
nativeScroll( 1 )
|
nativeScroll( 1 )
|
||||||
|
|
||||||
if nFreeLines <= 0 then
|
if nFreeLines <= 0 then
|
||||||
local w,h = _term.getSize()
|
local _,h = _term.getSize()
|
||||||
_term.setCursorPos( 1, h )
|
_term.setCursorPos( 1, h )
|
||||||
_term.write( "Press any key to continue" )
|
_term.write( "Press any key to continue" )
|
||||||
os.pullEvent( "key" )
|
os.pullEvent( "key" )
|
||||||
@ -123,7 +123,7 @@ local function tabulateCommon( bPaged, ... )
|
|||||||
local nCols = math.floor( w / nMaxLen )
|
local nCols = math.floor( w / nMaxLen )
|
||||||
local nLines = 0
|
local nLines = 0
|
||||||
local function newLine()
|
local function newLine()
|
||||||
if bPaged and nLines >= (h-3) then
|
if bPaged and nLines >= h-3 then
|
||||||
pagedPrint()
|
pagedPrint()
|
||||||
else
|
else
|
||||||
print()
|
print()
|
||||||
@ -133,14 +133,14 @@ local function tabulateCommon( bPaged, ... )
|
|||||||
|
|
||||||
local function drawCols( _t )
|
local function drawCols( _t )
|
||||||
local nCol = 1
|
local nCol = 1
|
||||||
for n, s in ipairs( _t ) do
|
for _, s in ipairs( _t ) do
|
||||||
if nCol > nCols then
|
if nCol > nCols then
|
||||||
nCol = 1
|
nCol = 1
|
||||||
newLine()
|
newLine()
|
||||||
end
|
end
|
||||||
|
|
||||||
local cx, cy = term.getCursorPos()
|
local cx, cy = term.getCursorPos()
|
||||||
cx = 1 + ((nCol - 1) * nMaxLen)
|
cx = 1 + (nCol - 1) * nMaxLen
|
||||||
term.setCursorPos( cx, cy )
|
term.setCursorPos( cx, cy )
|
||||||
term.write( s )
|
term.write( s )
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ local function tabulateCommon( bPaged, ... )
|
|||||||
end
|
end
|
||||||
print()
|
print()
|
||||||
end
|
end
|
||||||
for n, t in ipairs( tAll ) do
|
for _, t in ipairs( tAll ) do
|
||||||
if type(t) == "table" then
|
if type(t) == "table" then
|
||||||
if #t > 0 then
|
if #t > 0 then
|
||||||
drawCols( t )
|
drawCols( t )
|
||||||
@ -280,7 +280,7 @@ local function serializeJSONImpl( t, tTracking, bNBTStyle )
|
|||||||
nObjectSize = nObjectSize + 1
|
nObjectSize = nObjectSize + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for n,v in ipairs(t) do
|
for _,v in ipairs(t) do
|
||||||
local sEntry = serializeJSONImpl( v, tTracking, bNBTStyle )
|
local sEntry = serializeJSONImpl( v, tTracking, bNBTStyle )
|
||||||
if nArraySize == 0 then
|
if nArraySize == 0 then
|
||||||
sArrayResult = sArrayResult .. sEntry
|
sArrayResult = sArrayResult .. sEntry
|
||||||
|
@ -54,9 +54,9 @@ local vector = {
|
|||||||
round = function( self, nTolerance )
|
round = function( self, nTolerance )
|
||||||
nTolerance = nTolerance or 1.0
|
nTolerance = nTolerance or 1.0
|
||||||
return vector.new(
|
return vector.new(
|
||||||
math.floor( (self.x + (nTolerance * 0.5)) / nTolerance ) * nTolerance,
|
math.floor( (self.x + nTolerance * 0.5) / nTolerance ) * nTolerance,
|
||||||
math.floor( (self.y + (nTolerance * 0.5)) / nTolerance ) * nTolerance,
|
math.floor( (self.y + nTolerance * 0.5) / nTolerance ) * nTolerance,
|
||||||
math.floor( (self.z + (nTolerance * 0.5)) / nTolerance ) * nTolerance
|
math.floor( (self.z + nTolerance * 0.5) / nTolerance ) * nTolerance
|
||||||
)
|
)
|
||||||
end,
|
end,
|
||||||
tostring = function( self )
|
tostring = function( self )
|
||||||
|
@ -49,7 +49,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
createEmptyLines( nWidth )
|
createEmptyLines( nWidth )
|
||||||
|
|
||||||
-- Setup
|
-- Setup
|
||||||
local bVisible = (bStartVisible ~= false)
|
local bVisible = bStartVisible ~= false
|
||||||
local nCursorX = 1
|
local nCursorX = 1
|
||||||
local nCursorY = 1
|
local nCursorY = 1
|
||||||
local bCursorBlink = false
|
local bCursorBlink = false
|
||||||
|
@ -172,7 +172,6 @@ local function resizeWindows()
|
|||||||
end
|
end
|
||||||
for n=1,#tProcesses do
|
for n=1,#tProcesses do
|
||||||
local tProcess = tProcesses[n]
|
local tProcess = tProcesses[n]
|
||||||
local window = tProcess.window
|
|
||||||
local x,y = tProcess.window.getCursorPos()
|
local x,y = tProcess.window.getCursorPos()
|
||||||
if y > windowHeight then
|
if y > windowHeight then
|
||||||
tProcess.window.scroll( y - windowHeight )
|
tProcess.window.scroll( y - windowHeight )
|
||||||
@ -232,7 +231,7 @@ function multishell.launch( tProgramEnv, sProgramPath, ... )
|
|||||||
expect(1, tProgramEnv, "table")
|
expect(1, tProgramEnv, "table")
|
||||||
expect(2, sProgramPath, "string")
|
expect(2, sProgramPath, "string")
|
||||||
local previousTerm = term.current()
|
local previousTerm = term.current()
|
||||||
setMenuVisible( (#tProcesses + 1) >= 2 )
|
setMenuVisible( #tProcesses + 1 >= 2 )
|
||||||
local nResult = launchProcess( false, tProgramEnv, sProgramPath, ... )
|
local nResult = launchProcess( false, tProgramEnv, sProgramPath, ... )
|
||||||
redrawMenu()
|
redrawMenu()
|
||||||
term.redirect( previousTerm )
|
term.redirect( previousTerm )
|
||||||
@ -299,7 +298,7 @@ while #tProcesses > 0 do
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Passthrough to current process
|
-- Passthrough to current process
|
||||||
resumeProcess( nCurrentProcess, sEvent, button, x, (bShowMenu and y-1) or y )
|
resumeProcess( nCurrentProcess, sEvent, button, x, bShowMenu and y-1 or y )
|
||||||
if cullProcess( nCurrentProcess ) then
|
if cullProcess( nCurrentProcess ) then
|
||||||
setMenuVisible( #tProcesses >= 2 )
|
setMenuVisible( #tProcesses >= 2 )
|
||||||
redrawMenu()
|
redrawMenu()
|
||||||
@ -319,7 +318,7 @@ while #tProcesses > 0 do
|
|||||||
end
|
end
|
||||||
elseif not (bShowMenu and y == 1) then
|
elseif not (bShowMenu and y == 1) then
|
||||||
-- Passthrough to current process
|
-- Passthrough to current process
|
||||||
resumeProcess( nCurrentProcess, sEvent, p1, x, (bShowMenu and y-1) or y )
|
resumeProcess( nCurrentProcess, sEvent, p1, x, bShowMenu and y-1 or y )
|
||||||
if cullProcess( nCurrentProcess ) then
|
if cullProcess( nCurrentProcess ) then
|
||||||
setMenuVisible( #tProcesses >= 2 )
|
setMenuVisible( #tProcesses >= 2 )
|
||||||
redrawMenu()
|
redrawMenu()
|
||||||
|
@ -9,7 +9,7 @@ local sSource = shell.resolve( tArgs[1] )
|
|||||||
local sDest = shell.resolve( tArgs[2] )
|
local sDest = shell.resolve( tArgs[2] )
|
||||||
local tFiles = fs.find( sSource )
|
local tFiles = fs.find( sSource )
|
||||||
if #tFiles > 0 then
|
if #tFiles > 0 then
|
||||||
for n,sFile in ipairs( tFiles ) do
|
for _,sFile in ipairs( tFiles ) do
|
||||||
if fs.isDir( sDest ) then
|
if fs.isDir( sDest ) then
|
||||||
fs.copy( sFile, fs.combine( sDest, fs.getName(sFile) ) )
|
fs.copy( sFile, fs.combine( sDest, fs.getName(sFile) ) )
|
||||||
elseif #tFiles == 1 then
|
elseif #tFiles == 1 then
|
||||||
|
@ -8,7 +8,7 @@ end
|
|||||||
for i = 1, args.n do
|
for i = 1, args.n do
|
||||||
local files = fs.find(shell.resolve(args[i]))
|
local files = fs.find(shell.resolve(args[i]))
|
||||||
if #files > 0 then
|
if #files > 0 then
|
||||||
for n, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
local ok, err = pcall(fs.delete, file)
|
local ok, err = pcall(fs.delete, file)
|
||||||
if not ok then
|
if not ok then
|
||||||
printError((err:gsub("^pcall: ", "")))
|
printError((err:gsub("^pcall: ", "")))
|
||||||
|
@ -10,9 +10,9 @@ if fs.exists( sPath ) then
|
|||||||
write( fs.getDrive( sPath ) .. " (" )
|
write( fs.getDrive( sPath ) .. " (" )
|
||||||
local nSpace = fs.getFreeSpace( sPath )
|
local nSpace = fs.getFreeSpace( sPath )
|
||||||
if nSpace >= 1000 * 1000 then
|
if nSpace >= 1000 * 1000 then
|
||||||
print( (math.floor( nSpace / (100 * 1000) ) / 10) .. "MB remaining)" )
|
print( math.floor( nSpace / (100 * 1000) ) / 10 .. "MB remaining)" )
|
||||||
elseif nSpace >= 1000 then
|
elseif nSpace >= 1000 then
|
||||||
print( (math.floor( nSpace / 100 ) / 10) .. "KB remaining)" )
|
print( math.floor( nSpace / 100 ) / 10 .. "KB remaining)" )
|
||||||
else
|
else
|
||||||
print( nSpace .. "B remaining)" )
|
print( nSpace .. "B remaining)" )
|
||||||
end
|
end
|
||||||
|
@ -95,7 +95,7 @@ local function save( _sPath )
|
|||||||
local function innerSave()
|
local function innerSave()
|
||||||
file, fileerr = fs.open( _sPath, "w" )
|
file, fileerr = fs.open( _sPath, "w" )
|
||||||
if file then
|
if file then
|
||||||
for n, sLine in ipairs( tLines ) do
|
for _, sLine in ipairs( tLines ) do
|
||||||
file.write( sLine .. "\n" )
|
file.write( sLine .. "\n" )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -287,7 +287,7 @@ local tMenuFuncs = {
|
|||||||
if bReadOnly then
|
if bReadOnly then
|
||||||
sStatus = "Access denied"
|
sStatus = "Access denied"
|
||||||
else
|
else
|
||||||
local ok, err, fileerr = save( sPath )
|
local ok, _, fileerr = save( sPath )
|
||||||
if ok then
|
if ok then
|
||||||
sStatus="Saved to "..sPath
|
sStatus="Saved to "..sPath
|
||||||
else
|
else
|
||||||
@ -357,7 +357,7 @@ local tMenuFuncs = {
|
|||||||
term.redirect( printerTerminal )
|
term.redirect( printerTerminal )
|
||||||
local ok, error = pcall( function()
|
local ok, error = pcall( function()
|
||||||
term.scroll()
|
term.scroll()
|
||||||
for n, sLine in ipairs( tLines ) do
|
for _, sLine in ipairs( tLines ) do
|
||||||
print( sLine )
|
print( sLine )
|
||||||
end
|
end
|
||||||
end )
|
end )
|
||||||
@ -385,7 +385,7 @@ local tMenuFuncs = {
|
|||||||
end,
|
end,
|
||||||
Run = function()
|
Run = function()
|
||||||
local sTempPath = "/.temp"
|
local sTempPath = "/.temp"
|
||||||
local ok, err = save( sTempPath )
|
local ok = save( sTempPath )
|
||||||
if ok then
|
if ok then
|
||||||
local nTask = shell.openTab( sTempPath )
|
local nTask = shell.openTab( sTempPath )
|
||||||
if nTask then
|
if nTask then
|
||||||
@ -411,7 +411,7 @@ local function doMenuItem( _n )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function setCursor( newX, newY )
|
local function setCursor( newX, newY )
|
||||||
local oldX, oldY = x, y
|
local _, oldY = x, y
|
||||||
x, y = newX, newY
|
x, y = newX, newY
|
||||||
local screenX = x - scrollX
|
local screenX = x - scrollX
|
||||||
local screenY = y - scrollY
|
local screenY = y - scrollY
|
||||||
@ -476,7 +476,6 @@ end
|
|||||||
while bRunning do
|
while bRunning do
|
||||||
local sEvent, param, param2, param3 = os.pullEvent()
|
local sEvent, param, param2, param3 = os.pullEvent()
|
||||||
if sEvent == "key" then
|
if sEvent == "key" then
|
||||||
local oldX, oldY = x, y
|
|
||||||
if param == keys.up then
|
if param == keys.up then
|
||||||
-- Up
|
-- Up
|
||||||
if not bMenu then
|
if not bMenu then
|
||||||
|
@ -186,8 +186,8 @@ local function drawInterface()
|
|||||||
term.write("\127\127")
|
term.write("\127\127")
|
||||||
|
|
||||||
-- Left and Right Selected Colours
|
-- Left and Right Selected Colours
|
||||||
for i=18,18 do
|
do
|
||||||
term.setCursorPos(w-1, i)
|
term.setCursorPos(w-1, 18)
|
||||||
if leftColour ~= nil then
|
if leftColour ~= nil then
|
||||||
term.setBackgroundColour( leftColour )
|
term.setBackgroundColour( leftColour )
|
||||||
term.write(" ")
|
term.write(" ")
|
||||||
@ -269,7 +269,7 @@ local function accessMenu()
|
|||||||
for k,v in pairs(mChoices) do
|
for k,v in pairs(mChoices) do
|
||||||
if selection==k then
|
if selection==k then
|
||||||
term.setTextColour(colours.yellow)
|
term.setTextColour(colours.yellow)
|
||||||
local ox,_ = term.getCursorPos()
|
local ox = term.getCursorPos()
|
||||||
term.write("["..string.rep(" ",#v).."]")
|
term.write("["..string.rep(" ",#v).."]")
|
||||||
term.setCursorPos(ox+1,h)
|
term.setCursorPos(ox+1,h)
|
||||||
term.setTextColour(colours.white)
|
term.setTextColour(colours.white)
|
||||||
|
@ -66,8 +66,8 @@ local function printCentred( yc, stg )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function centerOrgin()
|
local function centerOrgin()
|
||||||
XOrgin = math.floor((TermW/2)-(SizeW/2))
|
XOrgin = math.floor(TermW/2-SizeW/2)
|
||||||
YOrgin = math.floor((TermH/2)-(SizeH/2))
|
YOrgin = math.floor(TermH/2-SizeH/2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function reMap()
|
local function reMap()
|
||||||
@ -177,7 +177,6 @@ local function loadLevel(nNum)
|
|||||||
local sLevelD = sDir .. "/levels/" .. tostring(nNum)..".dat"
|
local sLevelD = sDir .. "/levels/" .. tostring(nNum)..".dat"
|
||||||
if not ( fs.exists(sLevelD) or fs.isDir(sLevelD) ) then return error("Level Not Exists : "..sLevelD) end
|
if not ( fs.exists(sLevelD) or fs.isDir(sLevelD) ) then return error("Level Not Exists : "..sLevelD) end
|
||||||
fLevel = fs.open(sLevelD,"r")
|
fLevel = fs.open(sLevelD,"r")
|
||||||
local Line = 0
|
|
||||||
local wl = true
|
local wl = true
|
||||||
Blocks = tonumber(string.sub(fLevel.readLine(),1,1))
|
Blocks = tonumber(string.sub(fLevel.readLine(),1,1))
|
||||||
local xSize = string.len(fLevel.readLine())+2
|
local xSize = string.len(fLevel.readLine())+2
|
||||||
@ -557,7 +556,7 @@ function InterFace.render()
|
|||||||
elseif p3 == TermH and p2 >= TermW-4 and p2 <= TermW-3 then
|
elseif p3 == TermH and p2 >= TermW-4 and p2 <= TermW-3 then
|
||||||
bPaused = not bPaused
|
bPaused = not bPaused
|
||||||
fSpeedS = false
|
fSpeedS = false
|
||||||
Speed = (bPaused and 0) or nSpeed
|
Speed = bPaused and 0 or nSpeed
|
||||||
if Speed > 0 then
|
if Speed > 0 then
|
||||||
Tick = os.startTimer(Speed)
|
Tick = os.startTimer(Speed)
|
||||||
else
|
else
|
||||||
@ -567,7 +566,7 @@ function InterFace.render()
|
|||||||
elseif p3 == TermH and p2 >= TermW-1 then
|
elseif p3 == TermH and p2 >= TermW-1 then
|
||||||
bPaused = false
|
bPaused = false
|
||||||
fSpeedS = not fSpeedS
|
fSpeedS = not fSpeedS
|
||||||
Speed = (fSpeedS and fSpeed) or nSpeed
|
Speed = fSpeedS and fSpeed or nSpeed
|
||||||
Tick = os.startTimer(Speed)
|
Tick = os.startTimer(Speed)
|
||||||
InterFace.drawBar()
|
InterFace.drawBar()
|
||||||
elseif p3-1 < YOrgin+SizeH+1 and p3-1 > YOrgin and
|
elseif p3-1 < YOrgin+SizeH+1 and p3-1 > YOrgin and
|
||||||
@ -596,7 +595,6 @@ local function startG(LevelN)
|
|||||||
drawStars()
|
drawStars()
|
||||||
loadLevel(LevelN)
|
loadLevel(LevelN)
|
||||||
centerOrgin()
|
centerOrgin()
|
||||||
local create = true
|
|
||||||
drawMap()
|
drawMap()
|
||||||
InterFace.drawBar()
|
InterFace.drawBar()
|
||||||
gRender("start")
|
gRender("start")
|
||||||
|
@ -342,7 +342,7 @@ local function getTimeOfDay()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function isSunny()
|
local function isSunny()
|
||||||
return (getTimeOfDay() < 10)
|
return getTimeOfDay() < 10
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getRoom( x, y, z, dontCreate )
|
local function getRoom( x, y, z, dontCreate )
|
||||||
@ -365,7 +365,7 @@ local function getRoom( x, y, z, dontCreate )
|
|||||||
|
|
||||||
-- Add animals
|
-- Add animals
|
||||||
if math.random(1,3) == 1 then
|
if math.random(1,3) == 1 then
|
||||||
for n = 1,math.random(1,2) do
|
for _ = 1,math.random(1,2) do
|
||||||
local sAnimal = tAnimals[ math.random( 1, #tAnimals ) ]
|
local sAnimal = tAnimals[ math.random( 1, #tAnimals ) ]
|
||||||
room.items[ sAnimal ] = items[ sAnimal ]
|
room.items[ sAnimal ] = items[ sAnimal ]
|
||||||
end
|
end
|
||||||
@ -478,7 +478,7 @@ local function findItem( _tList, _sQuery )
|
|||||||
return sItem
|
return sItem
|
||||||
end
|
end
|
||||||
if tItem.aliases ~= nil then
|
if tItem.aliases ~= nil then
|
||||||
for n, sAlias in pairs( tItem.aliases ) do
|
for _, sAlias in pairs( tItem.aliases ) do
|
||||||
if sAlias == _sQuery then
|
if sAlias == _sQuery then
|
||||||
return sItem
|
return sItem
|
||||||
end
|
end
|
||||||
@ -613,7 +613,7 @@ local function doCommand( text )
|
|||||||
end
|
end
|
||||||
|
|
||||||
for sCommand, t in pairs( tMatches ) do
|
for sCommand, t in pairs( tMatches ) do
|
||||||
for n, sMatch in pairs( t ) do
|
for _, sMatch in pairs( t ) do
|
||||||
local tCaptures = { string.match( text, "^" .. sMatch .. "$" ) }
|
local tCaptures = { string.match( text, "^" .. sMatch .. "$" ) }
|
||||||
if #tCaptures ~= 0 then
|
if #tCaptures ~= 0 then
|
||||||
local fnCommand = commands[ sCommand ]
|
local fnCommand = commands[ sCommand ]
|
||||||
@ -679,7 +679,7 @@ function commands.look( _sTarget )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if tItem then
|
if tItem then
|
||||||
print( tItem.desc or ("You see nothing special about "..sItem..".") )
|
print( tItem.desc or "You see nothing special about "..sItem.."." )
|
||||||
else
|
else
|
||||||
print( "You don't see any ".._sTarget.." here." )
|
print( "You don't see any ".._sTarget.." here." )
|
||||||
end
|
end
|
||||||
@ -752,7 +752,7 @@ function commands.dig( _sDir, _sTool )
|
|||||||
tTool = inventory[ sTool ]
|
tTool = inventory[ sTool ]
|
||||||
end
|
end
|
||||||
|
|
||||||
local bActuallyDigging = (room.exits[ _sDir ] ~= true)
|
local bActuallyDigging = room.exits[ _sDir ] ~= true
|
||||||
if bActuallyDigging then
|
if bActuallyDigging then
|
||||||
if sTool == nil or tTool.toolType ~= "pick" then
|
if sTool == nil or tTool.toolType ~= "pick" then
|
||||||
print( "You need to use a pickaxe to dig through stone." )
|
print( "You need to use a pickaxe to dig through stone." )
|
||||||
@ -1021,7 +1021,7 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
print( "The "..tItem.aliases[1].." dies." )
|
print( "The "..tItem.aliases[1].." dies." )
|
||||||
|
|
||||||
if tItem.drops then
|
if tItem.drops then
|
||||||
for n, sDrop in pairs( tItem.drops ) do
|
for _, sDrop in pairs( tItem.drops ) do
|
||||||
if not room.items[sDrop] then
|
if not room.items[sDrop] then
|
||||||
print( "The "..tItem.aliases[1].." dropped "..sDrop.."." )
|
print( "The "..tItem.aliases[1].." dropped "..sDrop.."." )
|
||||||
room.items[sDrop] = items[sDrop]
|
room.items[sDrop] = items[sDrop]
|
||||||
@ -1037,7 +1037,7 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if tItem.hitDrops then
|
if tItem.hitDrops then
|
||||||
for n, sDrop in pairs( tItem.hitDrops ) do
|
for _, sDrop in pairs( tItem.hitDrops ) do
|
||||||
if not room.items[sDrop] then
|
if not room.items[sDrop] then
|
||||||
print( "The "..tItem.aliases[1].." dropped "..sDrop.."." )
|
print( "The "..tItem.aliases[1].." dropped "..sDrop.."." )
|
||||||
room.items[sDrop] = items[sDrop]
|
room.items[sDrop] = items[sDrop]
|
||||||
@ -1071,18 +1071,17 @@ function commands.craft( _sItem )
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local room = getRoom( x,y,z )
|
|
||||||
local sItem = findItem( items, _sItem )
|
local sItem = findItem( items, _sItem )
|
||||||
local tRecipe = (sItem and tRecipes[ sItem ]) or nil
|
local tRecipe = sItem and tRecipes[ sItem ] or nil
|
||||||
if tRecipe then
|
if tRecipe then
|
||||||
for n,sReq in ipairs( tRecipe ) do
|
for _,sReq in ipairs( tRecipe ) do
|
||||||
if inventory[sReq] == nil then
|
if inventory[sReq] == nil then
|
||||||
print( "You don't have the items you need to craft "..sItem.."." )
|
print( "You don't have the items you need to craft "..sItem.."." )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for n,sReq in ipairs( tRecipe ) do
|
for _,sReq in ipairs( tRecipe ) do
|
||||||
inventory[sReq] = nil
|
inventory[sReq] = nil
|
||||||
end
|
end
|
||||||
inventory[ sItem ] = items[ sItem ]
|
inventory[ sItem ] = items[ sItem ]
|
||||||
@ -1223,7 +1222,7 @@ local function simulate()
|
|||||||
|
|
||||||
-- Spawn monsters
|
-- Spawn monsters
|
||||||
if room.nMonsters < 2 and
|
if room.nMonsters < 2 and
|
||||||
((h == 0 and not isSunny() and not room.items["a torch"]) or room.dark) and
|
(h == 0 and not isSunny() and not room.items["a torch"] or room.dark) and
|
||||||
math.random(1,6) == 1 then
|
math.random(1,6) == 1 then
|
||||||
|
|
||||||
local sMonster = tMonsters[ math.random(1,#tMonsters) ]
|
local sMonster = tMonsters[ math.random(1,#tMonsters) ]
|
||||||
@ -1240,7 +1239,7 @@ local function simulate()
|
|||||||
|
|
||||||
-- Burn monsters
|
-- Burn monsters
|
||||||
if h == 0 and isSunny() then
|
if h == 0 and isSunny() then
|
||||||
for n,sMonster in ipairs( tMonsters ) do
|
for _,sMonster in ipairs( tMonsters ) do
|
||||||
if room.items[sMonster] and items[sMonster].nocturnal then
|
if room.items[sMonster] and items[sMonster].nocturnal then
|
||||||
room.items[sMonster] = nil
|
room.items[sMonster] = nil
|
||||||
if sx == 0 and sy == 0 and sz == 0 and not room.dark then
|
if sx == 0 and sy == 0 and sz == 0 and not room.dark then
|
||||||
@ -1258,10 +1257,10 @@ local function simulate()
|
|||||||
-- Make monsters attack
|
-- Make monsters attack
|
||||||
local room = getRoom( x, y, z )
|
local room = getRoom( x, y, z )
|
||||||
if nTimeInRoom >= 2 and not bNewMonstersThisRoom then
|
if nTimeInRoom >= 2 and not bNewMonstersThisRoom then
|
||||||
for n,sMonster in ipairs( tMonsters ) do
|
for _,sMonster in ipairs( tMonsters ) do
|
||||||
if room.items[sMonster] then
|
if room.items[sMonster] then
|
||||||
if math.random(1,4) == 1 and
|
if math.random(1,4) == 1 and
|
||||||
not (y == 0 and isSunny() and (sMonster == "a spider")) then
|
not (y == 0 and isSunny() and sMonster == "a spider") then
|
||||||
if sMonster == "a creeper" then
|
if sMonster == "a creeper" then
|
||||||
if room.dark then
|
if room.dark then
|
||||||
print( "A creeper explodes." )
|
print( "A creeper explodes." )
|
||||||
|
@ -23,7 +23,7 @@ elseif sCommand == "play" or sCommand == nil then
|
|||||||
if sName == nil then
|
if sName == nil then
|
||||||
-- No disc specified, pick one at random
|
-- No disc specified, pick one at random
|
||||||
local tNames = {}
|
local tNames = {}
|
||||||
for n,sName in ipairs( peripheral.getNames() ) do
|
for _,sName in ipairs( peripheral.getNames() ) do
|
||||||
if disk.isPresent( sName ) and disk.hasAudio( sName ) then
|
if disk.isPresent( sName ) and disk.hasAudio( sName ) then
|
||||||
table.insert( tNames, sName )
|
table.insert( tNames, sName )
|
||||||
end
|
end
|
||||||
|
@ -2,15 +2,13 @@
|
|||||||
-- Display the start screen
|
-- Display the start screen
|
||||||
local w,h = term.getSize()
|
local w,h = term.getSize()
|
||||||
|
|
||||||
local titleColour, headingColour, textColour, wormColour, fruitColour
|
local headingColour, textColour, wormColour, fruitColour
|
||||||
if term.isColour() then
|
if term.isColour() then
|
||||||
titleColour = colours.red
|
|
||||||
headingColour = colours.yellow
|
headingColour = colours.yellow
|
||||||
textColour = colours.white
|
textColour = colours.white
|
||||||
wormColour = colours.green
|
wormColour = colours.green
|
||||||
fruitColour = colours.red
|
fruitColour = colours.red
|
||||||
else
|
else
|
||||||
titleColour = colours.white
|
|
||||||
headingColour = colours.white
|
headingColour = colours.white
|
||||||
textColour = colours.white
|
textColour = colours.white
|
||||||
wormColour = colours.white
|
wormColour = colours.white
|
||||||
@ -27,8 +25,6 @@ end
|
|||||||
local xVel,yVel = 1,0
|
local xVel,yVel = 1,0
|
||||||
local xPos, yPos = math.floor(w/2), math.floor(h/2)
|
local xPos, yPos = math.floor(w/2), math.floor(h/2)
|
||||||
local pxVel, pyVel = nil, nil
|
local pxVel, pyVel = nil, nil
|
||||||
|
|
||||||
local nLength = 1
|
|
||||||
local nExtraLength = 6
|
local nExtraLength = 6
|
||||||
local bRunning = true
|
local bRunning = true
|
||||||
|
|
||||||
@ -103,7 +99,6 @@ local function drawMenu()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function update( )
|
local function update( )
|
||||||
local x,y = xPos,yPos
|
|
||||||
if pxVel and pyVel then
|
if pxVel and pyVel then
|
||||||
xVel, yVel = pxVel, pyVel
|
xVel, yVel = pxVel, pyVel
|
||||||
pxVel, pyVel = nil, nil
|
pxVel, pyVel = nil, nil
|
||||||
@ -190,7 +185,7 @@ end
|
|||||||
drawMenu()
|
drawMenu()
|
||||||
drawFrontend()
|
drawFrontend()
|
||||||
while true do
|
while true do
|
||||||
local e,key = os.pullEvent( "key" )
|
local _,key = os.pullEvent( "key" )
|
||||||
if key == keys.up or key == keys.w then
|
if key == keys.up or key == keys.w then
|
||||||
-- Up
|
-- Up
|
||||||
if nDifficulty > 1 then
|
if nDifficulty > 1 then
|
||||||
@ -228,7 +223,7 @@ addFruit()
|
|||||||
-- Play the game
|
-- Play the game
|
||||||
local timer = os.startTimer(0)
|
local timer = os.startTimer(0)
|
||||||
while bRunning do
|
while bRunning do
|
||||||
local event, p1, p2 = os.pullEvent()
|
local event, p1 = os.pullEvent()
|
||||||
if event == "timer" and p1 == timer then
|
if event == "timer" and p1 == timer then
|
||||||
timer = os.startTimer(nInterval)
|
timer = os.startTimer(nInterval)
|
||||||
update( false )
|
update( false )
|
||||||
|
@ -28,7 +28,7 @@ elseif sCommand == "host" then
|
|||||||
|
|
||||||
-- Find a modem
|
-- Find a modem
|
||||||
local sModemSide = nil
|
local sModemSide = nil
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for _,sSide in ipairs( rs.getSides() ) do
|
||||||
if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then
|
if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then
|
||||||
sModemSide = sSide
|
sModemSide = sSide
|
||||||
break
|
break
|
||||||
@ -80,7 +80,7 @@ elseif sCommand == "host" then
|
|||||||
-- Print the number of requests handled
|
-- Print the number of requests handled
|
||||||
nServed = nServed + 1
|
nServed = nServed + 1
|
||||||
if nServed > 1 then
|
if nServed > 1 then
|
||||||
local x,y = term.getCursorPos()
|
local _,y = term.getCursorPos()
|
||||||
term.setCursorPos(1,y-1)
|
term.setCursorPos(1,y-1)
|
||||||
end
|
end
|
||||||
print( nServed.." GPS requests served" )
|
print( nServed.." GPS requests served" )
|
||||||
|
@ -14,7 +14,7 @@ if sTopic == "index" then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local sFile = help.lookup( sTopic )
|
local sFile = help.lookup( sTopic )
|
||||||
local file = ((sFile ~= nil) and io.open( sFile )) or nil
|
local file = sFile ~= nil and io.open( sFile ) or nil
|
||||||
if file then
|
if file then
|
||||||
local sContents = file:read("*a")
|
local sContents = file:read("*a")
|
||||||
file:close()
|
file:close()
|
||||||
|
@ -18,7 +18,7 @@ local tFiles = {}
|
|||||||
local tDirs = {}
|
local tDirs = {}
|
||||||
|
|
||||||
local bShowHidden = settings.get( "list.show_hidden" )
|
local bShowHidden = settings.get( "list.show_hidden" )
|
||||||
for n, sItem in pairs( tAll ) do
|
for _, sItem in pairs( tAll ) do
|
||||||
if bShowHidden or string.sub( sItem, 1, 1 ) ~= "." then
|
if bShowHidden or string.sub( sItem, 1, 1 ) ~= "." then
|
||||||
local sPath = fs.combine( sDir, sItem )
|
local sPath = fs.combine( sDir, sItem )
|
||||||
if fs.isDir( sPath ) then
|
if fs.isDir( sPath ) then
|
||||||
|
@ -67,7 +67,7 @@ while bRunning do
|
|||||||
|
|
||||||
local nForcePrint = 0
|
local nForcePrint = 0
|
||||||
local func, e = load( s, "=lua", "t", tEnv )
|
local func, e = load( s, "=lua", "t", tEnv )
|
||||||
local func2, e2 = load( "return _echo("..s..");", "=lua", "t", tEnv )
|
local func2 = load( "return _echo("..s..");", "=lua", "t", tEnv )
|
||||||
if not func then
|
if not func then
|
||||||
if func2 then
|
if func2 then
|
||||||
func = func2
|
func = func2
|
||||||
@ -84,7 +84,7 @@ while bRunning do
|
|||||||
local tResults = table.pack( pcall( func ) )
|
local tResults = table.pack( pcall( func ) )
|
||||||
if tResults[1] then
|
if tResults[1] then
|
||||||
local n = 1
|
local n = 1
|
||||||
while n < tResults.n or (n <= nForcePrint) do
|
while n < tResults.n or n <= nForcePrint do
|
||||||
local value = tResults[ n + 1 ]
|
local value = tResults[ n + 1 ]
|
||||||
if type( value ) == "table" then
|
if type( value ) == "table" then
|
||||||
local metatable = getmetatable( value )
|
local metatable = getmetatable( value )
|
||||||
|
@ -9,7 +9,7 @@ local sSource = shell.resolve( tArgs[1] )
|
|||||||
local sDest = shell.resolve( tArgs[2] )
|
local sDest = shell.resolve( tArgs[2] )
|
||||||
local tFiles = fs.find( sSource )
|
local tFiles = fs.find( sSource )
|
||||||
if #tFiles > 0 then
|
if #tFiles > 0 then
|
||||||
for n,sFile in ipairs( tFiles ) do
|
for _,sFile in ipairs( tFiles ) do
|
||||||
if fs.isDir( sDest ) then
|
if fs.isDir( sDest ) then
|
||||||
fs.move( sFile, fs.combine( sDest, fs.getName(sFile) ) )
|
fs.move( sFile, fs.combine( sDest, fs.getName(sFile) ) )
|
||||||
elseif #tFiles == 1 then
|
elseif #tFiles == 1 then
|
||||||
|
@ -424,7 +424,7 @@ local function playGame()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #rows>0 then
|
if #rows>0 then
|
||||||
for i=1,4 do
|
for _=1,4 do
|
||||||
sleep(.1)
|
sleep(.1)
|
||||||
for r=1,#rows do
|
for r=1,#rows do
|
||||||
r=rows[r]
|
r=rows[r]
|
||||||
@ -469,7 +469,6 @@ local function playGame()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function blockFall()
|
local function blockFall()
|
||||||
local result = false
|
|
||||||
if testBlockAt(curBlock,curX,curY+1,curRot) then
|
if testBlockAt(curBlock,curX,curY+1,curRot) then
|
||||||
pitBlock(curBlock,curX,curY,curRot)
|
pitBlock(curBlock,curX,curY,curRot)
|
||||||
--detect rows that clear
|
--detect rows that clear
|
||||||
@ -524,16 +523,16 @@ local function playGame()
|
|||||||
dropTimer=os.startTimer(dropSpeed)
|
dropTimer=os.startTimer(dropSpeed)
|
||||||
end
|
end
|
||||||
if dx+dr~=0 then
|
if dx+dr~=0 then
|
||||||
if not testBlockAt(curBlock,curX+dx,curY+dy,(dr>0 and curRot%#curBlock+dr or curRot)) then
|
if not testBlockAt(curBlock,curX+dx,curY+dy,dr>0 and curRot%#curBlock+dr or curRot) then
|
||||||
eraseBlockAt(curBlock,curX,curY,curRot)
|
eraseBlockAt(curBlock,curX,curY,curRot)
|
||||||
curX=curX+dx
|
curX=curX+dx
|
||||||
curY=curY+dy
|
curY=curY+dy
|
||||||
curRot=dr==0 and curRot or (curRot%#curBlock+dr)
|
curRot=dr==0 and curRot or curRot%#curBlock+dr
|
||||||
drawBlockAt(curBlock,curX,curY,curRot)
|
drawBlockAt(curBlock,curX,curY,curRot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif e[1]=="term_resize" then
|
elseif e[1]=="term_resize" then
|
||||||
local w,h=term.getSize()
|
local _,h=term.getSize()
|
||||||
if h==20 then
|
if h==20 then
|
||||||
heightAdjust=0
|
heightAdjust=0
|
||||||
else
|
else
|
||||||
@ -617,7 +616,7 @@ local function runMenu()
|
|||||||
level=math.max(level-1,1)
|
level=math.max(level-1,1)
|
||||||
drawMenu()
|
drawMenu()
|
||||||
elseif key>=keys.one and key<=keys.nine and selected==1 then
|
elseif key>=keys.one and key<=keys.nine and selected==1 then
|
||||||
level=(key-keys.one) + 1
|
level=key-keys.one + 1
|
||||||
drawMenu()
|
drawMenu()
|
||||||
elseif key==keys.up or key==keys.w then
|
elseif key==keys.up or key==keys.w then
|
||||||
selected=selected-1
|
selected=selected-1
|
||||||
|
@ -9,7 +9,7 @@ end
|
|||||||
|
|
||||||
local sOpenedModem = nil
|
local sOpenedModem = nil
|
||||||
local function openModem()
|
local function openModem()
|
||||||
for n,sModem in ipairs( peripheral.getNames() ) do
|
for _,sModem in ipairs( peripheral.getNames() ) do
|
||||||
if peripheral.getType( sModem ) == "modem" then
|
if peripheral.getType( sModem ) == "modem" then
|
||||||
if not rednet.isOpen( sModem ) then
|
if not rednet.isOpen( sModem ) then
|
||||||
rednet.open( sModem )
|
rednet.open( sModem )
|
||||||
@ -94,7 +94,7 @@ if sCommand == "host" then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function printUsers()
|
local function printUsers()
|
||||||
local x,y = term.getCursorPos()
|
local _,y = term.getCursorPos()
|
||||||
term.setCursorPos( 1, y - 1 )
|
term.setCursorPos( 1, y - 1 )
|
||||||
term.clearLine()
|
term.clearLine()
|
||||||
if nUsers == 1 then
|
if nUsers == 1 then
|
||||||
@ -108,7 +108,7 @@ if sCommand == "host" then
|
|||||||
local ok, error = pcall( function()
|
local ok, error = pcall( function()
|
||||||
parallel.waitForAny( function()
|
parallel.waitForAny( function()
|
||||||
while true do
|
while true do
|
||||||
local sEvent, timer = os.pullEvent( "timer" )
|
local _, timer = os.pullEvent( "timer" )
|
||||||
local nUserID = tPingPongTimer[ timer ]
|
local nUserID = tPingPongTimer[ timer ]
|
||||||
if nUserID and tUsers[ nUserID ] then
|
if nUserID and tUsers[ nUserID ] then
|
||||||
local tUser = tUsers[ nUserID ]
|
local tUser = tUsers[ nUserID ]
|
||||||
@ -148,7 +148,7 @@ if sCommand == "host" then
|
|||||||
["users"] = function( tUser, sContent )
|
["users"] = function( tUser, sContent )
|
||||||
send( "* Connected Users:", tUser.nUserID )
|
send( "* Connected Users:", tUser.nUserID )
|
||||||
local sUsers = "*"
|
local sUsers = "*"
|
||||||
for nUserID, tUser in pairs( tUsers ) do
|
for _, tUser in pairs( tUsers ) do
|
||||||
sUsers = sUsers .. " " .. tUser.sUsername
|
sUsers = sUsers .. " " .. tUser.sUsername
|
||||||
end
|
end
|
||||||
send( sUsers, tUser.nUserID )
|
send( sUsers, tUser.nUserID )
|
||||||
@ -156,7 +156,7 @@ if sCommand == "host" then
|
|||||||
["help"] = function( tUser, sContent )
|
["help"] = function( tUser, sContent )
|
||||||
send( "* Available commands:", tUser.nUserID )
|
send( "* Available commands:", tUser.nUserID )
|
||||||
local sCommands = "*"
|
local sCommands = "*"
|
||||||
for sCommand, fnCommand in pairs( tCommands ) do
|
for sCommand in pairs( tCommands ) do
|
||||||
sCommands = sCommands .. " /" .. sCommand
|
sCommands = sCommands .. " /" .. sCommand
|
||||||
end
|
end
|
||||||
send( sCommands.." /logout", tUser.nUserID )
|
send( sCommands.." /logout", tUser.nUserID )
|
||||||
@ -297,8 +297,7 @@ elseif sCommand == "join" then
|
|||||||
promptWindow.restoreCursor()
|
promptWindow.restoreCursor()
|
||||||
|
|
||||||
local function drawTitle()
|
local function drawTitle()
|
||||||
local x,y = titleWindow.getCursorPos()
|
local w = titleWindow.getSize()
|
||||||
local w,h = titleWindow.getSize()
|
|
||||||
local sTitle = sUsername.." on "..sHostname
|
local sTitle = sUsername.." on "..sHostname
|
||||||
titleWindow.setTextColour( highlightColour )
|
titleWindow.setTextColour( highlightColour )
|
||||||
titleWindow.setCursorPos( math.floor( w/2 - string.len(sTitle)/2 ), 1 )
|
titleWindow.setCursorPos( math.floor( w/2 - string.len(sTitle)/2 ), 1 )
|
||||||
@ -410,7 +409,7 @@ elseif sCommand == "join" then
|
|||||||
term.redirect( parentTerm )
|
term.redirect( parentTerm )
|
||||||
|
|
||||||
-- Print error notice
|
-- Print error notice
|
||||||
local w,h = term.getSize()
|
local _,h = term.getSize()
|
||||||
term.setCursorPos( 1, h )
|
term.setCursorPos( 1, h )
|
||||||
term.clearLine()
|
term.clearLine()
|
||||||
term.setCursorBlink( false )
|
term.setCursorBlink( false )
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
-- Find modems
|
-- Find modems
|
||||||
local tModems = {}
|
local tModems = {}
|
||||||
for n,sModem in ipairs( peripheral.getNames() ) do
|
for _,sModem in ipairs( peripheral.getNames() ) do
|
||||||
if peripheral.getType( sModem ) == "modem" then
|
if peripheral.getType( sModem ) == "modem" then
|
||||||
table.insert( tModems, sModem )
|
table.insert( tModems, sModem )
|
||||||
end
|
end
|
||||||
@ -59,7 +59,7 @@ local ok, error = pcall( function()
|
|||||||
|
|
||||||
-- Log the event
|
-- Log the event
|
||||||
nTransmittedMessages = nTransmittedMessages + 1
|
nTransmittedMessages = nTransmittedMessages + 1
|
||||||
local x,y = term.getCursorPos()
|
local _,y = term.getCursorPos()
|
||||||
term.setCursorPos( 1, y - 1 )
|
term.setCursorPos( 1, y - 1 )
|
||||||
term.clearLine()
|
term.clearLine()
|
||||||
if nTransmittedMessages == 1 then
|
if nTransmittedMessages == 1 then
|
||||||
|
@ -17,7 +17,7 @@ if sCommand == "probe" then
|
|||||||
|
|
||||||
local count = 0
|
local count = 0
|
||||||
local bundledCount = 0
|
local bundledCount = 0
|
||||||
for n,sSide in ipairs( redstone.getSides() ) do
|
for _,sSide in ipairs( redstone.getSides() ) do
|
||||||
if redstone.getBundledInput( sSide ) > 0 then
|
if redstone.getBundledInput( sSide ) > 0 then
|
||||||
bundledCount = bundledCount + 1
|
bundledCount = bundledCount + 1
|
||||||
end
|
end
|
||||||
@ -39,7 +39,7 @@ if sCommand == "probe" then
|
|||||||
if bundledCount > 0 then
|
if bundledCount > 0 then
|
||||||
print()
|
print()
|
||||||
print( "Bundled inputs:" )
|
print( "Bundled inputs:" )
|
||||||
for i,sSide in ipairs( redstone.getSides() ) do
|
for _,sSide in ipairs( redstone.getSides() ) do
|
||||||
local nInput = redstone.getBundledInput( sSide )
|
local nInput = redstone.getBundledInput( sSide )
|
||||||
if nInput ~= 0 then
|
if nInput ~= 0 then
|
||||||
write( sSide..": " )
|
write( sSide..": " )
|
||||||
@ -69,7 +69,7 @@ elseif sCommand == "pulse" then
|
|||||||
local sSide = tArgs[2]
|
local sSide = tArgs[2]
|
||||||
local nCount = tonumber( tArgs[3] ) or 1
|
local nCount = tonumber( tArgs[3] ) or 1
|
||||||
local nPeriod = tonumber( tArgs[4] ) or 0.5
|
local nPeriod = tonumber( tArgs[4] ) or 0.5
|
||||||
for n=1,nCount do
|
for _=1,nCount do
|
||||||
redstone.setOutput( sSide, true )
|
redstone.setOutput( sSide, true )
|
||||||
sleep( nPeriod / 2 )
|
sleep( nPeriod / 2 )
|
||||||
redstone.setOutput( sSide, false )
|
redstone.setOutput( sSide, false )
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
local tArgs = { ... }
|
local tArgs = { ... }
|
||||||
if #tArgs == 0 then
|
if #tArgs == 0 then
|
||||||
-- "set"
|
-- "set"
|
||||||
local x,y = term.getCursorPos()
|
local _,y = term.getCursorPos()
|
||||||
local tSettings = {}
|
local tSettings = {}
|
||||||
for n,sName in ipairs( settings.getNames() ) do
|
for n,sName in ipairs( settings.getNames() ) do
|
||||||
tSettings[n] = textutils.serialize(sName) .. " is " .. textutils.serialize(settings.get(sName))
|
tSettings[n] = textutils.serialize(sName) .. " is " .. textutils.serialize(settings.get(sName))
|
||||||
|
@ -9,10 +9,10 @@ if multishell then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local bExit = false
|
local bExit = false
|
||||||
local sDir = (parentShell and parentShell.dir()) or ""
|
local sDir = parentShell and parentShell.dir() or ""
|
||||||
local sPath = (parentShell and parentShell.path()) or ".:/rom/programs"
|
local sPath = parentShell and parentShell.path() or ".:/rom/programs"
|
||||||
local tAliases = (parentShell and parentShell.aliases()) or {}
|
local tAliases = parentShell and parentShell.aliases() or {}
|
||||||
local tCompletionInfo = (parentShell and parentShell.getCompletionInfo()) or {}
|
local tCompletionInfo = parentShell and parentShell.getCompletionInfo() or {}
|
||||||
local tProgramStack = {}
|
local tProgramStack = {}
|
||||||
|
|
||||||
local shell = {}
|
local shell = {}
|
||||||
@ -287,7 +287,7 @@ function shell.programs( _bIncludeHidden )
|
|||||||
|
|
||||||
-- Sort and return
|
-- Sort and return
|
||||||
local tItemList = {}
|
local tItemList = {}
|
||||||
for sItem, b in pairs( tItems ) do
|
for sItem in pairs( tItems ) do
|
||||||
table.insert( tItemList, sItem )
|
table.insert( tItemList, sItem )
|
||||||
end
|
end
|
||||||
table.sort( tItemList )
|
table.sort( tItemList )
|
||||||
@ -304,7 +304,7 @@ local function completeProgram( sLine )
|
|||||||
local tSeen = {}
|
local tSeen = {}
|
||||||
|
|
||||||
-- Add aliases
|
-- Add aliases
|
||||||
for sAlias, sCommand in pairs( tAliases ) do
|
for sAlias in pairs( tAliases ) do
|
||||||
if #sAlias > #sLine and string.sub( sAlias, 1, #sLine ) == sLine then
|
if #sAlias > #sLine and string.sub( sAlias, 1, #sLine ) == sLine then
|
||||||
local sResult = string.sub( sAlias, #sLine + 1 )
|
local sResult = string.sub( sAlias, #sLine + 1 )
|
||||||
if not tSeen[ sResult ] then
|
if not tSeen[ sResult ] then
|
||||||
|
@ -81,7 +81,7 @@ textutils.slowWrite( "Preparing to get down." )
|
|||||||
textutils.slowPrint( "..", 0.75 )
|
textutils.slowPrint( "..", 0.75 )
|
||||||
|
|
||||||
local sAudio = nil
|
local sAudio = nil
|
||||||
for n,sName in pairs( peripheral.getNames() ) do
|
for _,sName in pairs( peripheral.getNames() ) do
|
||||||
if disk.hasAudio( sName ) then
|
if disk.hasAudio( sName ) then
|
||||||
disk.playAudio( sName )
|
disk.playAudio( sName )
|
||||||
print( "Jamming to "..disk.getAudioTitle( sName ) )
|
print( "Jamming to "..disk.getAudioTitle( sName ) )
|
||||||
@ -95,7 +95,7 @@ print( "Press any key to stop the groove" )
|
|||||||
parallel.waitForAny(
|
parallel.waitForAny(
|
||||||
function()
|
function()
|
||||||
while not bEnd do
|
while not bEnd do
|
||||||
local event, key = os.pullEvent("key")
|
local _, key = os.pullEvent("key")
|
||||||
if key ~= keys.escape then
|
if key ~= keys.escape then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -81,7 +81,7 @@ local function collect()
|
|||||||
if nTotalItems > collected then
|
if nTotalItems > collected then
|
||||||
collected = nTotalItems
|
collected = nTotalItems
|
||||||
if math.fmod(collected + unloaded, 50) == 0 then
|
if math.fmod(collected + unloaded, 50) == 0 then
|
||||||
print( "Mined "..(collected + unloaded).." items." )
|
print( "Mined "..collected + unloaded.." items." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -98,9 +98,8 @@ function refuel( ammount )
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local needed = ammount or (xPos + zPos + depth + 2)
|
local needed = ammount or xPos + zPos + depth + 2
|
||||||
if turtle.getFuelLevel() < needed then
|
if turtle.getFuelLevel() < needed then
|
||||||
local fueled = false
|
|
||||||
for n=1,16 do
|
for n=1,16 do
|
||||||
if turtle.getItemCount(n) > 0 then
|
if turtle.getItemCount(n) > 0 then
|
||||||
turtle.select(n)
|
turtle.select(n)
|
||||||
@ -292,7 +291,7 @@ local alternate = 0
|
|||||||
local done = false
|
local done = false
|
||||||
while not done do
|
while not done do
|
||||||
for n=1,size do
|
for n=1,size do
|
||||||
for m=1,size-1 do
|
for _=1,size-1 do
|
||||||
if not tryForwards() then
|
if not tryForwards() then
|
||||||
done = true
|
done = true
|
||||||
break
|
break
|
||||||
@ -354,4 +353,4 @@ if reseal then
|
|||||||
turtle.placeDown()
|
turtle.placeDown()
|
||||||
end
|
end
|
||||||
|
|
||||||
print( "Mined "..(collected + unloaded).." items total." )
|
print( "Mined "..collected + unloaded.." items total." )
|
||||||
|
@ -23,7 +23,7 @@ end
|
|||||||
if turtle.getFuelLevel() ~= "unlimited" then
|
if turtle.getFuelLevel() ~= "unlimited" then
|
||||||
for n = 1, 16 do
|
for n = 1, 16 do
|
||||||
-- Stop if we've reached the limit, or are fully refuelled.
|
-- Stop if we've reached the limit, or are fully refuelled.
|
||||||
if (nLimit and nLimit <= 0) or turtle.getFuelLevel() >= turtle.getFuelLimit() then
|
if nLimit and nLimit <= 0 or turtle.getFuelLevel() >= turtle.getFuelLimit() then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ if length < 1 then
|
|||||||
print( "Tunnel length must be positive" )
|
print( "Tunnel length must be positive" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local depth = 0
|
|
||||||
local collected = 0
|
local collected = 0
|
||||||
|
|
||||||
local function collect()
|
local function collect()
|
||||||
|
@ -31,7 +31,7 @@ while nArg <= #tArgs do
|
|||||||
|
|
||||||
local fnHandler = tHandlers[string.lower(sDirection)]
|
local fnHandler = tHandlers[string.lower(sDirection)]
|
||||||
if fnHandler then
|
if fnHandler then
|
||||||
for n=1,nDistance do
|
for _=1,nDistance do
|
||||||
fnHandler( nArg )
|
fnHandler( nArg )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -163,7 +163,7 @@ if settings.get( "shell.allow_startup" ) then
|
|||||||
tUserStartups = findStartups( "/" )
|
tUserStartups = findStartups( "/" )
|
||||||
end
|
end
|
||||||
if settings.get( "shell.allow_disk_startup" ) then
|
if settings.get( "shell.allow_disk_startup" ) then
|
||||||
for n,sName in pairs( peripheral.getNames() ) do
|
for _,sName in pairs( peripheral.getNames() ) do
|
||||||
if disk.isPresent( sName ) and disk.hasData( sName ) then
|
if disk.isPresent( sName ) and disk.hasData( sName ) then
|
||||||
local startups = findStartups( disk.getMountPath( sName ) )
|
local startups = findStartups( disk.getMountPath( sName ) )
|
||||||
if startups then
|
if startups then
|
||||||
|
Loading…
Reference in New Issue
Block a user