1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-04-09 20:26:42 +00:00

The big massive reformat

- Normalise all line endings to be LF rather than CLRF
 - Trim all trailing whitespace
 - Remove any tabs
This commit is contained in:
SquidDev 2018-12-17 17:22:15 +00:00
parent e6850ab644
commit 86569533e9
154 changed files with 3684 additions and 3717 deletions

View File

@ -1,19 +0,0 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2017. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.client.gui.widgets;
public class MousePos
{
public int x;
public int y;
public MousePos( int x, int y )
{
this.x = x;
this.y = y;
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"computercraft:wired_modem",
"recipes": [
"computercraft:wired_modem",
"computercraft:wired_modem_full_to",
"computercraft:wired_modem_full_from"
]

View File

@ -1,17 +1,17 @@
{
"variants": {
"facing=up,on=false": { "model": "computercraft:advanced_modem_off", "x": 270 },
"facing=down,on=false": { "model": "computercraft:advanced_modem_off", "x": 90 },
"facing=north,on=false": { "model": "computercraft:advanced_modem_off" },
"facing=south,on=false": { "model": "computercraft:advanced_modem_off", "y": 180 },
"facing=west,on=false": { "model": "computercraft:advanced_modem_off", "y": 270 },
"facing=east,on=false": { "model": "computercraft:advanced_modem_off", "y": 90 },
"facing=up,on=true": { "model": "computercraft:advanced_modem_on", "x": 270 },
"facing=down,on=true": { "model": "computercraft:advanced_modem_on", "x": 90 },
"facing=north,on=true": { "model": "computercraft:advanced_modem_on" },
"facing=south,on=true": { "model": "computercraft:advanced_modem_on", "y": 180 },
"facing=west,on=true": { "model": "computercraft:advanced_modem_on", "y": 270 },
"facing=east,on=true": { "model": "computercraft:advanced_modem_on", "y": 90 }
}
}
{
"variants": {
"facing=up,on=false": { "model": "computercraft:advanced_modem_off", "x": 270 },
"facing=down,on=false": { "model": "computercraft:advanced_modem_off", "x": 90 },
"facing=north,on=false": { "model": "computercraft:advanced_modem_off" },
"facing=south,on=false": { "model": "computercraft:advanced_modem_off", "y": 180 },
"facing=west,on=false": { "model": "computercraft:advanced_modem_off", "y": 270 },
"facing=east,on=false": { "model": "computercraft:advanced_modem_off", "y": 90 },
"facing=up,on=true": { "model": "computercraft:advanced_modem_on", "x": 270 },
"facing=down,on=true": { "model": "computercraft:advanced_modem_on", "x": 90 },
"facing=north,on=true": { "model": "computercraft:advanced_modem_on" },
"facing=south,on=true": { "model": "computercraft:advanced_modem_on", "y": 180 },
"facing=west,on=true": { "model": "computercraft:advanced_modem_on", "y": 270 },
"facing=east,on=true": { "model": "computercraft:advanced_modem_on", "y": 90 }
}
}

View File

@ -1,18 +1,18 @@
{
"variants": {
"facing=north,state=off": { "model": "computercraft:command_computer_off" },
"facing=south,state=off": { "model": "computercraft:command_computer_off", "y": 180 },
"facing=west,state=off": { "model": "computercraft:command_computer_off", "y": 270 },
"facing=east,state=off": { "model": "computercraft:command_computer_off", "y": 90 },
"facing=north,state=on": { "model": "computercraft:command_computer_on" },
"facing=south,state=on": { "model": "computercraft:command_computer_on", "y": 180 },
"facing=west,state=on": { "model": "computercraft:command_computer_on", "y": 270 },
"facing=east,state=on": { "model": "computercraft:command_computer_on", "y": 90 },
"facing=north,state=blinking": { "model": "computercraft:command_computer_blinking" },
"facing=south,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 180 },
"facing=west,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 270 },
"facing=east,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 90 }
}
}
{
"variants": {
"facing=north,state=off": { "model": "computercraft:command_computer_off" },
"facing=south,state=off": { "model": "computercraft:command_computer_off", "y": 180 },
"facing=west,state=off": { "model": "computercraft:command_computer_off", "y": 270 },
"facing=east,state=off": { "model": "computercraft:command_computer_off", "y": 90 },
"facing=north,state=on": { "model": "computercraft:command_computer_on" },
"facing=south,state=on": { "model": "computercraft:command_computer_on", "y": 180 },
"facing=west,state=on": { "model": "computercraft:command_computer_on", "y": 270 },
"facing=east,state=on": { "model": "computercraft:command_computer_on", "y": 90 },
"facing=north,state=blinking": { "model": "computercraft:command_computer_blinking" },
"facing=south,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 180 },
"facing=west,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 270 },
"facing=east,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 90 }
}
}

View File

@ -1,16 +1,15 @@
{
"variants": {
"advanced=false,facing=north,state=off": { "model": "computercraft:computer_off" },
"advanced=false,facing=south,state=off": { "model": "computercraft:computer_off", "y": 180 },
"advanced=false,facing=west,state=off": { "model": "computercraft:computer_off", "y": 270 },
"advanced=false,facing=east,state=off": { "model": "computercraft:computer_off", "y": 90 },
"advanced=false,facing=north,state=on": { "model": "computercraft:computer_on" },
"advanced=false,facing=south,state=on": { "model": "computercraft:computer_on", "y": 180 },
"advanced=false,facing=west,state=on": { "model": "computercraft:computer_on", "y": 270 },
"advanced=false,facing=east,state=on": { "model": "computercraft:computer_on", "y": 90 },
"advanced=false,facing=north,state=blinking": { "model": "computercraft:computer_blinking" },
"advanced=false,facing=south,state=blinking": { "model": "computercraft:computer_blinking", "y": 180 },
"advanced=false,facing=west,state=blinking": { "model": "computercraft:computer_blinking", "y": 270 },
@ -20,12 +19,12 @@
"advanced=true,facing=south,state=off": { "model": "computercraft:advanced_computer_off", "y": 180 },
"advanced=true,facing=west,state=off": { "model": "computercraft:advanced_computer_off", "y": 270 },
"advanced=true,facing=east,state=off": { "model": "computercraft:advanced_computer_off", "y": 90 },
"advanced=true,facing=north,state=on": { "model": "computercraft:advanced_computer_on" },
"advanced=true,facing=south,state=on": { "model": "computercraft:advanced_computer_on", "y": 180 },
"advanced=true,facing=west,state=on": { "model": "computercraft:advanced_computer_on", "y": 270 },
"advanced=true,facing=east,state=on": { "model": "computercraft:advanced_computer_on", "y": 90 },
"advanced=true,facing=north,state=blinking": { "model": "computercraft:advanced_computer_blinking" },
"advanced=true,facing=south,state=blinking": { "model": "computercraft:advanced_computer_blinking", "y": 180 },
"advanced=true,facing=west,state=blinking": { "model": "computercraft:advanced_computer_blinking", "y": 270 },

View File

@ -34,7 +34,7 @@
"facing=south,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 180 },
"facing=west,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 270 },
"facing=east,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 90 },
"facing=north,variant=wireless_modem_off": { "model": "computercraft:wireless_modem_off" },
"facing=south,variant=wireless_modem_off": { "model": "computercraft:wireless_modem_off", "y": 180 },
"facing=west,variant=wireless_modem_off": { "model": "computercraft:wireless_modem_off", "y": 270 },
@ -256,7 +256,7 @@
"facing=south,variant=monitor_down_lu": { "model": "computercraft:monitor_lu", "y": 180, "x": 90 },
"facing=west,variant=monitor_down_lu": { "model": "computercraft:monitor_lu", "y": 270, "x": 90 },
"facing=east,variant=monitor_down_lu": { "model": "computercraft:monitor_lu", "y": 90, "x": 90 },
"facing=north,variant=advanced_monitor": { "model": "computercraft:advanced_monitor" },
"facing=south,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 180 },
"facing=west,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 270 },

View File

@ -7,18 +7,18 @@ if _VERSION == "Lua 5.1" then
local nativesetfenv = setfenv
function load( x, name, mode, env )
if type( x ) ~= "string" and type( x ) ~= "function" then
error( "bad argument #1 (expected string or function, got " .. type( x ) .. ")", 2 )
error( "bad argument #1 (expected string or function, got " .. type( x ) .. ")", 2 )
end
if name ~= nil and type( name ) ~= "string" then
error( "bad argument #2 (expected string, got " .. type( name ) .. ")", 2 )
error( "bad argument #2 (expected string, got " .. type( name ) .. ")", 2 )
end
if mode ~= nil and type( mode ) ~= "string" then
error( "bad argument #3 (expected string, got " .. type( mode ) .. ")", 2 )
error( "bad argument #3 (expected string, got " .. type( mode ) .. ")", 2 )
end
if env ~= nil and type( env) ~= "table" then
error( "bad argument #4 (expected table, got " .. type( env ) .. ")", 2 )
error( "bad argument #4 (expected table, got " .. type( env ) .. ")", 2 )
end
local ok, p1, p2 = pcall( function()
local ok, p1, p2 = pcall( function()
if type(x) == "string" then
local result, err = nativeloadstring( x, name )
if result then
@ -47,7 +47,7 @@ if _VERSION == "Lua 5.1" then
return p1, p2
else
error( p1, 2 )
end
end
end
table.unpack = unpack
table.pack = function( ... ) return { n = select( "#", ... ), ... } end
@ -159,7 +159,7 @@ end
-- Install globals
function sleep( nTime )
if nTime ~= nil and type( nTime ) ~= "number" then
error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 )
error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 )
end
local timer = os.startTimer( nTime or 0 )
repeat
@ -169,12 +169,12 @@ end
function write( sText )
if type( sText ) ~= "string" and type( sText ) ~= "number" then
error( "bad argument #1 (expected string or number, got " .. type( sText ) .. ")", 2 )
error( "bad argument #1 (expected string or number, got " .. type( sText ) .. ")", 2 )
end
local w,h = term.getSize()
local w,h = term.getSize()
local x,y = term.getCursorPos()
local nLinesPrinted = 0
local function newLine()
if y + 1 <= h then
@ -186,7 +186,7 @@ function write( sText )
x, y = term.getCursorPos()
nLinesPrinted = nLinesPrinted + 1
end
-- Print the line with proper word wrapping
while string.len(sText) > 0 do
local whitespace = string.match( sText, "^[ \t]+" )
@ -196,19 +196,19 @@ function write( sText )
x,y = term.getCursorPos()
sText = string.sub( sText, string.len(whitespace) + 1 )
end
local newline = string.match( sText, "^\n" )
if newline then
-- Print newlines
newLine()
sText = string.sub( sText, 2 )
end
local text = string.match( sText, "^[^ \t\n]+" )
if text then
sText = string.sub( sText, string.len(text) + 1 )
if string.len(text) > w then
-- Print a multiline word
-- Print a multiline word
while string.len( text ) > 0 do
if x > w then
newLine()
@ -227,7 +227,7 @@ function write( sText )
end
end
end
return nLinesPrinted
end
@ -259,16 +259,16 @@ end
function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
if _sReplaceChar ~= nil and type( _sReplaceChar ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sReplaceChar ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sReplaceChar ) .. ")", 2 )
end
if _tHistory ~= nil and type( _tHistory ) ~= "table" then
error( "bad argument #2 (expected table, got " .. type( _tHistory ) .. ")", 2 )
error( "bad argument #2 (expected table, got " .. type( _tHistory ) .. ")", 2 )
end
if _fnComplete ~= nil and type( _fnComplete ) ~= "function" then
error( "bad argument #3 (expected function, got " .. type( _fnComplete ) .. ")", 2 )
error( "bad argument #3 (expected function, got " .. type( _fnComplete ) .. ")", 2 )
end
if _sDefault ~= nil and type( _sDefault ) ~= "string" then
error( "bad argument #4 (expected string, got " .. type( _sDefault ) .. ")", 2 )
error( "bad argument #4 (expected string, got " .. type( _sDefault ) .. ")", 2 )
end
term.setCursorBlink( true )
@ -345,7 +345,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
term.setCursorPos( sx + nPos - nScroll, cy )
end
local function clear()
redraw( true )
end
@ -395,7 +395,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
redraw()
end
break
elseif param == keys.left then
-- Left
if nPos > 0 then
@ -404,9 +404,9 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
recomplete()
redraw()
end
elseif param == keys.right then
-- Right
-- Right
if nPos < string.len(sLine) then
-- Move right
clear()
@ -454,11 +454,11 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
nHistoryPos = nil
elseif nHistoryPos ~= nil then
nHistoryPos = nHistoryPos + 1
end
end
end
if nHistoryPos then
sLine = _tHistory[nHistoryPos]
nPos = string.len( sLine )
nPos = string.len( sLine )
else
sLine = ""
nPos = 0
@ -491,7 +491,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
-- Delete
if nPos < string.len(sLine) then
clear()
sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )
sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )
recomplete()
redraw()
end
@ -523,16 +523,16 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
term.setCursorBlink( false )
term.setCursorPos( w + 1, cy )
print()
return sLine
end
loadfile = function( _sFile, _tEnv )
if type( _sFile ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 )
end
if _tEnv ~= nil and type( _tEnv ) ~= "table" then
error( "bad argument #2 (expected table, got " .. type( _tEnv ) .. ")", 2 )
error( "bad argument #2 (expected table, got " .. type( _tEnv ) .. ")", 2 )
end
local file = fs.open( _sFile, "r" )
if file then
@ -545,7 +545,7 @@ end
dofile = function( _sFile )
if type( _sFile ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 )
end
local fnFile, e = loadfile( _sFile, _G )
if fnFile then
@ -558,10 +558,10 @@ end
-- Install the rest of the OS api
function os.run( _tEnv, _sPath, ... )
if type( _tEnv ) ~= "table" then
error( "bad argument #1 (expected table, got " .. type( _tEnv ) .. ")", 2 )
error( "bad argument #1 (expected table, got " .. type( _tEnv ) .. ")", 2 )
end
if type( _sPath ) ~= "string" then
error( "bad argument #2 (expected string, got " .. type( _sPath ) .. ")", 2 )
error( "bad argument #2 (expected string, got " .. type( _sPath ) .. ")", 2 )
end
local tArgs = table.pack( ... )
local tEnv = _tEnv
@ -588,7 +588,7 @@ end
local tAPIsLoading = {}
function os.loadAPI( _sPath )
if type( _sPath ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 )
end
local sName = fs.getName( _sPath )
if sName:sub(-4) == ".lua" then
@ -613,7 +613,7 @@ function os.loadAPI( _sPath )
tAPIsLoading[sName] = nil
return error( "Failed to load API " .. sName .. " due to " .. err, 1 )
end
local tAPI = {}
for k,v in pairs( tEnv ) do
if k ~= "_ENV" then
@ -621,14 +621,14 @@ function os.loadAPI( _sPath )
end
end
_G[sName] = tAPI
_G[sName] = tAPI
tAPIsLoading[sName] = nil
return true
end
function os.unloadAPI( _sName )
if type( _sName ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sName ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sName ) .. ")", 2 )
end
if _sName ~= "_G" and type(_G[_sName]) == "table" then
_G[_sName] = nil
@ -667,7 +667,7 @@ if http then
local function checkKey( options, key, ty, opt )
local value = options[key]
local valueTy = type(value)
if (value ~= nil or not opt) and valueTy ~= ty then
error(("bad field '%s' (expected %s, got %s"):format(key, ty, valueTy), 4)
end
@ -675,8 +675,8 @@ if http then
local function checkOptions( options, body )
checkKey( options, "url", "string")
if body == false
then checkKey( options, "body", "nil" )
if body == false
then checkKey( options, "body", "nil" )
else checkKey( options, "body", "string", not body ) end
checkKey( options, "headers", "table", true )
checkKey( options, "method", "string", true )
@ -701,7 +701,7 @@ if http then
end
return nil, err
end
http.get = function( _url, _headers, _binary)
if type( _url ) == "table" then
checkOptions( _url, false )
@ -709,13 +709,13 @@ if http then
end
if type( _url ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 )
end
if _headers ~= nil and type( _headers ) ~= "table" then
error( "bad argument #2 (expected table, got " .. type( _headers ) .. ")", 2 )
error( "bad argument #2 (expected table, got " .. type( _headers ) .. ")", 2 )
end
if _binary ~= nil and type( _binary ) ~= "boolean" then
error( "bad argument #3 (expected boolean, got " .. type( _binary ) .. ")", 2 )
error( "bad argument #3 (expected boolean, got " .. type( _binary ) .. ")", 2 )
end
return wrapRequest( _url, _url, nil, _headers, _binary )
end
@ -727,16 +727,16 @@ if http then
end
if type( _url ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 )
end
if type( _post ) ~= "string" then
error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 )
error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 )
end
if _headers ~= nil and type( _headers ) ~= "table" then
error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 )
error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 )
end
if _binary ~= nil and type( _binary ) ~= "boolean" then
error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 )
error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 )
end
return wrapRequest( _url, _url, _post, _headers, _binary )
end
@ -748,16 +748,16 @@ if http then
url = _url.url
else
if type( _url ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 )
end
if _post ~= nil and type( _post ) ~= "string" then
error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 )
error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 )
end
if _headers ~= nil and type( _headers ) ~= "table" then
error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 )
error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 )
end
if _binary ~= nil and type( _binary ) ~= "boolean" then
error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 )
error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 )
end
url = _url.url
@ -769,13 +769,13 @@ if http then
end
return ok, err
end
local nativeCheckURL = http.checkURL
http.checkURLAsync = nativeCheckURL
http.checkURL = function( _url )
local ok, err = nativeCheckURL( _url )
if not ok then return ok, err end
while true do
local event, url, ok, err = os.pullEvent( "http_check" )
if url == _url then return ok, err end
@ -809,16 +809,16 @@ end
local tEmpty = {}
function fs.complete( sPath, sLocation, bIncludeFiles, bIncludeDirs )
if type( sPath ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 )
end
if type( sLocation ) ~= "string" then
error( "bad argument #2 (expected string, got " .. type( sLocation ) .. ")", 2 )
error( "bad argument #2 (expected string, got " .. type( sLocation ) .. ")", 2 )
end
if bIncludeFiles ~= nil and type( bIncludeFiles ) ~= "boolean" then
error( "bad argument #3 (expected boolean, got " .. type( bIncludeFiles ) .. ")", 2 )
error( "bad argument #3 (expected boolean, got " .. type( bIncludeFiles ) .. ")", 2 )
end
if bIncludeDirs ~= nil and type( bIncludeDirs ) ~= "boolean" then
error( "bad argument #4 (expected boolean, got " .. type( bIncludeDirs ) .. ")", 2 )
error( "bad argument #4 (expected boolean, got " .. type( bIncludeDirs ) .. ")", 2 )
end
bIncludeFiles = (bIncludeFiles ~= false)
bIncludeDirs = (bIncludeDirs ~= false)
@ -960,7 +960,7 @@ end
settings.set( "shell.allow_startup", true )
settings.set( "shell.allow_disk_startup", (commands == nil) )
settings.set( "shell.autocomplete", true )
settings.set( "edit.autocomplete", true )
settings.set( "edit.autocomplete", true )
settings.set( "edit.default_extension", "lua" )
settings.set( "paint.default_extension", "nfp" )
settings.set( "lua.autocomplete", true )
@ -1000,7 +1000,7 @@ end
-- Run the shell
local ok, err = pcall( function()
parallel.waitForAny(
parallel.waitForAny(
function()
local sShell
if term.isColour() and settings.get( "bios.use_multishell" ) then

View File

@ -57,7 +57,7 @@ function rgb8( r, g, b )
elseif type(r) == "number" and g == nil and b == nil then
return bit32.band( bit32.rshift( r, 16 ), 0xFF ) / 255, bit32.band( bit32.rshift( r, 8 ), 0xFF ) / 255, bit32.band( r, 0xFF ) / 255
elseif type(r) == "number" and type(g) == "number" and type(b) == "number" then
return
return
bit32.lshift( bit32.band(r * 255, 0xFF), 16 ) +
bit32.lshift( bit32.band(g * 255, 0xFF), 8 ) +
bit32.band(b * 255, 0xFF)

View File

@ -1,87 +1,87 @@
local function isDrive( name )
if type( name ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( name ) .. ")", 3 )
error( "bad argument #1 (expected string, got " .. type( name ) .. ")", 3 )
end
return peripheral.getType( name ) == "drive"
return peripheral.getType( name ) == "drive"
end
function isPresent( name )
if isDrive( name ) then
return peripheral.call( name, "isDiskPresent" )
end
return false
if isDrive( name ) then
return peripheral.call( name, "isDiskPresent" )
end
return false
end
function getLabel( name )
if isDrive( name ) then
return peripheral.call( name, "getDiskLabel" )
end
return nil
if isDrive( name ) then
return peripheral.call( name, "getDiskLabel" )
end
return nil
end
function setLabel( name, label )
if isDrive( name ) then
peripheral.call( name, "setDiskLabel", label )
end
if isDrive( name ) then
peripheral.call( name, "setDiskLabel", label )
end
end
function hasData( name )
if isDrive( name ) then
return peripheral.call( name, "hasData" )
end
return false
if isDrive( name ) then
return peripheral.call( name, "hasData" )
end
return false
end
function getMountPath( name )
if isDrive( name ) then
return peripheral.call( name, "getMountPath" )
end
return nil
if isDrive( name ) then
return peripheral.call( name, "getMountPath" )
end
return nil
end
function hasAudio( name )
if isDrive( name ) then
return peripheral.call( name, "hasAudio" )
end
return false
if isDrive( name ) then
return peripheral.call( name, "hasAudio" )
end
return false
end
function getAudioTitle( name )
if isDrive( name ) then
return peripheral.call( name, "getAudioTitle" )
end
return nil
if isDrive( name ) then
return peripheral.call( name, "getAudioTitle" )
end
return nil
end
function playAudio( name )
if isDrive( name ) then
peripheral.call( name, "playAudio" )
end
if isDrive( name ) then
peripheral.call( name, "playAudio" )
end
end
function stopAudio( name )
if not name then
for n,sName in ipairs( peripheral.getNames() ) do
stopAudio( sName )
end
else
if isDrive( name ) then
peripheral.call( name, "stopAudio" )
end
end
if not name then
for n,sName in ipairs( peripheral.getNames() ) do
stopAudio( sName )
end
else
if isDrive( name ) then
peripheral.call( name, "stopAudio" )
end
end
end
function eject( name )
if isDrive( name ) then
peripheral.call( name, "ejectDisk" )
end
if isDrive( name ) then
peripheral.call( name, "ejectDisk" )
end
end
function getID( name )
if isDrive( name ) then
return peripheral.call( name, "getDiskID" )
end
return nil
if isDrive( name ) then
return peripheral.call( name, "getDiskID" )
end
return nil
end

View File

@ -1,122 +1,121 @@
CHANNEL_GPS = 65534
local function trilaterate( A, B, C )
local a2b = B.vPosition - A.vPosition
local a2c = C.vPosition - A.vPosition
if math.abs( a2b:normalize():dot( a2c:normalize() ) ) > 0.999 then
return nil
end
local d = a2b:length()
local ex = a2b:normalize( )
local i = ex:dot( a2c )
local ey = (a2c - (ex * i)):normalize()
local j = ey:dot( a2c )
local ez = ex:cross( ey )
local a2b = B.vPosition - A.vPosition
local a2c = C.vPosition - A.vPosition
local r1 = A.nDistance
local r2 = B.nDistance
local r3 = C.nDistance
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 result = A.vPosition + (ex * x) + (ey * y)
if math.abs( a2b:normalize():dot( a2c:normalize() ) ) > 0.999 then
return nil
end
local d = a2b:length()
local ex = a2b:normalize( )
local i = ex:dot( a2c )
local ey = (a2c - (ex * i)):normalize()
local j = ey:dot( a2c )
local ez = ex:cross( ey )
local r1 = A.nDistance
local r2 = B.nDistance
local r3 = C.nDistance
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 result = A.vPosition + (ex * x) + (ey * y)
local zSquared = r1*r1 - x*x - y*y
if zSquared > 0 then
local z = math.sqrt( zSquared )
local result1 = result + (ez * z)
local result2 = result - (ez * z)
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
return rounded1, rounded2
else
return rounded1
end
end
return result:round( 0.01 )
local zSquared = r1*r1 - x*x - y*y
if zSquared > 0 then
local z = math.sqrt( zSquared )
local result1 = result + (ez * z)
local result2 = result - (ez * z)
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
return rounded1, rounded2
else
return rounded1
end
end
return result:round( 0.01 )
end
local function narrow( p1, p2, fix )
local dist1 = math.abs( (p1 - fix.vPosition):length() - fix.nDistance )
local dist2 = math.abs( (p2 - fix.vPosition):length() - fix.nDistance )
if math.abs(dist1 - dist2) < 0.01 then
return p1, p2
elseif dist1 < dist2 then
return p1:round( 0.01 )
else
return p2:round( 0.01 )
end
local dist1 = math.abs( (p1 - fix.vPosition):length() - fix.nDistance )
local dist2 = math.abs( (p2 - fix.vPosition):length() - fix.nDistance )
if math.abs(dist1 - dist2) < 0.01 then
return p1, p2
elseif dist1 < dist2 then
return p1:round( 0.01 )
else
return p2:round( 0.01 )
end
end
function locate( _nTimeout, _bDebug )
if _nTimeout ~= nil and type( _nTimeout ) ~= "number" then
error( "bad argument #1 (expected number, got " .. type( _nTimeout ) .. ")", 2 )
error( "bad argument #1 (expected number, got " .. type( _nTimeout ) .. ")", 2 )
end
if _bDebug ~= nil and type( _bDebug ) ~= "boolean" then
error( "bad argument #2 (expected boolean, got " .. type( _bDebug) .. ")", 2 )
error( "bad argument #2 (expected boolean, got " .. type( _bDebug) .. ")", 2 )
end
-- Let command computers use their magic fourth-wall-breaking special abilities
if commands then
return commands.getBlockPosition()
end
-- Find a modem
local sModemSide = nil
for n,sSide in ipairs( rs.getSides() ) do
if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then
sModemSide = sSide
break
end
end
-- Find a modem
local sModemSide = nil
for n,sSide in ipairs( rs.getSides() ) do
if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then
sModemSide = sSide
break
end
end
if sModemSide == nil then
if _bDebug then
print( "No wireless modem attached" )
end
return nil
end
if _bDebug then
print( "Finding position..." )
end
-- Open a channel
local modem = peripheral.wrap( sModemSide )
local bCloseChannel = false
if not modem.isOpen( os.getComputerID() ) then
modem.open( os.getComputerID() )
bCloseChannel = true
end
-- Send a ping to listening GPS hosts
modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" )
-- Wait for the responses
local tFixes = {}
local pos1, pos2 = nil, nil
local timeout = os.startTimer( _nTimeout or 2 )
while true do
local e, p1, p2, p3, p4, p5 = os.pullEvent()
if e == "modem_message" then
-- We received a reply from a modem
local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5
if sSide == sModemSide and sChannel == os.getComputerID() and sReplyChannel == CHANNEL_GPS and nDistance then
-- Received the correct message from the correct modem: use it to determine position
if type(tMessage) == "table" and #tMessage == 3 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then
local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance }
if _bDebug then
print( tFix.nDistance.." metres from "..tostring( tFix.vPosition ) )
end
if tFix.nDistance == 0 then
pos1, pos2 = tFix.vPosition, nil
else
if sModemSide == nil then
if _bDebug then
print( "No wireless modem attached" )
end
return nil
end
if _bDebug then
print( "Finding position..." )
end
-- Open a channel
local modem = peripheral.wrap( sModemSide )
local bCloseChannel = false
if not modem.isOpen( os.getComputerID() ) then
modem.open( os.getComputerID() )
bCloseChannel = true
end
-- Send a ping to listening GPS hosts
modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" )
-- Wait for the responses
local tFixes = {}
local pos1, pos2 = nil, nil
local timeout = os.startTimer( _nTimeout or 2 )
while true do
local e, p1, p2, p3, p4, p5 = os.pullEvent()
if e == "modem_message" then
-- We received a reply from a modem
local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5
if sSide == sModemSide and sChannel == os.getComputerID() and sReplyChannel == CHANNEL_GPS and nDistance then
-- Received the correct message from the correct modem: use it to determine position
if type(tMessage) == "table" and #tMessage == 3 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then
local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance }
if _bDebug then
print( tFix.nDistance.." metres from "..tostring( tFix.vPosition ) )
end
if tFix.nDistance == 0 then
pos1, pos2 = tFix.vPosition, nil
else
table.insert( tFixes, tFix )
if #tFixes >= 3 then
if not pos1 then
@ -126,43 +125,43 @@ function locate( _nTimeout, _bDebug )
end
end
end
if pos1 and not pos2 then
break
end
end
end
elseif e == "timer" then
-- We received a timeout
local timer = p1
if timer == timeout then
break
end
end
end
-- Close the channel, if we opened one
if bCloseChannel then
modem.close( os.getComputerID() )
end
-- Return the response
if pos1 and pos2 then
if _bDebug then
print( "Ambiguous position" )
print( "Could be "..pos1.x..","..pos1.y..","..pos1.z.." or "..pos2.x..","..pos2.y..","..pos2.z )
end
return nil
elseif pos1 then
if _bDebug then
print( "Position is "..pos1.x..","..pos1.y..","..pos1.z )
end
return pos1.x, pos1.y, pos1.z
else
if _bDebug then
print( "Could not determine position" )
end
return nil
end
if pos1 and not pos2 then
break
end
end
end
elseif e == "timer" then
-- We received a timeout
local timer = p1
if timer == timeout then
break
end
end
end
-- Close the channel, if we opened one
if bCloseChannel then
modem.close( os.getComputerID() )
end
-- Return the response
if pos1 and pos2 then
if _bDebug then
print( "Ambiguous position" )
print( "Could be "..pos1.x..","..pos1.y..","..pos1.z.." or "..pos2.x..","..pos2.y..","..pos2.z )
end
return nil
elseif pos1 then
if _bDebug then
print( "Position is "..pos1.x..","..pos1.y..","..pos1.z )
end
return pos1.x, pos1.y, pos1.z
else
if _bDebug then
print( "Could not determine position" )
end
return nil
end
end

View File

@ -2,69 +2,69 @@
local sPath = "/rom/help"
function path()
return sPath
return sPath
end
function setPath( _sPath )
if type( _sPath ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 )
end
sPath = _sPath
sPath = _sPath
end
function lookup( _sTopic )
if type( _sTopic ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sTopic ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sTopic ) .. ")", 2 )
end
-- Look on the path variable
-- Look on the path variable
for sPath in string.gmatch(sPath, "[^:]+") do
sPath = fs.combine( sPath, _sTopic )
if fs.exists( sPath ) and not fs.isDir( sPath ) then
return sPath
sPath = fs.combine( sPath, _sTopic )
if fs.exists( sPath ) and not fs.isDir( sPath ) then
return sPath
elseif fs.exists( sPath..".txt" ) and not fs.isDir( sPath..".txt" ) then
return sPath..".txt"
end
return sPath..".txt"
end
end
-- Not found
return nil
-- Not found
return nil
end
function topics()
-- Add index
local tItems = {
[ "index" ] = true
}
-- Add topics from the path
local tItems = {
[ "index" ] = true
}
-- Add topics from the path
for sPath in string.gmatch(sPath, "[^:]+") do
if fs.isDir( sPath ) then
local tList = fs.list( sPath )
for n,sFile in pairs( tList ) do
if string.sub( sFile, 1, 1 ) ~= "." then
if not fs.isDir( fs.combine( sPath, sFile ) ) then
if fs.isDir( sPath ) then
local tList = fs.list( sPath )
for n,sFile in pairs( tList ) do
if string.sub( sFile, 1, 1 ) ~= "." then
if not fs.isDir( fs.combine( sPath, sFile ) ) then
if #sFile > 4 and sFile:sub(-4) == ".txt" then
sFile = sFile:sub(1,-5)
end
tItems[ sFile ] = true
end
end
end
end
end
tItems[ sFile ] = true
end
end
end
end
end
-- Sort and return
local tItemList = {}
for sItem, b in pairs( tItems ) do
table.insert( tItemList, sItem )
end
table.sort( tItemList )
return tItemList
-- Sort and return
local tItemList = {}
for sItem, b in pairs( tItems ) do
table.insert( tItemList, sItem )
end
table.sort( tItemList )
return tItemList
end
function completeTopic( sText )
if type( sText ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sText ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( sText ) .. ")", 2 )
end
local tTopics = topics()
local tResults = {}
@ -74,7 +74,5 @@ function completeTopic( sText )
table.insert( tResults, string.sub( sTopic, #sText + 1 ) )
end
end
return tResults
return tResults
end

View File

@ -191,7 +191,7 @@ function lines(_sFileName)
local ok, err = open(_sFileName, "rb")
if not ok then error(err, 2) end
-- We set this magic flag to mark this file as being opened by io.lines and so should be
-- We set this magic flag to mark this file as being opened by io.lines and so should be
-- closed automatically
ok._autoclose = true
return ok:lines()

View File

@ -3,54 +3,54 @@
-- See http://www.minecraftwiki.net/wiki/Key_codes for more info
local tKeys = {
nil, "one", "two", "three", "four", -- 1
"five", "six", "seven", "eight", "nine", -- 6
"zero", "minus", "equals", "backspace","tab", -- 11
"q", "w", "e", "r", "t", -- 16
"y", "u", "i", "o", "p", -- 21
"leftBracket","rightBracket","enter","leftCtrl","a", -- 26
"s", "d", "f", "g", "h", -- 31
"j", "k", "l", "semiColon","apostrophe", -- 36
"grave", "leftShift","backslash","z", "x", -- 41
"c", "v", "b", "n", "m", -- 46
"comma", "period", "slash", "rightShift","multiply", -- 51
"leftAlt", "space", "capsLock", "f1", "f2", -- 56
"f3", "f4", "f5", "f6", "f7", -- 61
"f8", "f9", "f10", "numLock", "scrollLock", -- 66
"numPad7", "numPad8", "numPad9", "numPadSubtract","numPad4", -- 71
"numPad5", "numPad6", "numPadAdd","numPad1", "numPad2", -- 76
"numPad3", "numPad0", "numPadDecimal",nil, nil, -- 81
nil, "f11", "f12", nil, nil, -- 86
nil, nil, nil, nil, nil, -- 91
nil, nil, nil, nil, "f13", -- 96
"f14", "f15", nil, nil, nil, -- 101
nil, nil, nil, nil, nil, -- 106
nil, "kana", nil, nil, nil, -- 111
nil, nil, nil, nil, nil, -- 116
"convert", nil, "noconvert",nil, "yen", -- 121
nil, nil, nil, nil, nil, -- 126
nil, nil, nil, nil, nil, -- 131
nil, nil, nil, nil, nil, -- 136
"numPadEquals",nil, nil, "circumflex","at", -- 141
"colon", "underscore","kanji", "stop", "ax", -- 146
nil, nil, nil, nil, nil, -- 151
"numPadEnter","rightCtrl",nil, nil, nil, -- 156
nil, nil, nil, nil, nil, -- 161
nil, nil, nil, nil, nil, -- 166
nil, nil, nil, nil, nil, -- 171
nil, nil, nil, "numPadComma",nil, -- 176
"numPadDivide",nil, nil, "rightAlt", nil, -- 181
nil, nil, nil, nil, nil, -- 186
nil, nil, nil, nil, nil, -- 191
nil, "pause", nil, "home", "up", -- 196
"pageUp", nil, "left", nil, "right", -- 201
nil, "end", "down", "pageDown", "insert", -- 206
"delete" -- 211
nil, "one", "two", "three", "four", -- 1
"five", "six", "seven", "eight", "nine", -- 6
"zero", "minus", "equals", "backspace","tab", -- 11
"q", "w", "e", "r", "t", -- 16
"y", "u", "i", "o", "p", -- 21
"leftBracket","rightBracket","enter","leftCtrl","a", -- 26
"s", "d", "f", "g", "h", -- 31
"j", "k", "l", "semiColon","apostrophe", -- 36
"grave", "leftShift","backslash","z", "x", -- 41
"c", "v", "b", "n", "m", -- 46
"comma", "period", "slash", "rightShift","multiply", -- 51
"leftAlt", "space", "capsLock", "f1", "f2", -- 56
"f3", "f4", "f5", "f6", "f7", -- 61
"f8", "f9", "f10", "numLock", "scrollLock", -- 66
"numPad7", "numPad8", "numPad9", "numPadSubtract","numPad4", -- 71
"numPad5", "numPad6", "numPadAdd","numPad1", "numPad2", -- 76
"numPad3", "numPad0", "numPadDecimal",nil, nil, -- 81
nil, "f11", "f12", nil, nil, -- 86
nil, nil, nil, nil, nil, -- 91
nil, nil, nil, nil, "f13", -- 96
"f14", "f15", nil, nil, nil, -- 101
nil, nil, nil, nil, nil, -- 106
nil, "kana", nil, nil, nil, -- 111
nil, nil, nil, nil, nil, -- 116
"convert", nil, "noconvert",nil, "yen", -- 121
nil, nil, nil, nil, nil, -- 126
nil, nil, nil, nil, nil, -- 131
nil, nil, nil, nil, nil, -- 136
"numPadEquals",nil, nil, "circumflex","at", -- 141
"colon", "underscore","kanji", "stop", "ax", -- 146
nil, nil, nil, nil, nil, -- 151
"numPadEnter","rightCtrl",nil, nil, nil, -- 156
nil, nil, nil, nil, nil, -- 161
nil, nil, nil, nil, nil, -- 166
nil, nil, nil, nil, nil, -- 171
nil, nil, nil, "numPadComma",nil, -- 176
"numPadDivide",nil, nil, "rightAlt", nil, -- 181
nil, nil, nil, nil, nil, -- 186
nil, nil, nil, nil, nil, -- 191
nil, "pause", nil, "home", "up", -- 196
"pageUp", nil, "left", nil, "right", -- 201
nil, "end", "down", "pageDown", "insert", -- 206
"delete" -- 211
}
local keys = _ENV
for nKey, sKey in pairs( tKeys ) do
keys[sKey] = nKey
keys[sKey] = nKey
end
keys["return"] = keys.enter
--backwards compatibility to earlier, typo prone, versions
@ -59,7 +59,7 @@ keys.cimcumflex = keys.circumflex
function getName( _nKey )
if type( _nKey ) ~= "number" then
error( "bad argument #1 (expected number, got " .. type( _nKey ) .. ")", 2 )
error( "bad argument #1 (expected number, got " .. type( _nKey ) .. ")", 2 )
end
return tKeys[ _nKey ]
return tKeys[ _nKey ]
end

View File

@ -58,7 +58,7 @@ function drawLine( startX, startY, endX, endY, nColour )
if type( endX ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( endX ) .. ")", 2 ) end
if type( endY ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( endY ) .. ")", 2 ) end
if nColour ~= nil and type( nColour ) ~= "number" then error( "bad argument #5 (expected number, got " .. type( nColour ) .. ")", 2 ) end
startX = math.floor(startX)
startY = math.floor(startY)
endX = math.floor(endX)
@ -71,7 +71,7 @@ function drawLine( startX, startY, endX, endY, nColour )
drawPixelInternal( startX, startY )
return
end
local minX = math.min( startX, endX )
local maxX, minY, maxY
if minX == startX then
@ -85,10 +85,10 @@ function drawLine( startX, startY, endX, endY, nColour )
end
-- TODO: clip to screen rectangle?
local xDiff = maxX - minX
local yDiff = maxY - minY
if xDiff > math.abs(yDiff) then
local y = minY
local dy = yDiff / xDiff
@ -134,7 +134,7 @@ function drawBox( startX, startY, endX, endY, nColour )
end
local minX = math.min( startX, endX )
local maxX, minY, maxY
local maxX, minY, maxY
if minX == startX then
minY = startY
maxX = endX

View File

@ -4,54 +4,54 @@ local function create( ... )
local tCos = {}
for i = 1, tFns.n, 1 do
local fn = tFns[i]
if type( fn ) ~= "function" then
error( "bad argument #" .. i .. " (expected function, got " .. type( fn ) .. ")", 3 )
if type( fn ) ~= "function" then
error( "bad argument #" .. i .. " (expected function, got " .. type( fn ) .. ")", 3 )
end
tCos[i] = coroutine.create(fn)
end
return tCos
end
local function runUntilLimit( _routines, _limit )
local count = #_routines
local living = count
local tFilters = {}
local eventData = { n = 0 }
while true do
for n=1,count do
local r = _routines[n]
if r then
if tFilters[r] == nil or tFilters[r] == eventData[1] or eventData[1] == "terminate" then
local ok, param = coroutine.resume( r, table.unpack( eventData, 1, eventData.n ) )
if not ok then
error( param, 0 )
else
tFilters[r] = param
end
if coroutine.status( r ) == "dead" then
_routines[n] = nil
living = living - 1
if living <= _limit then
return n
end
end
end
end
end
for n=1,count do
local r = _routines[n]
if r and coroutine.status( r ) == "dead" then
_routines[n] = nil
living = living - 1
if living <= _limit then
return n
end
end
end
eventData = table.pack( os.pullEventRaw() )
for n=1,count do
local r = _routines[n]
if r then
if tFilters[r] == nil or tFilters[r] == eventData[1] or eventData[1] == "terminate" then
local ok, param = coroutine.resume( r, table.unpack( eventData, 1, eventData.n ) )
if not ok then
error( param, 0 )
else
tFilters[r] = param
end
if coroutine.status( r ) == "dead" then
_routines[n] = nil
living = living - 1
if living <= _limit then
return n
end
end
end
end
end
for n=1,count do
local r = _routines[n]
if r and coroutine.status( r ) == "dead" then
_routines[n] = nil
living = living - 1
if living <= _limit then
return n
end
end
end
eventData = table.pack( os.pullEventRaw() )
end
end
@ -62,5 +62,5 @@ end
function waitForAll( ... )
local routines = create( ... )
runUntilLimit( routines, 0 )
runUntilLimit( routines, 0 )
end

View File

@ -1,70 +1,70 @@
local native = peripheral
function getNames()
local tResults = {}
for n,sSide in ipairs( rs.getSides() ) do
if native.isPresent( sSide ) then
table.insert( tResults, sSide )
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
local tRemote = native.call( sSide, "getNamesRemote" )
for n,sName in ipairs( tRemote ) do
table.insert( tResults, sName )
end
end
end
end
return tResults
local tResults = {}
for n,sSide in ipairs( rs.getSides() ) do
if native.isPresent( sSide ) then
table.insert( tResults, sSide )
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
local tRemote = native.call( sSide, "getNamesRemote" )
for n,sName in ipairs( tRemote ) do
table.insert( tResults, sName )
end
end
end
end
return tResults
end
function isPresent( _sSide )
if type( _sSide ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 )
end
if native.isPresent( _sSide ) then
return true
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return true
end
end
end
return false
if native.isPresent( _sSide ) then
return true
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return true
end
end
end
return false
end
function getType( _sSide )
if type( _sSide ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 )
end
if native.isPresent( _sSide ) then
return native.getType( _sSide )
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return native.call( sSide, "getTypeRemote", _sSide )
end
end
end
return nil
if native.isPresent( _sSide ) then
return native.getType( _sSide )
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return native.call( sSide, "getTypeRemote", _sSide )
end
end
end
return nil
end
function getMethods( _sSide )
if type( _sSide ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 )
end
if native.isPresent( _sSide ) then
return native.getMethods( _sSide )
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return native.call( sSide, "getMethodsRemote", _sSide )
end
end
end
return nil
if native.isPresent( _sSide ) then
return native.getMethods( _sSide )
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return native.call( sSide, "getMethodsRemote", _sSide )
end
end
end
return nil
end
function call( _sSide, _sMethod, ... )
@ -74,34 +74,34 @@ function call( _sSide, _sMethod, ... )
if type( _sSide ) ~= "string" then
error( "bad argument #2 (expected string, got " .. type( _sMethod ) .. ")", 2 )
end
if native.isPresent( _sSide ) then
return native.call( _sSide, _sMethod, ... )
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return native.call( sSide, "callRemote", _sSide, _sMethod, ... )
end
end
end
return nil
if native.isPresent( _sSide ) then
return native.call( _sSide, _sMethod, ... )
end
for n,sSide in ipairs( rs.getSides() ) do
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
if native.call( sSide, "isPresentRemote", _sSide ) then
return native.call( sSide, "callRemote", _sSide, _sMethod, ... )
end
end
end
return nil
end
function wrap( _sSide )
if type( _sSide ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 )
end
if peripheral.isPresent( _sSide ) then
local tMethods = peripheral.getMethods( _sSide )
local tResult = {}
for n,sMethod in ipairs( tMethods ) do
tResult[sMethod] = function( ... )
return peripheral.call( _sSide, sMethod, ... )
end
end
return tResult
end
return nil
if peripheral.isPresent( _sSide ) then
local tMethods = peripheral.getMethods( _sSide )
local tResult = {}
for n,sMethod in ipairs( tMethods ) do
tResult[sMethod] = function( ... )
return peripheral.call( _sSide, sMethod, ... )
end
end
return tResult
end
return nil
end
function find( sType, fnFilter )
@ -111,14 +111,14 @@ function find( sType, fnFilter )
if fnFilter ~= nil and type( fnFilter ) ~= "function" then
error( "bad argument #2 (expected function, got " .. type( fnFilter ) .. ")", 2 )
end
local tResults = {}
for n,sName in ipairs( peripheral.getNames() ) do
if peripheral.getType( sName ) == sType then
local wrapped = peripheral.wrap( sName )
if fnFilter == nil or fnFilter( sName, wrapped ) then
table.insert( tResults, wrapped )
end
end
end
return table.unpack( tResults )
local tResults = {}
for n,sName in ipairs( peripheral.getNames() ) do
if peripheral.getType( sName ) == sType then
local wrapped = peripheral.wrap( sName )
if fnFilter == nil or fnFilter( sName, wrapped ) then
table.insert( tResults, wrapped )
end
end
end
return table.unpack( tResults )
end

View File

@ -10,7 +10,7 @@ function open( sModem )
if type( sModem ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sModem ) .. ")", 2 )
end
if peripheral.getType( sModem ) ~= "modem" then
if peripheral.getType( sModem ) ~= "modem" then
error( "No such modem: "..sModem, 2 )
end
peripheral.call( sModem, "open", os.getComputerID() )
@ -244,7 +244,7 @@ function run()
error( "rednet is already running", 2 )
end
bRunning = true
while bRunning do
local sEvent, p1, p2, p3, p4 = os.pullEventRaw()
if sEvent == "modem_message" then

View File

@ -3,10 +3,10 @@ local tSettings = {}
function set( sName, value )
if type( sName ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) end
local sValueTy = type(value)
if sValueTy ~= "number" and sValueTy ~= "string" and sValueTy ~= "boolean" and sValueTy ~= "table" then
error( "bad argument #2 (expected value, got " .. sValueTy .. ")", 2 )
if sValueTy ~= "number" and sValueTy ~= "string" and sValueTy ~= "boolean" and sValueTy ~= "table" then
error( "bad argument #2 (expected value, got " .. sValueTy .. ")", 2 )
end
if sValueTy == "table" then
-- Ensure value is serializeable
@ -30,7 +30,7 @@ end
function get( sName, default )
if type(sName) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 )
end
local result = tSettings[ sName ]
if result ~= nil then
@ -42,7 +42,7 @@ end
function unset( sName )
if type(sName) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 )
end
tSettings[ sName ] = nil
end
@ -62,7 +62,7 @@ end
function load( sPath )
if type(sPath) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 )
end
local file = fs.open( sPath, "r" )
if not file then
@ -89,7 +89,7 @@ end
function save( sPath )
if type(sPath) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 )
error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 )
end
local file = fs.open( sPath, "w" )
if not file then

View File

@ -3,32 +3,32 @@ local native = (term.native and term.native()) or term
local redirectTarget = native
local function wrap( _sFunction )
return function( ... )
return redirectTarget[ _sFunction ]( ... )
end
return function( ... )
return redirectTarget[ _sFunction ]( ... )
end
end
local term = {}
term.redirect = function( target )
if type( target ) ~= "table" then
error( "bad argument #1 (expected table, got " .. type( target ) .. ")", 2 )
error( "bad argument #1 (expected table, got " .. type( target ) .. ")", 2 )
end
if target == term then
error( "term is not a recommended redirect target, try term.current() instead", 2 )
end
for k,v in pairs( native ) do
if type( k ) == "string" and type( v ) == "function" then
if type( target[k] ) ~= "function" then
target[k] = function()
error( "Redirect object is missing method "..k..".", 2 )
end
end
end
end
local oldRedirectTarget = redirectTarget
redirectTarget = target
return oldRedirectTarget
for k,v in pairs( native ) do
if type( k ) == "string" and type( v ) == "function" then
if type( target[k] ) ~= "function" then
target[k] = function()
error( "Redirect object is missing method "..k..".", 2 )
end
end
end
end
local oldRedirectTarget = redirectTarget
redirectTarget = target
return oldRedirectTarget
end
term.current = function()
@ -43,14 +43,14 @@ term.native = function()
end
for k,v in pairs( native ) do
if type( k ) == "string" and type( v ) == "function" then
if term[k] == nil then
term[k] = wrap( k )
end
end
if type( k ) == "string" and type( v ) == "function" then
if term[k] == nil then
term[k] = wrap( k )
end
end
end
local env = _ENV
for k,v in pairs( term ) do
env[k] = v
env[k] = v
end

View File

@ -8,11 +8,11 @@ function slowWrite( sText, nRate )
error( "Rate must be positive", 2 )
end
local nSleep = 1 / nRate
sText = tostring( sText )
local x,y = term.getCursorPos()
local len = string.len( sText )
for n=1,len do
term.setCursorPos( x, y )
sleep( nSleep )
@ -32,7 +32,7 @@ function formatTime( nTime, bTwentyFourHour )
error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 )
end
if bTwentyFourHour ~= nil and type( bTwentyFourHour ) ~= "boolean" then
error( "bad argument #2 (expected boolean, got " .. type( bTwentyFourHour ) .. ")", 2 )
error( "bad argument #2 (expected boolean, got " .. type( bTwentyFourHour ) .. ")", 2 )
end
local sTOD = nil
if not bTwentyFourHour then
@ -61,7 +61,7 @@ local function makePagedScroll( _term, _nFreeLines )
return function( _n )
for n=1,_n do
nativeScroll( 1 )
if nFreeLines <= 0 then
local w,h = _term.getSize()
_term.setCursorPos( 1, h )
@ -78,7 +78,7 @@ end
function pagedPrint( _sText, _nFreeLines )
if _nFreeLines ~= nil and type( _nFreeLines ) ~= "number" then
error( "bad argument #2 (expected number, got " .. type( _nFreeLines ) .. ")", 2 )
error( "bad argument #2 (expected number, got " .. type( _nFreeLines ) .. ")", 2 )
end
-- Setup a redirector
local oldTerm = term.current()
@ -113,17 +113,17 @@ local function tabulateCommon( bPaged, ... )
local tAll = { ... }
for k,v in ipairs( tAll ) do
if type( v ) ~= "number" and type( v ) ~= "table" then
error( "bad argument #"..k.." (expected number or table, got " .. type( v ) .. ")", 3 )
error( "bad argument #"..k.." (expected number or table, got " .. type( v ) .. ")", 3 )
end
end
local w,h = term.getSize()
local nMaxLen = w / 8
for n, t in ipairs( tAll ) do
if type(t) == "table" then
for nu, sItem in pairs(t) do
if type( sItem ) ~= "string" then
error( "bad argument #"..n.."."..nu.." (expected string, got " .. type( sItem ) .. ")", 3 )
error( "bad argument #"..n.."."..nu.." (expected string, got " .. type( sItem ) .. ")", 3 )
end
nMaxLen = math.max( string.len( sItem ) + 1, nMaxLen )
end
@ -139,7 +139,7 @@ local function tabulateCommon( bPaged, ... )
end
nLines = nLines + 1
end
local function drawCols( _t )
local nCol = 1
for n, s in ipairs( _t ) do
@ -153,7 +153,7 @@ local function tabulateCommon( bPaged, ... )
term.setCursorPos( cx, cy )
term.write( s )
nCol = nCol + 1
nCol = nCol + 1
end
print()
end
@ -165,7 +165,7 @@ local function tabulateCommon( bPaged, ... )
elseif type(t) == "number" then
term.setTextColor( t )
end
end
end
end
function tabulate( ... )
@ -234,16 +234,16 @@ local function serializeImpl( t, tTracking, sIndent )
sResult = sResult .. sIndent .. "}"
return sResult
end
elseif sType == "string" then
return string.format( "%q", t )
elseif sType == "number" or sType == "boolean" or sType == "nil" then
return tostring(t)
else
error( "Cannot serialize type "..sType, 0 )
end
end
@ -365,7 +365,7 @@ function urlEncode( str )
end )
str = string.gsub(str, " ", "+")
end
return str
return str
end
local tEmpty = {}
@ -403,7 +403,7 @@ function complete( sSearchText, tSearchTable )
return tEmpty
end
end
local sPart = string.sub( sSearchText, nStart )
local nPartLength = string.len( sPart )

View File

@ -1,6 +1,6 @@
if not turtle then
error( "Cannot load turtle API on computer", 2 )
error( "Cannot load turtle API on computer", 2 )
end
native = turtle.native or turtle
@ -28,7 +28,7 @@ for k,v in pairs( native ) do
return result, err
end
else
env[k] = v
env[k] = v
end
end
addCraftMethod( env )

View File

@ -84,11 +84,11 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
parent.setCursorPos( 0, 0 )
end
end
local function updateCursorBlink()
parent.setCursorBlink( bCursorBlink )
end
local function updateCursorColor()
parent.setTextColor( nTextColor )
end
@ -275,7 +275,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end
local function setTextColor( color )
if type( color ) ~= "number" then
if type( color ) ~= "number" then
error( "bad argument #1 (expected number, got " .. type( color ) .. ")", 2 )
elseif tHex[color] == nil then
error( "Invalid color (got " .. color .. ")" , 2 )
@ -291,7 +291,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
function window.setPaletteColour( colour, r, g, b )
if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end
if tHex[colour] == nil then
error( "Invalid color (got " .. colour .. ")" , 2 )
end
@ -304,7 +304,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
if type( r ) ~= "number" then error( "bad argument #2 (expected number, got " .. type( r ) .. ")", 2 ) end
if type( g ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( g ) .. ")", 2 ) end
if type( b ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( b ) .. ")", 2 ) end
tCol = tPalette[ colour ]
tCol[1] = r
tCol[2] = g

View File

@ -1,6 +1,6 @@
alias assigns shell commands to run other programs.
ex:
"alias dir ls" will make the "dir" command run the "ls" program
alias assigns shell commands to run other programs.
ex:
"alias dir ls" will make the "dir" command run the "ls" program
"alias dir" will remove the alias set on "dir"
"alias" will list all current aliases.

View File

@ -1,6 +1,6 @@
The set program can be used to inspect and change system settings.
Usage:
"set" will print all the system settings and their values
"set foo" will print the value of the system setting "foo"
"set foo bar" will set the value of the system setting "foo" to "bar"
The set program can be used to inspect and change system settings.
Usage:
"set" will print all the system settings and their values
"set foo" will print the value of the system setting "foo"
"set foo bar" will set the value of the system setting "foo" to "bar"

View File

@ -24,4 +24,3 @@ else
table.sort( tList )
textutils.pagedTabulate( tList )
end

View File

@ -77,7 +77,7 @@ local function load( _sPath )
end
file:close()
end
if #tLines == 0 then
table.insert( tLines, "" )
end
@ -91,7 +91,7 @@ local function save( _sPath )
end
-- Save
local file = nil
local file, fileerr
local function innerSave()
file, fileerr = fs.open( _sPath, "w" )
if file then
@ -102,9 +102,9 @@ local function save( _sPath )
error( "Failed to open ".._sPath )
end
end
local ok, err = pcall( innerSave )
if file then
if file then
file.close()
end
return ok, err, fileerr
@ -150,8 +150,8 @@ local function tryWrite( sLine, regex, colour )
end
local function writeHighlighted( sLine )
while string.len(sLine) > 0 do
sLine =
while string.len(sLine) > 0 do
sLine =
tryWrite( sLine, "^%-%-%[%[.-%]%]", commentColour ) or
tryWrite( sLine, "^%-%-.*", commentColour ) or
tryWrite( sLine, "^\"\"", stringColour ) or
@ -282,7 +282,7 @@ local function redrawMenu()
term.setCursorPos( x - scrollX, y - scrollY )
end
local tMenuFuncs = {
local tMenuFuncs = {
Save = function()
if bReadOnly then
sStatus = "Access denied"
@ -326,9 +326,9 @@ local tMenuFuncs = {
}
printerTerminal.scroll = function()
if nPage == 1 then
printer.setPageTitle( sName.." (page "..nPage..")" )
printer.setPageTitle( sName.." (page "..nPage..")" )
end
while not printer.newPage() do
if printer.getInkLevel() < 1 then
sStatus = "Printer out of ink, please refill"
@ -337,11 +337,11 @@ local tMenuFuncs = {
else
sStatus = "Printer output tray full, please empty"
end
term.redirect( screenTerminal )
redrawMenu()
term.redirect( printerTerminal )
local timer = os.startTimer(0.5)
sleep(0.5)
end
@ -353,7 +353,7 @@ local tMenuFuncs = {
printer.setPageTitle( sName.." (page "..nPage..")" )
end
end
bMenu = false
term.redirect( printerTerminal )
local ok, error = pcall( function()
@ -366,14 +366,14 @@ local tMenuFuncs = {
if not ok then
print( error )
end
while not printer.endPage() do
sStatus = "Printer output tray full, please empty"
redrawMenu()
sleep( 0.5 )
end
bMenu = true
if nPage > 1 then
sStatus = "Printed "..nPage.." Pages"
else
@ -416,7 +416,7 @@ local function setCursor( newX, newY )
x, y = newX, newY
local screenX = x - scrollX
local screenY = y - scrollY
local bRedraw = false
if screenX < 1 then
scrollX = x - 1
@ -427,7 +427,7 @@ local function setCursor( newX, newY )
screenX = w
bRedraw = true
end
if screenY < 1 then
scrollY = y - 1
screenY = 1
@ -694,7 +694,7 @@ while bRunning do
redrawMenu()
end
elseif sEvent == "char" then
if not bMenu and not bReadOnly then
-- Input text
@ -725,7 +725,7 @@ while bRunning do
tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
setCursor( x + string.len( param ), y )
end
elseif sEvent == "mouse_click" then
if not bMenu then
if param == 1 then
@ -738,7 +738,7 @@ while bRunning do
end
end
end
elseif sEvent == "mouse_scroll" then
if not bMenu then
if param == -1 then
@ -748,7 +748,7 @@ while bRunning do
scrollY = scrollY - 1
redrawText()
end
elseif param == 1 then
-- Scroll down
local nMaxScroll = #tLines - (h-1)
@ -757,7 +757,7 @@ while bRunning do
scrollY = scrollY + 1
redrawText()
end
end
end
@ -774,4 +774,3 @@ end
term.clear()
term.setCursorBlink( false )
term.setCursorPos( 1, 1 )

View File

@ -78,7 +78,7 @@ local function getCharOf( colour )
end
end
return " "
end
end
--[[
Converts a text character to colour value
@ -94,7 +94,7 @@ local function getColourOf( char )
return tColourLookup[char]
end
--[[
--[[
Loads the file into the canvas
params: path = the path of the file to open
returns: nil
@ -116,8 +116,8 @@ local function load(path)
end
end
--[[
Saves the current canvas to file
--[[
Saves the current canvas to file
params: path = the path of the file to save
returns: true if save was successful, false otherwise
]]
@ -161,7 +161,7 @@ local function save(path)
return true
end
--[[
--[[
Draws colour picker sidebar, the pallette and the footer
returns: nil
]]
@ -172,7 +172,7 @@ local function drawInterface()
term.setTextColour(colours.yellow)
term.clearLine()
term.write(fMessage)
-- Colour Picker
for i=1,16 do
term.setCursorPos(w-1, i)
@ -184,7 +184,7 @@ local function drawInterface()
term.setBackgroundColour( canvasColour )
term.setTextColour( colours.grey )
term.write("\127\127")
-- Left and Right Selected Colours
for i=18,18 do
term.setCursorPos(w-1, i)
@ -214,7 +214,7 @@ local function drawInterface()
end
end
--[[
--[[
Converts a single pixel of a single line of the canvas and draws it
returns: nil
]]
@ -232,7 +232,7 @@ local function drawCanvasPixel( x, y )
end
end
--[[
--[[
Converts each colour in a single line of the canvas and draws it
returns: nil
]]
@ -242,7 +242,7 @@ local function drawCanvasLine( y )
end
end
--[[
--[[
Converts each colour in the canvas and draws it
returns: nil
]]
@ -259,7 +259,7 @@ end
local function accessMenu()
-- Selected menu option
local selection = 1
term.setBackgroundColour(colours.black)
while true do
-- Draw the menu
@ -267,7 +267,7 @@ local function accessMenu()
term.clearLine()
term.setTextColour(colours.white)
for k,v in pairs(mChoices) do
if selection==k then
if selection==k then
term.setTextColour(colours.yellow)
local ox,_ = term.getCursorPos()
term.write("["..string.rep(" ",#v).."]")
@ -279,7 +279,7 @@ local function accessMenu()
term.write(" "..v.." ")
end
end
-- Handle input in the menu
local id,key = os.pullEvent("key")
if id == "key" then
@ -291,25 +291,25 @@ local function accessMenu()
selection = 2
key = keys.enter
end
if key == keys.right then
-- Move right
selection = selection + 1
if selection > #mChoices then
selection = 1
end
elseif key == keys.left and selection > 1 then
-- Move left
selection = selection - 1
if selection < 1 then
selection = #mChoices
end
elseif key == keys.enter then
-- Select an option
if mChoices[selection]=="Save" then
if bReadOnly then
if mChoices[selection]=="Save" then
if bReadOnly then
fMessage = "Access denied"
return false
end
@ -324,18 +324,18 @@ local function accessMenu()
end
end
return false
elseif mChoices[selection]=="Exit" then
elseif mChoices[selection]=="Exit" then
return true
end
elseif key == keys.leftCtrl or keys == keys.rightCtrl then
-- Cancel the menu
return false
return false
end
end
end
end
--[[
--[[
Runs the main thread of execution. Draws the canvas and interface, and handles
mouse and key events.
returns: nil
@ -405,4 +405,3 @@ term.setBackgroundColour(colours.black)
term.setTextColour(colours.white)
term.clear()
term.setCursorPos(1,1)

View File

@ -266,7 +266,7 @@ end
local function drawMap()
for x=1,SizeW do
for y=1,SizeH do
local obj = tScreen[x][y]
if obj.ground == true then
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cG)
@ -274,7 +274,7 @@ local function drawMap()
if obj.wall == true then
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cW)
end
local ex = tostring(tScreen[x][y].exit)
if not(ex == "zz" or ex == "nil") then
if ex == "a" then
@ -293,7 +293,7 @@ local function drawMap()
term.setCursorPos(XOrgin+x,YOrgin+y+1)
print("X")
end
local st = tostring(tScreen[x][y].start)
if not(st == "zz" or st == "nil") then
local Cr = string.sub(st,2,2)
@ -308,11 +308,11 @@ local function drawMap()
else
return error("Start Color Out")
end
term.setTextColor(Cr)
term.setBackgroundColor(cG)
term.setCursorPos(XOrgin+x,YOrgin+y+1)
local sSide = string.sub(st,1,1)
if sSide == "a" then
print("^")
@ -326,11 +326,11 @@ local function drawMap()
print("@")
end
end
if obj.space == true then
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cS)
end
local rb = tostring(tScreen[x][y].robot)
if not(rb == "zz" or rb == "nil") then
local Cr = string.sub(rb,2,2)
@ -516,13 +516,13 @@ function InterFace.drawBar()
term.setBackgroundColor( colors.black )
term.setTextColor( InterFace.cTitle )
printCentred( 1, " "..sLevelTitle.." " )
term.setCursorPos(1,1)
term.setBackgroundColor( cW )
write( " " )
term.setBackgroundColor( colors.black )
write( " x "..tostring(Blocks).." " )
term.setCursorPos( TermW-8,TermH )
term.setBackgroundColor( colors.black )
term.setTextColour(InterFace.cSpeedD)
@ -601,12 +601,12 @@ local function startG(LevelN)
InterFace.drawBar()
gRender("start")
drawMap()
local NExit = true
if aExits == 0 then
NExit = false
end
while true do
local isExit = InterFace.render()
if isExit == "end" then

View File

@ -279,7 +279,7 @@ local tRecipes = {
["a crafting table"] = { "some planks" },
["a furnace"] = { "some stone" },
["some torches"] = { "some sticks", "some coal" },
["a wooden pickaxe"] = { "some planks", "some sticks" },
["a stone pickaxe"] = { "some stone", "some sticks" },
["an iron pickaxe"] = { "some iron", "some sticks" },
@ -355,14 +355,14 @@ local function getRoom( x, y, z, dontCreate )
nMonsters = 0,
}
tMap[x][y][z] = room
if y == 0 then
-- Room is above ground
-- Pick biome
room.nBiome = math.random( 1, #tBiomes )
room.trees = hasTrees( room.nBiome )
-- Add animals
if math.random(1,3) == 1 then
for n = 1,math.random(1,2) do
@ -370,7 +370,7 @@ local function getRoom( x, y, z, dontCreate )
room.items[ sAnimal ] = items[ sAnimal ]
end
end
-- Add surface ore
if math.random(1,5) == 1 or hasStone( room.nBiome ) then
room.items[ "some stone" ] = items[ "some stone" ]
@ -393,7 +393,7 @@ local function getRoom( x, y, z, dontCreate )
room.exits["down"] = true
room.items["a cave entrance"] = items["a cave entrance"]
end
else
-- Room is underground
-- Add exits
@ -409,7 +409,7 @@ local function getRoom( x, y, z, dontCreate )
end
end
end
if y == -1 then
local above = getRoom( x, y + 1, z )
if above.exits["down"] then
@ -419,16 +419,16 @@ local function getRoom( x, y, z, dontCreate )
else
tryExit( "up", "down", x, y + 1, z )
end
if y > -3 then
tryExit( "down", "up", x, y - 1, z )
end
tryExit( "east", "west", x - 1, y, z )
tryExit( "west", "east", x + 1, y, z )
tryExit( "north", "south", x, y, z + 1 )
tryExit( "south", "north", x, y, z - 1 )
tryExit( "south", "north", x, y, z - 1 )
-- Add ores
room.items[ "some stone" ] = items[ "some stone" ]
if math.random(1,3) == 1 then
@ -440,7 +440,7 @@ local function getRoom( x, y, z, dontCreate )
if y == -3 and math.random(1,15) == 1 then
room.items[ "some diamond" ] = items[ "some diamond" ]
end
-- Turn out the lights
room.dark = true
end
@ -453,11 +453,11 @@ local function itemize( t )
if item == nil then
return "nothing"
end
local text = ""
while item do
text = text .. item
local nextItem = next( t, item )
if nextItem ~= nil then
local nextNextItem = next( t, nextItem )
@ -611,7 +611,7 @@ local function doCommand( text )
commands[ "noinput" ]()
return
end
for sCommand, t in pairs( tMatches ) do
for n, sMatch in pairs( t ) do
local tCaptures = { string.match( text, "^" .. sMatch .. "$" ) }
@ -659,7 +659,7 @@ function commands.look( _sTarget )
if room.trees then
print( "There are trees here." )
end
else
-- Look at stuff
if room.trees and (_sTarget == "tree" or _sTarget == "trees") then
@ -677,7 +677,7 @@ function commands.look( _sTarget )
tItem = inventory[sItem]
end
end
if tItem then
print( tItem.desc or ("You see nothing special about "..sItem..".") )
else
@ -693,7 +693,7 @@ function commands.go( _sDir )
print( "Go where?" )
return
end
if nGoWest ~= nil then
if _sDir == "west" then
nGoWest = nGoWest + 1
@ -707,12 +707,12 @@ function commands.go( _sDir )
end
end
end
if room.exits[_sDir] == nil then
print( "You can't go that way." )
return
end
if _sDir == "north" then
z = z + 1
elseif _sDir == "south" then
@ -729,7 +729,7 @@ function commands.go( _sDir )
print( "I don't understand that direction." )
return
end
nTimeInRoom = 0
doCommand( "look" )
end
@ -740,7 +740,7 @@ function commands.dig( _sDir, _sTool )
print( "Dig where?" )
return
end
local sTool = nil
local tTool = nil
if _sTool ~= nil then
@ -751,7 +751,7 @@ function commands.dig( _sDir, _sTool )
end
tTool = inventory[ sTool ]
end
local bActuallyDigging = (room.exits[ _sDir ] ~= true)
if bActuallyDigging then
if sTool == nil or tTool.toolType ~= "pick" then
@ -759,7 +759,7 @@ function commands.dig( _sDir, _sTool )
return
end
end
if _sDir == "north" then
room.exits["north"] = true
z = z + 1
@ -769,17 +769,17 @@ function commands.dig( _sDir, _sTool )
room.exits["south"] = true
z = z - 1
getRoom( x, y, z ).exits["north"] = true
elseif _sDir == "east" then
room.exits["east"] = true
x = x - 1
getRoom( x, y, z ).exits["west"] = true
elseif _sDir == "west" then
room.exits["west"] = true
x = x + 1
getRoom( x, y, z ).exits["east"] = true
elseif _sDir == "up" then
if y == 0 then
print( "You can't dig that way." )
@ -791,13 +791,13 @@ function commands.dig( _sDir, _sTool )
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
if y == 0 then
room.items[ "a cave entrance" ] = items[ "a cave entrance" ]
end
elseif _sDir == "down" then
if y <= -3 then
print( "You hit bedrock." )
@ -809,18 +809,18 @@ function commands.dig( _sDir, _sTool )
room.items[ "a cave entrance" ] = items[ "a cave entrance" ]
end
y = y - 1
room = getRoom( x, y, z )
room.exits["up"] = true
if y == -1 then
room.items[ "an exit to the surface" ] = items[ "an exit to the surface" ]
end
else
print( "I don't understand that direction." )
return
end
--
if bActuallyDigging then
if _sDir == "down" and y == -1 or
@ -833,7 +833,7 @@ function commands.dig( _sDir, _sTool )
print( "You dig ".._sDir.." using "..sTool.." and collect some stone." )
end
end
nTimeInRoom = 0
doCommand( "look" )
end
@ -847,7 +847,7 @@ function commands.drop( _sItem )
print( "Drop what?" )
return
end
local room = getRoom( x,y,z )
local sItem = findItem( inventory, _sItem )
if sItem then
@ -869,7 +869,7 @@ function commands.place( _sItem )
print( "Place what?" )
return
end
if _sItem == "torch" or _sItem == "a torch" then
local room = getRoom( x,y,z )
if inventory["some torches"] or inventory["a torch"] then
@ -888,7 +888,7 @@ function commands.place( _sItem )
end
return
end
commands.drop( _sItem )
end
@ -911,7 +911,7 @@ function commands.take( _sItem )
room.items[ sItem ] = nil
end
inventory[ sItem ] = tItem
if inventory["some torches"] and inventory["a torch"] then
inventory["a torch"] = nil
end
@ -935,7 +935,7 @@ function commands.mine( _sItem, _sTool )
if _sTool == nil then
print( "Mine ".._sItem.." with what?" )
return
end
end
commands.cbreak( _sItem, _sTool )
end
@ -952,7 +952,7 @@ function commands.cbreak( _sItem, _sTool )
print( "Break what?" )
return
end
local sTool = nil
if _sTool ~= nil then
sTool = findItem( inventory, _sTool )
@ -977,7 +977,7 @@ function commands.cbreak( _sItem, _sTool )
bRunning = false
return
end
local sItem = findItem( room.items, _sItem )
if sItem then
local tItem = room.items[ sItem ]
@ -1003,7 +1003,7 @@ function commands.cbreak( _sItem, _sTool )
else
print( "You can't break "..sItem.." with "..sTool..".")
end
elseif tItem.creature == true then
-- Fighting monsters (or pigs)
local toolLevel = 0
@ -1014,12 +1014,12 @@ function commands.cbreak( _sItem, _sTool )
toolLevel = tTool.toolLevel
end
end
local tChances = { 0.2, 0.4, 0.55, 0.8, 1 }
if math.random() <= tChances[ toolLevel + 1 ] then
room.items[ sItem ] = nil
print( "The "..tItem.aliases[1].." dies." )
if tItem.drops then
for n, sDrop in pairs( tItem.drops ) do
if not room.items[sDrop] then
@ -1028,14 +1028,14 @@ function commands.cbreak( _sItem, _sTool )
end
end
end
if tItem.monster then
room.nMonsters = room.nMonsters - 1
end
else
print( "The "..tItem.aliases[1].." is injured by your blow." )
end
if tItem.hitDrops then
for n, sDrop in pairs( tItem.hitDrops ) do
if not room.items[sDrop] then
@ -1044,7 +1044,7 @@ function commands.cbreak( _sItem, _sTool )
end
end
end
else
print( "You can't break "..sItem.."." )
end
@ -1058,7 +1058,7 @@ function commands.craft( _sItem )
print( "Craft what?" )
return
end
if _sItem == "computer" or _sItem == "a computer" then
print( "By creating a computer in a computer in a computer, you tear a hole in the spacetime continuum from which no mortal being can escape." )
if term.isColour() then
@ -1070,7 +1070,7 @@ function commands.craft( _sItem )
bRunning = false
return
end
local room = getRoom( x,y,z )
local sItem = findItem( items, _sItem )
local tRecipe = (sItem and tRecipes[ sItem ]) or nil
@ -1081,7 +1081,7 @@ function commands.craft( _sItem )
return
end
end
for n,sReq in ipairs( tRecipe ) do
inventory[sReq] = nil
end
@ -1092,7 +1092,7 @@ function commands.craft( _sItem )
print( "Crafted." )
else
print( "You don't know how to make "..(sItem or _sItem).."." )
end
end
end
function commands.build( _sThing, _sMaterial )
@ -1100,7 +1100,7 @@ function commands.build( _sThing, _sMaterial )
print( "Build what?" )
return
end
local sMaterial = nil
if _sMaterial == nil then
for sItem, tItem in pairs( inventory ) do
@ -1119,18 +1119,18 @@ function commands.build( _sThing, _sMaterial )
print( "You don't have any ".._sMaterial )
return
end
if inventory[sMaterial].material ~= true then
print( sMaterial.." is not a good building material." )
return
end
end
local alias = nil
if string.sub(_sThing, 1, 1) == "a" then
alias = string.match( _sThing, "a ([%a ]+)" )
end
local room = getRoom( x,y,z )
inventory[sMaterial] = nil
room.items[ _sThing ] = {
@ -1143,7 +1143,7 @@ function commands.build( _sThing, _sMaterial )
end
function commands.help()
local sText =
local sText =
"Welcome to adventure, the greatest text adventure game on CraftOS. " ..
"To get around the world, type actions, and the adventure will " ..
"be read back to you. The actions availiable to you are go, look, inspect, inventory, " ..
@ -1162,12 +1162,12 @@ function commands.eat( _sItem )
print( "You don't have any ".._sItem.."." )
return
end
local tItem = inventory[sItem]
if tItem.food then
print( "That was delicious!" )
inventory[sItem] = nil
if bInjured then
print( "You are no longer injured." )
bInjured = false
@ -1212,7 +1212,7 @@ end
local function simulate()
local bNewMonstersThisRoom = false
-- Spawn monsters in nearby rooms
for sx = -2,2 do
for sy = -1,1 do
@ -1220,24 +1220,24 @@ local function simulate()
local h = y + sy
if h >= -3 and h <= 0 then
local room = getRoom( x + sx, h, z + sz )
-- Spawn monsters
if room.nMonsters < 2 and
((h == 0 and not isSunny() and not room.items["a torch"]) or room.dark) and
math.random(1,6) == 1 then
local sMonster = tMonsters[ math.random(1,#tMonsters) ]
if room.items[ sMonster ] == nil then
room.items[ sMonster ] = items[ sMonster ]
room.nMonsters = room.nMonsters + 1
if sx == 0 and sy == 0 and sz == 0 and not room.dark then
print( "From the shadows, "..sMonster.." appears." )
bNewMonstersThisRoom = true
end
end
end
end
-- Burn monsters
if h == 0 and isSunny() then
for n,sMonster in ipairs( tMonsters ) do
@ -1249,7 +1249,7 @@ local function simulate()
room.nMonsters = room.nMonsters - 1
end
end
end
end
end
end
end
@ -1277,7 +1277,7 @@ local function simulate()
print( "The "..items[sMonster].aliases[1].." attacks you." )
end
end
if bInjured then
if term.isColour() then
term.setTextColour( colours.red )
@ -1290,13 +1290,13 @@ local function simulate()
else
bInjured = true
end
break
end
end
end
end
-- Always print this
if bInjured then
if term.isColour() then
@ -1305,7 +1305,7 @@ local function simulate()
print( "You are injured." )
term.setTextColour( colours.white )
end
-- Advance time
nTurn = nTurn + 1
nTimeInRoom = nTimeInRoom + 1
@ -1321,10 +1321,10 @@ while bRunning do
end
write( "? " )
term.setTextColour( colours.white )
local sRawLine = read( nil, tCommandHistory )
table.insert( tCommandHistory, sRawLine )
local sLine = nil
for match in string.gmatch(sRawLine, "%a+") do
if sLine then
@ -1333,7 +1333,7 @@ while bRunning do
sLine = string.lower(match)
end
end
doCommand( sLine or "" )
if bRunning then
simulate()

View File

@ -43,8 +43,8 @@ elseif sCommand == "play" or sCommand == nil then
print( "No Music Disc in disk drive: "..sName )
return
end
else
printUsage()
end

View File

@ -75,7 +75,7 @@ local function addFruit()
break
end
end
nFruit = nFruit + 1
if nFruit > #tFruits then
nFruit = 1
@ -86,7 +86,7 @@ local function drawMenu()
term.setTextColour( headingColour )
term.setCursorPos(1,1)
term.write( "SCORE " )
term.setTextColour( textColour )
term.setCursorPos(7,1)
term.write( tostring(nScore) )
@ -97,7 +97,7 @@ local function drawMenu()
term.setTextColour( textColour )
term.setCursorPos(w,1)
term.write( tostring(nDifficulty or "?") )
term.write( tostring(nDifficulty or "?") )
term.setTextColour( colours.white )
end
@ -120,7 +120,7 @@ local function update( )
else
nExtraLength = nExtraLength - 1
end
-- Update the head
local head = screen[xPos][yPos]
local newXPos = xPos + xVel
@ -135,11 +135,11 @@ local function update( )
elseif newYPos > h then
newYPos = 2
end
local newHead = screen[newXPos][newYPos]
if newHead.snake == true or newHead.wall == true then
bRunning = false
else
if newHead.fruit == true then
nScore = nScore + 10
@ -151,9 +151,9 @@ local function update( )
head.nextX = newXPos
head.nextY = newYPos
screen[newXPos][newYPos] = { snake = true }
end
term.setCursorPos(xPos,yPos)
term.setBackgroundColour( wormColour )
term.write(" ")
@ -172,7 +172,7 @@ local function drawFrontend()
printCentred( math.floor(h/2) - 3, "" )
printCentred( math.floor(h/2) - 2, " SELECT DIFFICULTY " )
printCentred( math.floor(h/2) - 1, "" )
printCentred( math.floor(h/2) + 0, " " )
printCentred( math.floor(h/2) + 1, " " )
printCentred( math.floor(h/2) + 2, " " )
@ -232,7 +232,7 @@ while bRunning do
if event == "timer" and p1 == timer then
timer = os.startTimer(nInterval)
update( false )
elseif event == "key" then
local key = p1
if key == keys.up or key == keys.w then
@ -250,14 +250,14 @@ while bRunning do
if xVel == 0 then
pxVel,pyVel = -1,0
end
elseif key == keys.right or key == keys.d then
-- Right
if xVel == 0 then
pxVel,pyVel = 1,0
end
end
end
end
end
@ -285,5 +285,3 @@ until e == "char"
term.clear()
term.setCursorPos(1,1)

View File

@ -11,13 +11,13 @@ if #tArgs < 1 then
printUsage()
return
end
local sCommand = tArgs[1]
if sCommand == "locate" then
-- "gps locate"
-- Just locate this computer (this will print the results)
gps.locate( 2, true )
elseif sCommand == "host" then
-- "gps host"
-- Act as a GPS host
@ -29,7 +29,7 @@ elseif sCommand == "host" then
-- Find a modem
local sModemSide = nil
for n,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
break
end
@ -53,14 +53,14 @@ elseif sCommand == "host" then
end
print( "Position is "..x..","..y..","..z )
else
-- Position is to be determined using locate
-- Position is to be determined using locate
x,y,z = gps.locate( 2, true )
if x == nil then
print( "Run \"gps host <x> <y> <z>\" to set position manually" )
return
end
end
-- Open a channel
local modem = peripheral.wrap( sModemSide )
print( "Opening channel on modem "..sModemSide )
@ -76,7 +76,7 @@ elseif sCommand == "host" then
if sSide == sModemSide and sChannel == gps.CHANNEL_GPS and sMessage == "PING" and nDistance then
-- We received a ping message on the GPS channel, send a response
modem.transmit( sReplyChannel, gps.CHANNEL_GPS, { x, y, z } )
-- Print the number of requests handled
nServed = nServed + 1
if nServed > 1 then
@ -91,5 +91,4 @@ else
-- "gps somethingelse"
-- Error
printUsage()
end

View File

@ -12,7 +12,7 @@ if sTopic == "index" then
textutils.pagedTabulate( tTopics )
return
end
local sFile = help.lookup( sTopic )
local file = ((sFile ~= nil) and io.open( sFile )) or nil
if file then

View File

@ -5,28 +5,28 @@ local function printUsage()
print( "pastebin get <code> <filename>" )
print( "pastebin run <code> <arguments>" )
end
local tArgs = { ... }
if #tArgs < 2 then
printUsage()
return
end
if not http then
printError( "Pastebin requires http API" )
printError( "Set http_enable to true in ComputerCraft.cfg" )
return
end
local function get(paste)
write( "Connecting to pastebin.com... " )
local response = http.get(
"https://pastebin.com/raw/"..textutils.urlEncode( paste )
)
if response then
print( "Success." )
local sResponse = response.readAll()
response.close()
return sResponse
@ -34,7 +34,7 @@ local function get(paste)
print( "Failed." )
end
end
local sCommand = tArgs[1]
if sCommand == "put" then
-- Upload a file to pastebin.com
@ -45,46 +45,46 @@ if sCommand == "put" then
print( "No such file" )
return
end
-- Read in the file
local sName = fs.getName( sPath )
local file = fs.open( sPath, "r" )
local sText = file.readAll()
file.close()
-- POST the contents to pastebin
write( "Connecting to pastebin.com... " )
local key = "0ec2eb25b6166c0c27a394ae118ad829"
local response = http.post(
"https://pastebin.com/api/api_post.php",
"https://pastebin.com/api/api_post.php",
"api_option=paste&"..
"api_dev_key="..key.."&"..
"api_paste_format=lua&"..
"api_paste_name="..textutils.urlEncode(sName).."&"..
"api_paste_code="..textutils.urlEncode(sText)
)
if response then
print( "Success." )
local sResponse = response.readAll()
response.close()
local sCode = string.match( sResponse, "[^/]+$" )
print( "Uploaded as "..sResponse )
print( "Run \"pastebin get "..sCode.."\" to download anywhere" )
else
print( "Failed." )
end
elseif sCommand == "get" then
-- Download a file from pastebin.com
if #tArgs < 3 then
printUsage()
return
end
-- Determine file to download
local sCode = tArgs[2]
local sFile = tArgs[3]
@ -93,19 +93,19 @@ elseif sCommand == "get" then
print( "File already exists" )
return
end
-- GET the contents from pastebin
local res = get(sCode)
if res then
if res then
local file = fs.open( sPath, "w" )
file.write( res )
file.close()
print( "Downloaded as "..sFile )
end
end
elseif sCommand == "run" then
local sCode = tArgs[2]
local res = get(sCode)
if res then
local func, err = load(res, sCode, "t", _ENV)

View File

@ -3,13 +3,13 @@ local function printUsage()
print( "Usage:" )
print( "wget <url> [filename]" )
end
local tArgs = { ... }
if #tArgs < 1 then
printUsage()
return
end
if not http then
printError( "wget requires http API" )
printError( "Set http_enable to true in ComputerCraft.cfg" )

View File

@ -7,7 +7,7 @@ end
if sDrive == nil then
print( "This is computer #"..os.getComputerID() )
local label = os.getComputerLabel()
if label then
print( "This computer is labelled \""..label.."\"" )
@ -19,7 +19,7 @@ else
print( "No disk in drive "..sDrive )
return
end
print( "The disk is #"..disk.getID( sDrive ) )
local label = disk.getLabel( sDrive )
@ -27,4 +27,3 @@ else
print( "The disk is labelled \""..label.."\"" )
end
end

View File

@ -47,7 +47,7 @@ while bRunning do
if s:match("%S") and tCommandHistory[#tCommandHistory] ~= s then
table.insert( tCommandHistory, s )
end
local nForcePrint = 0
local func, e = load( s, "lua", "t", tEnv )
local func2, e2 = load( "return _echo("..s..");", "lua", "t", tEnv )
@ -62,7 +62,7 @@ while bRunning do
func = func2
end
end
if func then
local tResults = table.pack( pcall( func ) )
if tResults[1] then
@ -92,5 +92,5 @@ while bRunning do
else
printError( e )
end
end

View File

@ -1,4 +1,3 @@
local function printUsage()
print( "Usage: monitor <name> <program> <arguments>" )
return
@ -64,4 +63,3 @@ term.redirect( previousTerm )
if not ok then
printError( param )
end

View File

@ -3,4 +3,4 @@ if not ok then
printError( "Nothing to unequip" )
else
print( "Item unequipped" )
end
end

View File

@ -15,14 +15,14 @@ else
print( #tModems .. " modems found." )
end
function open( nChannel )
local function open( nChannel )
for n=1,#tModems do
local sModem = tModems[n]
peripheral.call( sModem, "open", nChannel )
end
end
function close( nChannel )
local function close( nChannel )
for n=1,#tModems do
local sModem = tModems[n]
peripheral.call( sModem, "close", nChannel )

View File

@ -254,7 +254,7 @@ function shell.resolveProgram( _sCommand )
end
return nil
end
-- Otherwise, look on the path variable
for sPath in string.gmatch(sPath, "[^:]+") do
sPath = fs.combine( shell.resolve( sPath ), _sCommand )
@ -267,14 +267,14 @@ function shell.resolveProgram( _sCommand )
end
end
end
-- Not found
return nil
end
function shell.programs( _bIncludeHidden )
local tItems = {}
-- Add programs from the path
for sPath in string.gmatch(sPath, "[^:]+") do
sPath = shell.resolve( sPath )
@ -291,7 +291,7 @@ function shell.programs( _bIncludeHidden )
end
end
end
end
end
-- Sort and return
local tItemList = {}

View File

@ -96,7 +96,7 @@ parallel.waitForAny(
if key ~= keys.escape then
return
end
end
end
end,
function()
while true do

View File

@ -11,7 +11,7 @@ if size < 1 then
print( "Excavate diameter must be positive" )
return
end
local depth = 0
local unloaded = 0
local collected = 0
@ -21,18 +21,18 @@ local xDir,zDir = 0,1
local goTo -- Filled in further down
local refuel -- Filled in further down
local function unload( _bKeepOneFuelStack )
print( "Unloading items..." )
for n=1,16 do
local nCount = turtle.getItemCount(n)
if nCount > 0 then
turtle.select(n)
turtle.select(n)
local bDrop = true
if _bKeepOneFuelStack and turtle.refuel(0) then
bDrop = false
_bKeepOneFuelStack = false
end
end
if bDrop then
turtle.drop()
unloaded = unloaded + nCount
@ -47,7 +47,7 @@ local function returnSupplies()
local x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
print( "Returning to surface..." )
goTo( 0,0,0,0,-1 )
local fuelNeeded = 2*(x+y+z) + 1
if not refuel( fuelNeeded ) then
unload( true )
@ -56,14 +56,14 @@ local function returnSupplies()
os.pullEvent( "turtle_inventory" )
end
else
unload( true )
unload( true )
end
print( "Resuming mining..." )
goTo( x,y,z,xd,zd )
end
local function collect()
local function collect()
local bFull = true
local nTotalItems = 0
for n=1,16 do
@ -73,14 +73,14 @@ local function collect()
end
nTotalItems = nTotalItems + nCount
end
if nTotalItems > collected then
collected = nTotalItems
if math.fmod(collected + unloaded, 50) == 0 then
print( "Mined "..(collected + unloaded).." items." )
end
end
if bFull then
print( "No empty slots left." )
return false
@ -93,7 +93,7 @@ function refuel( ammount )
if fuelLevel == "unlimited" then
return true
end
local needed = ammount or (xPos + zPos + depth + 2)
if turtle.getFuelLevel() < needed then
local fueled = false
@ -114,7 +114,7 @@ function refuel( ammount )
turtle.select(1)
return false
end
return true
end
@ -123,7 +123,7 @@ local function tryForwards()
print( "Not enough Fuel" )
returnSupplies()
end
while not turtle.forward() do
if turtle.detect() then
if turtle.dig() then
@ -141,7 +141,7 @@ local function tryForwards()
sleep( 0.5 )
end
end
xPos = xPos + xDir
zPos = zPos + zDir
return true
@ -152,7 +152,7 @@ local function tryDown()
print( "Not enough Fuel" )
returnSupplies()
end
while not turtle.down() do
if turtle.detectDown() then
if turtle.digDown() then
@ -227,7 +227,7 @@ function goTo( x, y, z, xd, zd )
end
end
end
if zPos > z then
while zDir ~= -1 do
turnLeft()
@ -253,9 +253,9 @@ function goTo( x, y, z, xd, zd )
else
sleep( 0.5 )
end
end
end
end
while depth < y do
if turtle.down() then
depth = depth + 1
@ -265,7 +265,7 @@ function goTo( x, y, z, xd, zd )
sleep( 0.5 )
end
end
while zDir ~= zd or xDir ~= xd do
turnLeft()
end
@ -318,7 +318,7 @@ while not done do
if done then
break
end
if size > 1 then
if math.fmod(size,2) == 0 then
turnRight()
@ -331,7 +331,7 @@ while not done do
alternate = 1 - alternate
end
end
if not tryDown() then
done = true
break

View File

@ -11,7 +11,7 @@ if length < 1 then
print( "Tunnel length must be positive" )
return
end
local depth = 0
local collected = 0
@ -63,7 +63,7 @@ local function refuel()
if fuelLevel == "unlimited" or fuelLevel > 0 then
return
end
local function tryRefuel()
for n=1,16 do
if turtle.getItemCount(n) > 0 then
@ -77,7 +77,7 @@ local function refuel()
turtle.select(1)
return false
end
if not tryRefuel() then
print( "Add more fuel to continue." )
while not tryRefuel() do
@ -150,7 +150,7 @@ for n=1,length do
tryDown()
tryDig()
turtle.turnLeft()
if n<length then
tryDig()
if not tryForward() then

View File

@ -34,5 +34,4 @@ while nArg <= #tArgs do
print( "Try: left, right" )
return
end
end

View File

@ -168,7 +168,7 @@ local function completeSet( shell, nIndex, sText, tPreviousText )
return completeMultipleChoice( sText, settings.getNames(), true )
end
end
local tCommands
local tCommands
if commands then
tCommands = commands.list()
end

View File

@ -1,159 +1,159 @@
function new(_sizeX, _sizeY, _color)
local redirect = {buffer = {text = {}, textColor = {}, backColor = {}, cursorX = 1, cursorY = 1, cursorBlink = false, curTextColor = "0", curBackColor = "f", sizeX = _sizeX or 51, sizeY = _sizeY or 19, color = _color}}
redirect.write = function(text)
text = tostring(text)
local pos = redirect.buffer.cursorX
if redirect.buffer.cursorY > redirect.buffer.sizeY or redirect.buffer.cursorY < 1 then
redirect.buffer.cursorX = pos + #text
return
end
local writeText
if pos + #text <= 1 then
--skip entirely.
redirect.buffer.cursorX = pos + #text
return
elseif pos < 1 then
--adjust text to fit on screen starting at one.
writeText = string.sub(text, math.abs(redirect.buffer.cursorX) + 2)
redirect.buffer.cursorX = 1
elseif pos > redirect.buffer.sizeX then
--if we're off the edge to the right, skip entirely.
redirect.buffer.cursorX = pos + #text
return
else
writeText = text
end
local lineText = redirect.buffer.text[redirect.buffer.cursorY]
local lineColor = redirect.buffer.textColor[redirect.buffer.cursorY]
local lineBack = redirect.buffer.backColor[redirect.buffer.cursorY]
local preStop = redirect.buffer.cursorX - 1
local preStart = math.min(1, preStop)
local postStart = redirect.buffer.cursorX + string.len(writeText)
local postStop = redirect.buffer.sizeX
redirect.buffer.text[redirect.buffer.cursorY] = string.sub(lineText, preStart, preStop)..writeText..string.sub(lineText, postStart, postStop)
redirect.buffer.textColor[redirect.buffer.cursorY] = string.sub(lineColor, preStart, preStop)..string.rep(redirect.buffer.curTextColor, #writeText)..string.sub(lineColor, postStart, postStop)
redirect.buffer.backColor[redirect.buffer.cursorY] = string.sub(lineBack, preStart, preStop)..string.rep(redirect.buffer.curBackColor, #writeText)..string.sub(lineBack, postStart, postStop)
redirect.buffer.cursorX = pos + string.len(text)
end
redirect.clear = function()
for i=1, redirect.buffer.sizeY do
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
end
redirect.clearLine = function()
redirect.buffer.text[redirect.buffer.cursorY] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
redirect.getCursorPos = function()
return redirect.buffer.cursorX, redirect.buffer.cursorY
end
redirect.setCursorPos = function(x, y)
redirect.buffer.cursorX = math.floor(tonumber(x)) or redirect.buffer.cursorX
redirect.buffer.cursorY = math.floor(tonumber(y)) or redirect.buffer.cursorY
end
redirect.setCursorBlink = function(b)
redirect.buffer.cursorBlink = b
end
redirect.getSize = function()
return redirect.buffer.sizeX, redirect.buffer.sizeY
end
redirect.scroll = function(n)
n = tonumber(n) or 1
if n > 0 then
for i = 1, redirect.buffer.sizeY - n do
if redirect.buffer.text[i + n] then
redirect.buffer.text[i] = redirect.buffer.text[i + n]
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
end
end
for i = redirect.buffer.sizeY, redirect.buffer.sizeY - n + 1, -1 do
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
elseif n < 0 then
for i = redirect.buffer.sizeY, math.abs(n) + 1, -1 do
if redirect.buffer.text[i + n] then
redirect.buffer.text[i] = redirect.buffer.text[i + n]
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
end
end
for i = 1, math.abs(n) do
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
end
end
redirect.setTextColor = function(clr)
if clr and clr <= 32768 and clr >= 1 then
if redirect.buffer.color then
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
elseif clr == 1 or clr == 32768 then
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
else
return nil, "Colour not supported"
end
end
end
redirect.setTextColour = redirect.setTextColor
redirect.setBackgroundColor = function(clr)
if clr and clr <= 32768 and clr >= 1 then
if redirect.buffer.color then
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
elseif clr == 32768 or clr == 1 then
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
else
return nil, "Colour not supported"
end
end
end
redirect.setBackgroundColour = redirect.setBackgroundColor
redirect.isColor = function()
return redirect.buffer.color == true
end
redirect.isColour = redirect.isColor
redirect.render = function(inputBuffer)
for i = 1, redirect.buffer.sizeY do
redirect.buffer.text[i] = inputBuffer.text[i]
redirect.buffer.textColor[i] = inputBuffer.textColor[i]
redirect.buffer.backColor[i] = inputBuffer.backColor[i]
end
end
redirect.clear()
return redirect
end
function draw(buffer, current)
for i=1, buffer.sizeY do
term.setCursorPos(1,i)
if (current and (buffer.text[i] ~= current.text[i] or buffer.textColor[i] ~= current.textColor[i] or buffer.backColor[i] ~= current.backColor[i])) or not current then
local lineEnd = false
local offset = 1
while not lineEnd do
local textColorString = string.match(string.sub(buffer.textColor[i], offset), string.sub(buffer.textColor[i], offset, offset).."*")
local backColorString = string.match(string.sub(buffer.backColor[i], offset), string.sub(buffer.backColor[i], offset, offset).."*")
term.setTextColor(2 ^ tonumber(string.sub(textColorString, 1, 1), 16))
term.setBackgroundColor(2 ^ tonumber(string.sub(backColorString, 1, 1), 16))
term.write(string.sub(buffer.text[i], offset, offset + math.min(#textColorString, #backColorString) - 1))
offset = offset + math.min(#textColorString, #backColorString)
if offset > buffer.sizeX then lineEnd = true end
end
if current then
current.text[i] = buffer.text[i]
current.textColor[i] = buffer.textColor[i]
current.backColor[i] = buffer.backColor[i]
end
end
end
term.setCursorPos(buffer.cursorX, buffer.cursorY)
term.setTextColor(2 ^ tonumber(buffer.curTextColor, 16))
term.setBackgroundColor(2 ^ tonumber(buffer.curBackColor, 16))
term.setCursorBlink(buffer.cursorBlink)
return current
end
function new(_sizeX, _sizeY, _color)
local redirect = {buffer = {text = {}, textColor = {}, backColor = {}, cursorX = 1, cursorY = 1, cursorBlink = false, curTextColor = "0", curBackColor = "f", sizeX = _sizeX or 51, sizeY = _sizeY or 19, color = _color}}
redirect.write = function(text)
text = tostring(text)
local pos = redirect.buffer.cursorX
if redirect.buffer.cursorY > redirect.buffer.sizeY or redirect.buffer.cursorY < 1 then
redirect.buffer.cursorX = pos + #text
return
end
local writeText
if pos + #text <= 1 then
--skip entirely.
redirect.buffer.cursorX = pos + #text
return
elseif pos < 1 then
--adjust text to fit on screen starting at one.
writeText = string.sub(text, math.abs(redirect.buffer.cursorX) + 2)
redirect.buffer.cursorX = 1
elseif pos > redirect.buffer.sizeX then
--if we're off the edge to the right, skip entirely.
redirect.buffer.cursorX = pos + #text
return
else
writeText = text
end
local lineText = redirect.buffer.text[redirect.buffer.cursorY]
local lineColor = redirect.buffer.textColor[redirect.buffer.cursorY]
local lineBack = redirect.buffer.backColor[redirect.buffer.cursorY]
local preStop = redirect.buffer.cursorX - 1
local preStart = math.min(1, preStop)
local postStart = redirect.buffer.cursorX + string.len(writeText)
local postStop = redirect.buffer.sizeX
redirect.buffer.text[redirect.buffer.cursorY] = string.sub(lineText, preStart, preStop)..writeText..string.sub(lineText, postStart, postStop)
redirect.buffer.textColor[redirect.buffer.cursorY] = string.sub(lineColor, preStart, preStop)..string.rep(redirect.buffer.curTextColor, #writeText)..string.sub(lineColor, postStart, postStop)
redirect.buffer.backColor[redirect.buffer.cursorY] = string.sub(lineBack, preStart, preStop)..string.rep(redirect.buffer.curBackColor, #writeText)..string.sub(lineBack, postStart, postStop)
redirect.buffer.cursorX = pos + string.len(text)
end
redirect.clear = function()
for i=1, redirect.buffer.sizeY do
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
end
redirect.clearLine = function()
redirect.buffer.text[redirect.buffer.cursorY] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
redirect.getCursorPos = function()
return redirect.buffer.cursorX, redirect.buffer.cursorY
end
redirect.setCursorPos = function(x, y)
redirect.buffer.cursorX = math.floor(tonumber(x)) or redirect.buffer.cursorX
redirect.buffer.cursorY = math.floor(tonumber(y)) or redirect.buffer.cursorY
end
redirect.setCursorBlink = function(b)
redirect.buffer.cursorBlink = b
end
redirect.getSize = function()
return redirect.buffer.sizeX, redirect.buffer.sizeY
end
redirect.scroll = function(n)
n = tonumber(n) or 1
if n > 0 then
for i = 1, redirect.buffer.sizeY - n do
if redirect.buffer.text[i + n] then
redirect.buffer.text[i] = redirect.buffer.text[i + n]
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
end
end
for i = redirect.buffer.sizeY, redirect.buffer.sizeY - n + 1, -1 do
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
elseif n < 0 then
for i = redirect.buffer.sizeY, math.abs(n) + 1, -1 do
if redirect.buffer.text[i + n] then
redirect.buffer.text[i] = redirect.buffer.text[i + n]
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
end
end
for i = 1, math.abs(n) do
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX)
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
end
end
end
redirect.setTextColor = function(clr)
if clr and clr <= 32768 and clr >= 1 then
if redirect.buffer.color then
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
elseif clr == 1 or clr == 32768 then
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
else
return nil, "Colour not supported"
end
end
end
redirect.setTextColour = redirect.setTextColor
redirect.setBackgroundColor = function(clr)
if clr and clr <= 32768 and clr >= 1 then
if redirect.buffer.color then
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
elseif clr == 32768 or clr == 1 then
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
else
return nil, "Colour not supported"
end
end
end
redirect.setBackgroundColour = redirect.setBackgroundColor
redirect.isColor = function()
return redirect.buffer.color == true
end
redirect.isColour = redirect.isColor
redirect.render = function(inputBuffer)
for i = 1, redirect.buffer.sizeY do
redirect.buffer.text[i] = inputBuffer.text[i]
redirect.buffer.textColor[i] = inputBuffer.textColor[i]
redirect.buffer.backColor[i] = inputBuffer.backColor[i]
end
end
redirect.clear()
return redirect
end
function draw(buffer, current)
for i=1, buffer.sizeY do
term.setCursorPos(1,i)
if (current and (buffer.text[i] ~= current.text[i] or buffer.textColor[i] ~= current.textColor[i] or buffer.backColor[i] ~= current.backColor[i])) or not current then
local lineEnd = false
local offset = 1
while not lineEnd do
local textColorString = string.match(string.sub(buffer.textColor[i], offset), string.sub(buffer.textColor[i], offset, offset).."*")
local backColorString = string.match(string.sub(buffer.backColor[i], offset), string.sub(buffer.backColor[i], offset, offset).."*")
term.setTextColor(2 ^ tonumber(string.sub(textColorString, 1, 1), 16))
term.setBackgroundColor(2 ^ tonumber(string.sub(backColorString, 1, 1), 16))
term.write(string.sub(buffer.text[i], offset, offset + math.min(#textColorString, #backColorString) - 1))
offset = offset + math.min(#textColorString, #backColorString)
if offset > buffer.sizeX then lineEnd = true end
end
if current then
current.text[i] = buffer.text[i]
current.textColor[i] = buffer.textColor[i]
current.backColor[i] = buffer.backColor[i]
end
end
end
term.setCursorPos(buffer.cursorX, buffer.cursorY)
term.setTextColor(2 ^ tonumber(buffer.curTextColor, 16))
term.setBackgroundColor(2 ^ tonumber(buffer.curBackColor, 16))
term.setCursorBlink(buffer.cursorBlink)
return current
end

View File

@ -1,26 +1,26 @@
if not nsh then print("No nsh session!") return end
local args = {...}
if #args < 2 then
print("Usage: get <remote> <local>")
print("<remote>: any file on the server")
print("<local>: any non-existant file on the client")
return
end
if fs.exists(args[1]) then
nsh.send("FS:;t="..args[2])
local message = nsh.receive()
if message == "FR:;ok" then
nsh.send("FH:;"..args[1])
local handle = io.open(args[1], "r")
if handle then
nsh.send("FD:;t="..handle:read("*a"))
handle:close()
end
nsh.send("FE:;end")
else
print("Client rejected file!")
end
if not nsh then print("No nsh session!") return end
local args = {...}
if #args < 2 then
print("Usage: get <remote> <local>")
print("<remote>: any file on the server")
print("<local>: any non-existant file on the client")
return
end
if fs.exists(args[1]) then
nsh.send("FS:;t="..args[2])
local message = nsh.receive()
if message == "FR:;ok" then
nsh.send("FH:;"..args[1])
local handle = io.open(args[1], "r")
if handle then
nsh.send("FD:;t="..handle:read("*a"))
handle:close()
end
nsh.send("FE:;end")
else
print("Client rejected file!")
end
end

View File

@ -1,35 +1,35 @@
if not nsh then print("No nsh session!") return end
local args = {...}
if #args < 2 then
print("Usage: put <local> <remote>")
print("<local>: any file on the client")
print("<remote>: any file on the server")
return
end
local fileData = ""
nsh.send("FQ:;t="..args[1])
local message = nsh.receive()
if message ~= "fileNotFound" then
while true do
message = nsh.receive()
pType = string.sub(message, 1, 2)
if pType == "FD" then
fileData = fileData..string.match(message, "^FD:;t=(.*)")
elseif pType == "FE" then
break
end
end
if #fileData > 0 then
local handle = io.open(args[2], "w")
if handle then
handle:write(fileData)
handle:close()
end
else
print("Empty file not written!")
end
if not nsh then print("No nsh session!") return end
local args = {...}
if #args < 2 then
print("Usage: put <local> <remote>")
print("<local>: any file on the client")
print("<remote>: any file on the server")
return
end
local fileData = ""
nsh.send("FQ:;t="..args[1])
local message = nsh.receive()
if message ~= "fileNotFound" then
while true do
message = nsh.receive()
pType = string.sub(message, 1, 2)
if pType == "FD" then
fileData = fileData..string.match(message, "^FD:;t=(.*)")
elseif pType == "FE" then
break
end
end
if #fileData > 0 then
local handle = io.open(args[2], "w")
if handle then
handle:write(fileData)
handle:close()
end
else
print("Empty file not written!")
end
end

View File

@ -1,178 +1,178 @@
board = {}
tArgs = { ... }
generation = 0
sleeptime = 0.5
if(tArgs[1] == "left" or tArgs[1] == "right" or tArgs[1] == "top" or tArgs[1] == "bottom" or tArgs[1] == "front" or tArgs[1] == "back")then
mon = peripheral.wrap(tArgs[1])
else
mon = term
end
if(mon.isColor() or mon.isColor)then
colored = true
else
colored = false
end
w, h = mon.getSize()
for x = 1, w do
board[x] = {}
for y = 1, h do
board[x][y] = 0
end
end
function drawScreen()
w, h = mon.getSize()
for x = 1, w do
for y = 1, h do
nei = getNeighbours(x, y)
if(board[x][y] == 1)then
if colored then
if(nei < 2 or nei > 3)then
mon.setBackgroundColor(colors.red)
else
mon.setBackgroundColor(colors.green)
end
else
mon.setBackgroundColor(colors.white)
end
else
if colored then
if(nei == 3)then
mon.setBackgroundColor(colors.yellow)
else
mon.setBackgroundColor(colors.black)
end
else
mon.setBackgroundColor(colors.black)
end
end
mon.setCursorPos(x, y)
mon.write(" ")
end
end
mon.setCursorPos(1,1)
if colored then
mon.setTextColor(colors.blue)
end
mon.write(generation)
end
function getNeighbours(x, y)
w, h = mon.getSize()
total = 0
if(x > 1 and y > 1)then if(board[x-1][y-1] == 1)then total = total + 1 end end
if(y > 1)then if(board[x][y-1] == 1)then total = total + 1 end end
if(x < w and y > 1)then if(board[x+1][y-1] == 1)then total = total + 1 end end
if(x > 1)then if(board[x-1][y] == 1)then total = total + 1 end end
if(x < w)then if(board[x+1][y] == 1)then total = total + 1 end end
if(x > 1 and y < h)then if(board[x-1][y+1] == 1)then total = total + 1 end end
if(y < h)then if(board[x][y+1] == 1)then total = total + 1 end end
if(x < w and y < h)then if(board[x+1][y+1] == 1)then total = total + 1 end end
return total
end
function compute()
w, h = mon.getSize()
while true do
newBoard = {}
for x = 1, w do
newBoard[x] = {}
for y = 1, h do
nei = getNeighbours(x, y)
if(board[x][y] == 1)then
if(nei < 2)then
newBoard[x][y] = 0
elseif(nei > 3)then
newBoard[x][y] = 0
else
newBoard[x][y] = 1
end
else
if(nei == 3)then
newBoard[x][y] = 1
end
end
end
end
board = newBoard
generation = generation + 1
sleep(sleeptime)
end
end
function loop()
while true do
event, variable, xPos, yPos = os.pullEvent()
if event == "mouse_click" or event == "monitor_touch" or event == "mouse_drag" then
if variable == 1 then
board[xPos][yPos] = 1
else
board[xPos][yPos] = 0
end
end
if event == "key" then
if tostring(variable) == "28" then
return true
elseif tostring(variable) == "57" then
if(mon.isColor() or mon.isColor)then
colored = not colored
end
elseif tostring(variable) == "200" then
if sleeptime > 0.1 then
sleeptime = sleeptime - 0.1
end
elseif tostring(variable) == "208" then
if sleeptime < 1 then
sleeptime = sleeptime + 0.1
end
end
end
drawScreen()
end
end
function intro()
mon.setBackgroundColor(colors.black)
mon.clear()
mon.setCursorPos(1,1)
mon.write("Conway's Game Of Life")
mon.setCursorPos(1,2)
mon.write("It is a game which represents life.")
mon.setCursorPos(1,3)
mon.write("The game runs by 4 basic rules:")
mon.setCursorPos(1,4)
mon.write("1. If a cell has less than 2 neighbours, it dies.")
mon.setCursorPos(1,5)
mon.write("2. If a cell has 2 or 3 neightbours, it lives.")
mon.setCursorPos(1,6)
mon.write("3. If a cell has more than 3 neighbours, it dies.")
mon.setCursorPos(1,7)
mon.write("4. If a cell has exactly 3 neighbours it is born.")
mon.setCursorPos(1,9)
mon.write("At the top left is the generation count.")
mon.setCursorPos(1,10)
mon.write("Press spacebar to switch between color modes")
mon.setCursorPos(1,11)
mon.write("Press enter to start the game")
mon.setCursorPos(1,13)
mon.write("Colors:")
mon.setCursorPos(1,14)
mon.write("Red - Cell will die in next generation")
mon.setCursorPos(1,15)
mon.write("Green - Cell will live in next generation")
mon.setCursorPos(1,16)
mon.write("Yellow - Cell will be born in next generation")
mon.setCursorPos(1,18)
mon.write("Press any key to continue!")
event, variable, xPos, yPos = os.pullEvent("key")
end
intro()
drawScreen()
while true do
loop()
parallel.waitForAny(loop, compute)
board = {}
tArgs = { ... }
generation = 0
sleeptime = 0.5
if(tArgs[1] == "left" or tArgs[1] == "right" or tArgs[1] == "top" or tArgs[1] == "bottom" or tArgs[1] == "front" or tArgs[1] == "back")then
mon = peripheral.wrap(tArgs[1])
else
mon = term
end
if(mon.isColor() or mon.isColor)then
colored = true
else
colored = false
end
w, h = mon.getSize()
for x = 1, w do
board[x] = {}
for y = 1, h do
board[x][y] = 0
end
end
function drawScreen()
w, h = mon.getSize()
for x = 1, w do
for y = 1, h do
nei = getNeighbours(x, y)
if(board[x][y] == 1)then
if colored then
if(nei < 2 or nei > 3)then
mon.setBackgroundColor(colors.red)
else
mon.setBackgroundColor(colors.green)
end
else
mon.setBackgroundColor(colors.white)
end
else
if colored then
if(nei == 3)then
mon.setBackgroundColor(colors.yellow)
else
mon.setBackgroundColor(colors.black)
end
else
mon.setBackgroundColor(colors.black)
end
end
mon.setCursorPos(x, y)
mon.write(" ")
end
end
mon.setCursorPos(1,1)
if colored then
mon.setTextColor(colors.blue)
end
mon.write(generation)
end
function getNeighbours(x, y)
w, h = mon.getSize()
total = 0
if(x > 1 and y > 1)then if(board[x-1][y-1] == 1)then total = total + 1 end end
if(y > 1)then if(board[x][y-1] == 1)then total = total + 1 end end
if(x < w and y > 1)then if(board[x+1][y-1] == 1)then total = total + 1 end end
if(x > 1)then if(board[x-1][y] == 1)then total = total + 1 end end
if(x < w)then if(board[x+1][y] == 1)then total = total + 1 end end
if(x > 1 and y < h)then if(board[x-1][y+1] == 1)then total = total + 1 end end
if(y < h)then if(board[x][y+1] == 1)then total = total + 1 end end
if(x < w and y < h)then if(board[x+1][y+1] == 1)then total = total + 1 end end
return total
end
function compute()
w, h = mon.getSize()
while true do
newBoard = {}
for x = 1, w do
newBoard[x] = {}
for y = 1, h do
nei = getNeighbours(x, y)
if(board[x][y] == 1)then
if(nei < 2)then
newBoard[x][y] = 0
elseif(nei > 3)then
newBoard[x][y] = 0
else
newBoard[x][y] = 1
end
else
if(nei == 3)then
newBoard[x][y] = 1
end
end
end
end
board = newBoard
generation = generation + 1
sleep(sleeptime)
end
end
function loop()
while true do
event, variable, xPos, yPos = os.pullEvent()
if event == "mouse_click" or event == "monitor_touch" or event == "mouse_drag" then
if variable == 1 then
board[xPos][yPos] = 1
else
board[xPos][yPos] = 0
end
end
if event == "key" then
if tostring(variable) == "28" then
return true
elseif tostring(variable) == "57" then
if(mon.isColor() or mon.isColor)then
colored = not colored
end
elseif tostring(variable) == "200" then
if sleeptime > 0.1 then
sleeptime = sleeptime - 0.1
end
elseif tostring(variable) == "208" then
if sleeptime < 1 then
sleeptime = sleeptime + 0.1
end
end
end
drawScreen()
end
end
function intro()
mon.setBackgroundColor(colors.black)
mon.clear()
mon.setCursorPos(1,1)
mon.write("Conway's Game Of Life")
mon.setCursorPos(1,2)
mon.write("It is a game which represents life.")
mon.setCursorPos(1,3)
mon.write("The game runs by 4 basic rules:")
mon.setCursorPos(1,4)
mon.write("1. If a cell has less than 2 neighbours, it dies.")
mon.setCursorPos(1,5)
mon.write("2. If a cell has 2 or 3 neightbours, it lives.")
mon.setCursorPos(1,6)
mon.write("3. If a cell has more than 3 neighbours, it dies.")
mon.setCursorPos(1,7)
mon.write("4. If a cell has exactly 3 neighbours it is born.")
mon.setCursorPos(1,9)
mon.write("At the top left is the generation count.")
mon.setCursorPos(1,10)
mon.write("Press spacebar to switch between color modes")
mon.setCursorPos(1,11)
mon.write("Press enter to start the game")
mon.setCursorPos(1,13)
mon.write("Colors:")
mon.setCursorPos(1,14)
mon.write("Red - Cell will die in next generation")
mon.setCursorPos(1,15)
mon.write("Green - Cell will live in next generation")
mon.setCursorPos(1,16)
mon.write("Yellow - Cell will be born in next generation")
mon.setCursorPos(1,18)
mon.write("Press any key to continue!")
event, variable, xPos, yPos = os.pullEvent("key")
end
intro()
drawScreen()
while true do
loop()
parallel.waitForAny(loop, compute)
end

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_blink_advanced",
"side": "computercraft:blocks/computer_side_advanced",
"top": "computercraft:blocks/computer_top_advanced"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_blink_advanced",
"side": "computercraft:blocks/computer_side_advanced",
"top": "computercraft:blocks/computer_top_advanced"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_advanced",
"side": "computercraft:blocks/computer_side_advanced",
"top": "computercraft:blocks/computer_top_advanced"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_advanced",
"side": "computercraft:blocks/computer_side_advanced",
"top": "computercraft:blocks/computer_top_advanced"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_on_advanced",
"side": "computercraft:blocks/computer_side_advanced",
"top": "computercraft:blocks/computer_top_advanced"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_on_advanced",
"side": "computercraft:blocks/computer_side_advanced",
"top": "computercraft:blocks/computer_top_advanced"
}
}

View File

@ -1,7 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:blocks/adv_modem_face",
"back": "computercraft:blocks/modem_back"
}
}
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:blocks/adv_modem_face",
"back": "computercraft:blocks/modem_back"
}
}

View File

@ -1,7 +1,7 @@
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:blocks/adv_modem_face_on",
"back": "computercraft:blocks/modem_back"
}
}
{
"parent": "computercraft:block/modem",
"textures": {
"front": "computercraft:blocks/adv_modem_face_on",
"back": "computercraft:blocks/modem_back"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor16",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor4"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor16",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor4"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor20",
"side": "computercraft:blocks/adv_monitor36",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor36"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor20",
"side": "computercraft:blocks/adv_monitor36",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor36"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/adv_monitor15",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor0"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/adv_monitor15",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor0"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor19",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor33"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor19",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor33"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor31",
"side": "computercraft:blocks/adv_monitor7",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor45"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor31",
"side": "computercraft:blocks/adv_monitor7",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor45"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor18",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor34"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor18",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor34"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor30",
"side": "computercraft:blocks/adv_monitor7",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor46"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor30",
"side": "computercraft:blocks/adv_monitor7",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor46"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor24",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor40"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor24",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor40"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor27",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor43"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor27",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor2",
"back": "computercraft:blocks/adv_monitor43"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor25",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor39"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor25",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor39"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor28",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor42"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor28",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor1",
"back": "computercraft:blocks/adv_monitor42"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor17",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor35"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor17",
"side": "computercraft:blocks/adv_monitor4",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor35"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor29",
"side": "computercraft:blocks/adv_monitor7",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor47"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor29",
"side": "computercraft:blocks/adv_monitor7",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor47"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor23",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor41"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor23",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor41"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor26",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor44"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor26",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor3",
"back": "computercraft:blocks/adv_monitor44"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor22",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor38"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor22",
"side": "computercraft:blocks/adv_monitor38",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor38"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor21",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor37"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/adv_monitor21",
"side": "computercraft:blocks/adv_monitor37",
"top": "computercraft:blocks/adv_monitor0",
"back": "computercraft:blocks/adv_monitor37"
}
}

View File

@ -1,6 +1,6 @@
{
"parent": "computercraft:block/turtle_base",
"textures": {
"texture": "computercraft:blocks/turtle_advanced"
}
}
{
"parent": "computercraft:block/turtle_base",
"textures": {
"texture": "computercraft:blocks/turtle_advanced"
}
}

View File

@ -1,6 +1,6 @@
{
"parent": "computercraft:block/turtle_upgrade_base_left",
"textures": {
"texture": "computercraft:blocks/adv_modem_face"
}
}
{
"parent": "computercraft:block/turtle_upgrade_base_left",
"textures": {
"texture": "computercraft:blocks/adv_modem_face"
}
}

View File

@ -1,6 +1,6 @@
{
"parent": "computercraft:block/turtle_upgrade_base_right",
"textures": {
"texture": "computercraft:blocks/adv_modem_face"
}
}
{
"parent": "computercraft:block/turtle_upgrade_base_right",
"textures": {
"texture": "computercraft:blocks/adv_modem_face"
}
}

View File

@ -1,6 +1,6 @@
{
"parent": "computercraft:block/turtle_upgrade_base_left",
"textures": {
"texture": "computercraft:blocks/adv_modem_face_on"
}
}
{
"parent": "computercraft:block/turtle_upgrade_base_left",
"textures": {
"texture": "computercraft:blocks/adv_modem_face_on"
}
}

View File

@ -1,6 +1,6 @@
{
"parent": "computercraft:block/turtle_upgrade_base_right",
"textures": {
"texture": "computercraft:blocks/adv_modem_face_on"
}
}
{
"parent": "computercraft:block/turtle_upgrade_base_right",
"textures": {
"texture": "computercraft:blocks/adv_modem_face_on"
}
}

View File

@ -1,19 +1,19 @@
{
"parent": "block/block",
"textures": {
"particle": "computercraft:blocks/cable_core",
"side": "computercraft:blocks/cable_side"
},
"elements": [
{
"from": [ 6, 6, 10 ],
"to": [ 10, 10, 16 ],
"faces": {
"down": { "uv": [ 6, 0, 10, 6 ], "texture": "#side" },
"up": { "uv": [ 6, 10, 10, 16 ], "texture": "#side" },
"west": { "uv": [ 0, 6, 6, 10 ], "texture": "#side" },
"east": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" }
}
}
]
}
{
"parent": "block/block",
"textures": {
"particle": "computercraft:blocks/cable_core",
"side": "computercraft:blocks/cable_side"
},
"elements": [
{
"from": [ 6, 6, 10 ],
"to": [ 10, 10, 16 ],
"faces": {
"down": { "uv": [ 6, 0, 10, 6 ], "texture": "#side" },
"up": { "uv": [ 6, 10, 10, 16 ], "texture": "#side" },
"west": { "uv": [ 0, 6, 6, 10 ], "texture": "#side" },
"east": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" }
}
}
]
}

View File

@ -5,7 +5,7 @@
"side": "computercraft:blocks/cable_side"
},
"elements": [
{
{
"from": [ 6, 6, 6 ],
"to": [ 10, 10, 10 ],
"faces": {

View File

@ -1,22 +1,22 @@
{
"parent": "block/block",
"textures": {
"particle": "computercraft:blocks/cable_core",
"side": "computercraft:blocks/cable_side",
"end": "computercraft:blocks/cable_core"
},
"elements": [
{
"from": [ 6, 6, 2 ],
"to": [ 10, 10, 14 ],
"faces": {
"down": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
"up": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
"north": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
"south": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
"west": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" },
"east": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" }
}
}
]
}
{
"parent": "block/block",
"textures": {
"particle": "computercraft:blocks/cable_core",
"side": "computercraft:blocks/cable_side",
"end": "computercraft:blocks/cable_core"
},
"elements": [
{
"from": [ 6, 6, 2 ],
"to": [ 10, 10, 14 ],
"faces": {
"down": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
"up": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
"north": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
"south": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
"west": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" },
"east": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" }
}
}
]
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/command_computer_front_blink",
"side": "computercraft:blocks/command_computer_side",
"top": "computercraft:blocks/command_computer_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/command_computer_front_blink",
"side": "computercraft:blocks/command_computer_side",
"top": "computercraft:blocks/command_computer_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/command_computer_front",
"side": "computercraft:blocks/command_computer_side",
"top": "computercraft:blocks/command_computer_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/command_computer_front",
"side": "computercraft:blocks/command_computer_side",
"top": "computercraft:blocks/command_computer_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/command_computer_front_on",
"side": "computercraft:blocks/command_computer_side",
"top": "computercraft:blocks/command_computer_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/command_computer_front_on",
"side": "computercraft:blocks/command_computer_side",
"top": "computercraft:blocks/command_computer_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_blink",
"side": "computercraft:blocks/computer_side",
"top": "computercraft:blocks/computer_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_blink",
"side": "computercraft:blocks/computer_side",
"top": "computercraft:blocks/computer_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front",
"side": "computercraft:blocks/computer_side",
"top": "computercraft:blocks/computer_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front",
"side": "computercraft:blocks/computer_side",
"top": "computercraft:blocks/computer_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_on",
"side": "computercraft:blocks/computer_side",
"top": "computercraft:blocks/computer_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/computer_front_on",
"side": "computercraft:blocks/computer_side",
"top": "computercraft:blocks/computer_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/disk_drive_front",
"side": "computercraft:blocks/disk_drive_side",
"top": "computercraft:blocks/disk_drive_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/disk_drive_front",
"side": "computercraft:blocks/disk_drive_side",
"top": "computercraft:blocks/disk_drive_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/disk_drive_front_accepted",
"side": "computercraft:blocks/disk_drive_side",
"top": "computercraft:blocks/disk_drive_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/disk_drive_front_accepted",
"side": "computercraft:blocks/disk_drive_side",
"top": "computercraft:blocks/disk_drive_top"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/disk_drive_front_rejected",
"side": "computercraft:blocks/disk_drive_side",
"top": "computercraft:blocks/disk_drive_top"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/disk_drive_front_rejected",
"side": "computercraft:blocks/disk_drive_side",
"top": "computercraft:blocks/disk_drive_top"
}
}

View File

@ -1,52 +1,52 @@
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 2, 2, 0 ],
"to": [ 14, 14, 3 ],
"faces": {
"down": { "uv": [ 2, 13, 14, 16 ], "texture": "#front" },
"up": { "uv": [ 2, 0, 14, 3 ], "texture": "#front" },
"north": { "uv": [ 2, 2, 14, 14 ], "texture": "#back" },
"south": { "uv": [ 2, 2, 14, 14 ], "texture": "#front" },
"west": { "uv": [ 0, 2, 3, 14 ], "texture": "#front" },
"east": { "uv": [ 13, 2, 16, 14 ], "texture": "#front" }
}
}
],
"display": {
"gui": {
"rotation": [ 30, 45, 0 ],
"translation": [ 3.2, -2, 0],
"scale":[ 0.75, 0.75, 0.75 ]
},
"ground": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 3, 0],
"scale":[ 0.25, 0.25, 0.25 ]
},
"fixed": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 0, 0],
"scale":[ 0.5, 0.5, 0.5 ]
},
"thirdperson_righthand": {
"rotation": [ 75, 180, 0 ],
"translation": [ 0, 2.5, 0],
"scale": [ 0.375, 0.375, 0.375 ]
},
"firstperson_righthand": {
"rotation": [ 0, 45, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.40, 0.40, 0.40 ]
},
"firstperson_lefthand": {
"rotation": [ 0, 45, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.40, 0.40, 0.40 ]
}
}
}
{
"parent": "block/block",
"textures": {
"particle": "#front"
},
"elements": [
{
"from": [ 2, 2, 0 ],
"to": [ 14, 14, 3 ],
"faces": {
"down": { "uv": [ 2, 13, 14, 16 ], "texture": "#front" },
"up": { "uv": [ 2, 0, 14, 3 ], "texture": "#front" },
"north": { "uv": [ 2, 2, 14, 14 ], "texture": "#back" },
"south": { "uv": [ 2, 2, 14, 14 ], "texture": "#front" },
"west": { "uv": [ 0, 2, 3, 14 ], "texture": "#front" },
"east": { "uv": [ 13, 2, 16, 14 ], "texture": "#front" }
}
}
],
"display": {
"gui": {
"rotation": [ 30, 45, 0 ],
"translation": [ 3.2, -2, 0],
"scale":[ 0.75, 0.75, 0.75 ]
},
"ground": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 3, 0],
"scale":[ 0.25, 0.25, 0.25 ]
},
"fixed": {
"rotation": [ 0, 0, 0 ],
"translation": [ 0, 0, 0],
"scale":[ 0.5, 0.5, 0.5 ]
},
"thirdperson_righthand": {
"rotation": [ 75, 180, 0 ],
"translation": [ 0, 2.5, 0],
"scale": [ 0.375, 0.375, 0.375 ]
},
"firstperson_righthand": {
"rotation": [ 0, 45, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.40, 0.40, 0.40 ]
},
"firstperson_lefthand": {
"rotation": [ 0, 45, 0 ],
"translation": [ 0, 0, 0 ],
"scale": [ 0.40, 0.40, 0.40 ]
}
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor16",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor0",
"back": "computercraft:blocks/monitor4"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor16",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor0",
"back": "computercraft:blocks/monitor4"
}
}

View File

@ -1,12 +1,12 @@
{
"parent": "block/cube",
"textures": {
"particle": "#front",
"down": "#top",
"up": "#top",
"north": "#front",
"east": "#side",
"south": "#back",
"west": "#side"
}
}
{
"parent": "block/cube",
"textures": {
"particle": "#front",
"down": "#top",
"up": "#top",
"north": "#front",
"east": "#side",
"south": "#back",
"west": "#side"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor20",
"side": "computercraft:blocks/monitor36",
"top": "computercraft:blocks/monitor0",
"back": "computercraft:blocks/monitor36"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor20",
"side": "computercraft:blocks/monitor36",
"top": "computercraft:blocks/monitor0",
"back": "computercraft:blocks/monitor36"
}
}

View File

@ -1,8 +1,8 @@
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/monitor15",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor0"
}
}
{
"parent": "block/orientable",
"textures": {
"front": "computercraft:blocks/monitor15",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor0"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor19",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor1",
"back": "computercraft:blocks/monitor33"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor19",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor1",
"back": "computercraft:blocks/monitor33"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor31",
"side": "computercraft:blocks/monitor7",
"top": "computercraft:blocks/monitor1",
"back": "computercraft:blocks/monitor45"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor31",
"side": "computercraft:blocks/monitor7",
"top": "computercraft:blocks/monitor1",
"back": "computercraft:blocks/monitor45"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor18",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor2",
"back": "computercraft:blocks/monitor34"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor18",
"side": "computercraft:blocks/monitor4",
"top": "computercraft:blocks/monitor2",
"back": "computercraft:blocks/monitor34"
}
}

View File

@ -1,9 +1,9 @@
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor30",
"side": "computercraft:blocks/monitor7",
"top": "computercraft:blocks/monitor2",
"back": "computercraft:blocks/monitor46"
}
}
{
"parent": "computercraft:block/monitor_base",
"textures": {
"front": "computercraft:blocks/monitor30",
"side": "computercraft:blocks/monitor7",
"top": "computercraft:blocks/monitor2",
"back": "computercraft:blocks/monitor46"
}
}

Some files were not shown because too many files have changed in this diff Show More