mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-06-09 01:54:11 +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:
parent
e6850ab644
commit
86569533e9
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "minecraft:recipes/root",
|
"parent": "minecraft:recipes/root",
|
||||||
"rewards": {
|
"rewards": {
|
||||||
"recipes": [
|
"recipes": [
|
||||||
"computercraft:wired_modem",
|
"computercraft:wired_modem",
|
||||||
"computercraft:wired_modem_full_to",
|
"computercraft:wired_modem_full_to",
|
||||||
"computercraft:wired_modem_full_from"
|
"computercraft:wired_modem_full_from"
|
||||||
]
|
]
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"variants": {
|
"variants": {
|
||||||
"facing=up,on=false": { "model": "computercraft:advanced_modem_off", "x": 270 },
|
"facing=up,on=false": { "model": "computercraft:advanced_modem_off", "x": 270 },
|
||||||
"facing=down,on=false": { "model": "computercraft:advanced_modem_off", "x": 90 },
|
"facing=down,on=false": { "model": "computercraft:advanced_modem_off", "x": 90 },
|
||||||
"facing=north,on=false": { "model": "computercraft:advanced_modem_off" },
|
"facing=north,on=false": { "model": "computercraft:advanced_modem_off" },
|
||||||
"facing=south,on=false": { "model": "computercraft:advanced_modem_off", "y": 180 },
|
"facing=south,on=false": { "model": "computercraft:advanced_modem_off", "y": 180 },
|
||||||
"facing=west,on=false": { "model": "computercraft:advanced_modem_off", "y": 270 },
|
"facing=west,on=false": { "model": "computercraft:advanced_modem_off", "y": 270 },
|
||||||
"facing=east,on=false": { "model": "computercraft:advanced_modem_off", "y": 90 },
|
"facing=east,on=false": { "model": "computercraft:advanced_modem_off", "y": 90 },
|
||||||
|
|
||||||
"facing=up,on=true": { "model": "computercraft:advanced_modem_on", "x": 270 },
|
"facing=up,on=true": { "model": "computercraft:advanced_modem_on", "x": 270 },
|
||||||
"facing=down,on=true": { "model": "computercraft:advanced_modem_on", "x": 90 },
|
"facing=down,on=true": { "model": "computercraft:advanced_modem_on", "x": 90 },
|
||||||
"facing=north,on=true": { "model": "computercraft:advanced_modem_on" },
|
"facing=north,on=true": { "model": "computercraft:advanced_modem_on" },
|
||||||
"facing=south,on=true": { "model": "computercraft:advanced_modem_on", "y": 180 },
|
"facing=south,on=true": { "model": "computercraft:advanced_modem_on", "y": 180 },
|
||||||
"facing=west,on=true": { "model": "computercraft:advanced_modem_on", "y": 270 },
|
"facing=west,on=true": { "model": "computercraft:advanced_modem_on", "y": 270 },
|
||||||
"facing=east,on=true": { "model": "computercraft:advanced_modem_on", "y": 90 }
|
"facing=east,on=true": { "model": "computercraft:advanced_modem_on", "y": 90 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"variants": {
|
"variants": {
|
||||||
"facing=north,state=off": { "model": "computercraft:command_computer_off" },
|
"facing=north,state=off": { "model": "computercraft:command_computer_off" },
|
||||||
"facing=south,state=off": { "model": "computercraft:command_computer_off", "y": 180 },
|
"facing=south,state=off": { "model": "computercraft:command_computer_off", "y": 180 },
|
||||||
"facing=west,state=off": { "model": "computercraft:command_computer_off", "y": 270 },
|
"facing=west,state=off": { "model": "computercraft:command_computer_off", "y": 270 },
|
||||||
"facing=east,state=off": { "model": "computercraft:command_computer_off", "y": 90 },
|
"facing=east,state=off": { "model": "computercraft:command_computer_off", "y": 90 },
|
||||||
|
|
||||||
"facing=north,state=on": { "model": "computercraft:command_computer_on" },
|
"facing=north,state=on": { "model": "computercraft:command_computer_on" },
|
||||||
"facing=south,state=on": { "model": "computercraft:command_computer_on", "y": 180 },
|
"facing=south,state=on": { "model": "computercraft:command_computer_on", "y": 180 },
|
||||||
"facing=west,state=on": { "model": "computercraft:command_computer_on", "y": 270 },
|
"facing=west,state=on": { "model": "computercraft:command_computer_on", "y": 270 },
|
||||||
"facing=east,state=on": { "model": "computercraft:command_computer_on", "y": 90 },
|
"facing=east,state=on": { "model": "computercraft:command_computer_on", "y": 90 },
|
||||||
|
|
||||||
"facing=north,state=blinking": { "model": "computercraft:command_computer_blinking" },
|
"facing=north,state=blinking": { "model": "computercraft:command_computer_blinking" },
|
||||||
"facing=south,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 180 },
|
"facing=south,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 180 },
|
||||||
"facing=west,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 270 },
|
"facing=west,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 270 },
|
||||||
"facing=east,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 90 }
|
"facing=east,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 90 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
{
|
{
|
||||||
"variants": {
|
"variants": {
|
||||||
|
|
||||||
"advanced=false,facing=north,state=off": { "model": "computercraft:computer_off" },
|
"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=south,state=off": { "model": "computercraft:computer_off", "y": 180 },
|
||||||
"advanced=false,facing=west,state=off": { "model": "computercraft:computer_off", "y": 270 },
|
"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=east,state=off": { "model": "computercraft:computer_off", "y": 90 },
|
||||||
|
|
||||||
"advanced=false,facing=north,state=on": { "model": "computercraft:computer_on" },
|
"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=south,state=on": { "model": "computercraft:computer_on", "y": 180 },
|
||||||
"advanced=false,facing=west,state=on": { "model": "computercraft:computer_on", "y": 270 },
|
"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=east,state=on": { "model": "computercraft:computer_on", "y": 90 },
|
||||||
|
|
||||||
"advanced=false,facing=north,state=blinking": { "model": "computercraft:computer_blinking" },
|
"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=south,state=blinking": { "model": "computercraft:computer_blinking", "y": 180 },
|
||||||
"advanced=false,facing=west,state=blinking": { "model": "computercraft:computer_blinking", "y": 270 },
|
"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=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=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=east,state=off": { "model": "computercraft:advanced_computer_off", "y": 90 },
|
||||||
|
|
||||||
"advanced=true,facing=north,state=on": { "model": "computercraft:advanced_computer_on" },
|
"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=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=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=east,state=on": { "model": "computercraft:advanced_computer_on", "y": 90 },
|
||||||
|
|
||||||
"advanced=true,facing=north,state=blinking": { "model": "computercraft:advanced_computer_blinking" },
|
"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=south,state=blinking": { "model": "computercraft:advanced_computer_blinking", "y": 180 },
|
||||||
"advanced=true,facing=west,state=blinking": { "model": "computercraft:advanced_computer_blinking", "y": 270 },
|
"advanced=true,facing=west,state=blinking": { "model": "computercraft:advanced_computer_blinking", "y": 270 },
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
"facing=south,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 180 },
|
"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=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=east,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 90 },
|
||||||
|
|
||||||
"facing=north,variant=wireless_modem_off": { "model": "computercraft:wireless_modem_off" },
|
"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=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 },
|
"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=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=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=east,variant=monitor_down_lu": { "model": "computercraft:monitor_lu", "y": 90, "x": 90 },
|
||||||
|
|
||||||
"facing=north,variant=advanced_monitor": { "model": "computercraft:advanced_monitor" },
|
"facing=north,variant=advanced_monitor": { "model": "computercraft:advanced_monitor" },
|
||||||
"facing=south,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 180 },
|
"facing=south,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 180 },
|
||||||
"facing=west,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 270 },
|
"facing=west,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 270 },
|
||||||
|
@ -7,18 +7,18 @@ if _VERSION == "Lua 5.1" then
|
|||||||
local nativesetfenv = setfenv
|
local nativesetfenv = setfenv
|
||||||
function load( x, name, mode, env )
|
function load( x, name, mode, env )
|
||||||
if type( x ) ~= "string" and type( x ) ~= "function" then
|
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
|
end
|
||||||
if name ~= nil and type( name ) ~= "string" then
|
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
|
end
|
||||||
if mode ~= nil and type( mode ) ~= "string" then
|
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
|
end
|
||||||
if env ~= nil and type( env) ~= "table" then
|
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
|
end
|
||||||
local ok, p1, p2 = pcall( function()
|
local ok, p1, p2 = pcall( function()
|
||||||
if type(x) == "string" then
|
if type(x) == "string" then
|
||||||
local result, err = nativeloadstring( x, name )
|
local result, err = nativeloadstring( x, name )
|
||||||
if result then
|
if result then
|
||||||
@ -47,7 +47,7 @@ if _VERSION == "Lua 5.1" then
|
|||||||
return p1, p2
|
return p1, p2
|
||||||
else
|
else
|
||||||
error( p1, 2 )
|
error( p1, 2 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
table.pack = function( ... ) return { n = select( "#", ... ), ... } end
|
table.pack = function( ... ) return { n = select( "#", ... ), ... } end
|
||||||
@ -159,7 +159,7 @@ end
|
|||||||
-- Install globals
|
-- Install globals
|
||||||
function sleep( nTime )
|
function sleep( nTime )
|
||||||
if nTime ~= nil and type( nTime ) ~= "number" then
|
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
|
end
|
||||||
local timer = os.startTimer( nTime or 0 )
|
local timer = os.startTimer( nTime or 0 )
|
||||||
repeat
|
repeat
|
||||||
@ -169,12 +169,12 @@ end
|
|||||||
|
|
||||||
function write( sText )
|
function write( sText )
|
||||||
if type( sText ) ~= "string" and type( sText ) ~= "number" then
|
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
|
end
|
||||||
|
|
||||||
local w,h = term.getSize()
|
local w,h = term.getSize()
|
||||||
local x,y = term.getCursorPos()
|
local x,y = term.getCursorPos()
|
||||||
|
|
||||||
local nLinesPrinted = 0
|
local nLinesPrinted = 0
|
||||||
local function newLine()
|
local function newLine()
|
||||||
if y + 1 <= h then
|
if y + 1 <= h then
|
||||||
@ -186,7 +186,7 @@ function write( sText )
|
|||||||
x, y = term.getCursorPos()
|
x, y = term.getCursorPos()
|
||||||
nLinesPrinted = nLinesPrinted + 1
|
nLinesPrinted = nLinesPrinted + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Print the line with proper word wrapping
|
-- Print the line with proper word wrapping
|
||||||
while string.len(sText) > 0 do
|
while string.len(sText) > 0 do
|
||||||
local whitespace = string.match( sText, "^[ \t]+" )
|
local whitespace = string.match( sText, "^[ \t]+" )
|
||||||
@ -196,19 +196,19 @@ function write( sText )
|
|||||||
x,y = term.getCursorPos()
|
x,y = term.getCursorPos()
|
||||||
sText = string.sub( sText, string.len(whitespace) + 1 )
|
sText = string.sub( sText, string.len(whitespace) + 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
local newline = string.match( sText, "^\n" )
|
local newline = string.match( sText, "^\n" )
|
||||||
if newline then
|
if newline then
|
||||||
-- Print newlines
|
-- Print newlines
|
||||||
newLine()
|
newLine()
|
||||||
sText = string.sub( sText, 2 )
|
sText = string.sub( sText, 2 )
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = string.match( sText, "^[^ \t\n]+" )
|
local text = string.match( sText, "^[^ \t\n]+" )
|
||||||
if text then
|
if text then
|
||||||
sText = string.sub( sText, string.len(text) + 1 )
|
sText = string.sub( sText, string.len(text) + 1 )
|
||||||
if string.len(text) > w then
|
if string.len(text) > w then
|
||||||
-- Print a multiline word
|
-- Print a multiline word
|
||||||
while string.len( text ) > 0 do
|
while string.len( text ) > 0 do
|
||||||
if x > w then
|
if x > w then
|
||||||
newLine()
|
newLine()
|
||||||
@ -227,7 +227,7 @@ function write( sText )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return nLinesPrinted
|
return nLinesPrinted
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,16 +259,16 @@ end
|
|||||||
|
|
||||||
function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
||||||
if _sReplaceChar ~= nil and type( _sReplaceChar ) ~= "string" then
|
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
|
end
|
||||||
if _tHistory ~= nil and type( _tHistory ) ~= "table" then
|
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
|
end
|
||||||
if _fnComplete ~= nil and type( _fnComplete ) ~= "function" then
|
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
|
end
|
||||||
if _sDefault ~= nil and type( _sDefault ) ~= "string" then
|
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
|
end
|
||||||
term.setCursorBlink( true )
|
term.setCursorBlink( true )
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
|
|
||||||
term.setCursorPos( sx + nPos - nScroll, cy )
|
term.setCursorPos( sx + nPos - nScroll, cy )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function clear()
|
local function clear()
|
||||||
redraw( true )
|
redraw( true )
|
||||||
end
|
end
|
||||||
@ -395,7 +395,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
|
|
||||||
elseif param == keys.left then
|
elseif param == keys.left then
|
||||||
-- Left
|
-- Left
|
||||||
if nPos > 0 then
|
if nPos > 0 then
|
||||||
@ -404,9 +404,9 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == keys.right then
|
elseif param == keys.right then
|
||||||
-- Right
|
-- Right
|
||||||
if nPos < string.len(sLine) then
|
if nPos < string.len(sLine) then
|
||||||
-- Move right
|
-- Move right
|
||||||
clear()
|
clear()
|
||||||
@ -454,11 +454,11 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
nHistoryPos = nil
|
nHistoryPos = nil
|
||||||
elseif nHistoryPos ~= nil then
|
elseif nHistoryPos ~= nil then
|
||||||
nHistoryPos = nHistoryPos + 1
|
nHistoryPos = nHistoryPos + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if nHistoryPos then
|
if nHistoryPos then
|
||||||
sLine = _tHistory[nHistoryPos]
|
sLine = _tHistory[nHistoryPos]
|
||||||
nPos = string.len( sLine )
|
nPos = string.len( sLine )
|
||||||
else
|
else
|
||||||
sLine = ""
|
sLine = ""
|
||||||
nPos = 0
|
nPos = 0
|
||||||
@ -491,7 +491,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
-- Delete
|
-- Delete
|
||||||
if nPos < string.len(sLine) then
|
if nPos < string.len(sLine) then
|
||||||
clear()
|
clear()
|
||||||
sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )
|
sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 )
|
||||||
recomplete()
|
recomplete()
|
||||||
redraw()
|
redraw()
|
||||||
end
|
end
|
||||||
@ -523,16 +523,16 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault )
|
|||||||
term.setCursorBlink( false )
|
term.setCursorBlink( false )
|
||||||
term.setCursorPos( w + 1, cy )
|
term.setCursorPos( w + 1, cy )
|
||||||
print()
|
print()
|
||||||
|
|
||||||
return sLine
|
return sLine
|
||||||
end
|
end
|
||||||
|
|
||||||
loadfile = function( _sFile, _tEnv )
|
loadfile = function( _sFile, _tEnv )
|
||||||
if type( _sFile ) ~= "string" then
|
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
|
end
|
||||||
if _tEnv ~= nil and type( _tEnv ) ~= "table" then
|
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
|
end
|
||||||
local file = fs.open( _sFile, "r" )
|
local file = fs.open( _sFile, "r" )
|
||||||
if file then
|
if file then
|
||||||
@ -545,7 +545,7 @@ end
|
|||||||
|
|
||||||
dofile = function( _sFile )
|
dofile = function( _sFile )
|
||||||
if type( _sFile ) ~= "string" then
|
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
|
end
|
||||||
local fnFile, e = loadfile( _sFile, _G )
|
local fnFile, e = loadfile( _sFile, _G )
|
||||||
if fnFile then
|
if fnFile then
|
||||||
@ -558,10 +558,10 @@ end
|
|||||||
-- Install the rest of the OS api
|
-- Install the rest of the OS api
|
||||||
function os.run( _tEnv, _sPath, ... )
|
function os.run( _tEnv, _sPath, ... )
|
||||||
if type( _tEnv ) ~= "table" then
|
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
|
end
|
||||||
if type( _sPath ) ~= "string" then
|
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
|
end
|
||||||
local tArgs = table.pack( ... )
|
local tArgs = table.pack( ... )
|
||||||
local tEnv = _tEnv
|
local tEnv = _tEnv
|
||||||
@ -588,7 +588,7 @@ end
|
|||||||
local tAPIsLoading = {}
|
local tAPIsLoading = {}
|
||||||
function os.loadAPI( _sPath )
|
function os.loadAPI( _sPath )
|
||||||
if type( _sPath ) ~= "string" then
|
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
|
end
|
||||||
local sName = fs.getName( _sPath )
|
local sName = fs.getName( _sPath )
|
||||||
if sName:sub(-4) == ".lua" then
|
if sName:sub(-4) == ".lua" then
|
||||||
@ -613,7 +613,7 @@ function os.loadAPI( _sPath )
|
|||||||
tAPIsLoading[sName] = nil
|
tAPIsLoading[sName] = nil
|
||||||
return error( "Failed to load API " .. sName .. " due to " .. err, 1 )
|
return error( "Failed to load API " .. sName .. " due to " .. err, 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
local tAPI = {}
|
local tAPI = {}
|
||||||
for k,v in pairs( tEnv ) do
|
for k,v in pairs( tEnv ) do
|
||||||
if k ~= "_ENV" then
|
if k ~= "_ENV" then
|
||||||
@ -621,14 +621,14 @@ function os.loadAPI( _sPath )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
_G[sName] = tAPI
|
_G[sName] = tAPI
|
||||||
tAPIsLoading[sName] = nil
|
tAPIsLoading[sName] = nil
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
function os.unloadAPI( _sName )
|
function os.unloadAPI( _sName )
|
||||||
if type( _sName ) ~= "string" then
|
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
|
end
|
||||||
if _sName ~= "_G" and type(_G[_sName]) == "table" then
|
if _sName ~= "_G" and type(_G[_sName]) == "table" then
|
||||||
_G[_sName] = nil
|
_G[_sName] = nil
|
||||||
@ -667,7 +667,7 @@ if http then
|
|||||||
local function checkKey( options, key, ty, opt )
|
local function checkKey( options, key, ty, opt )
|
||||||
local value = options[key]
|
local value = options[key]
|
||||||
local valueTy = type(value)
|
local valueTy = type(value)
|
||||||
|
|
||||||
if (value ~= nil or not opt) and valueTy ~= ty then
|
if (value ~= nil or not opt) and valueTy ~= ty then
|
||||||
error(("bad field '%s' (expected %s, got %s"):format(key, ty, valueTy), 4)
|
error(("bad field '%s' (expected %s, got %s"):format(key, ty, valueTy), 4)
|
||||||
end
|
end
|
||||||
@ -675,8 +675,8 @@ if http then
|
|||||||
|
|
||||||
local function checkOptions( options, body )
|
local function checkOptions( options, body )
|
||||||
checkKey( options, "url", "string")
|
checkKey( options, "url", "string")
|
||||||
if body == false
|
if body == false
|
||||||
then checkKey( options, "body", "nil" )
|
then checkKey( options, "body", "nil" )
|
||||||
else checkKey( options, "body", "string", not body ) end
|
else checkKey( options, "body", "string", not body ) end
|
||||||
checkKey( options, "headers", "table", true )
|
checkKey( options, "headers", "table", true )
|
||||||
checkKey( options, "method", "string", true )
|
checkKey( options, "method", "string", true )
|
||||||
@ -701,7 +701,7 @@ if http then
|
|||||||
end
|
end
|
||||||
return nil, err
|
return nil, err
|
||||||
end
|
end
|
||||||
|
|
||||||
http.get = function( _url, _headers, _binary)
|
http.get = function( _url, _headers, _binary)
|
||||||
if type( _url ) == "table" then
|
if type( _url ) == "table" then
|
||||||
checkOptions( _url, false )
|
checkOptions( _url, false )
|
||||||
@ -709,13 +709,13 @@ if http then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if type( _url ) ~= "string" then
|
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
|
end
|
||||||
if _headers ~= nil and type( _headers ) ~= "table" then
|
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
|
end
|
||||||
if _binary ~= nil and type( _binary ) ~= "boolean" then
|
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
|
end
|
||||||
return wrapRequest( _url, _url, nil, _headers, _binary )
|
return wrapRequest( _url, _url, nil, _headers, _binary )
|
||||||
end
|
end
|
||||||
@ -727,16 +727,16 @@ if http then
|
|||||||
end
|
end
|
||||||
|
|
||||||
if type( _url ) ~= "string" then
|
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
|
end
|
||||||
if type( _post ) ~= "string" then
|
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
|
end
|
||||||
if _headers ~= nil and type( _headers ) ~= "table" then
|
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
|
end
|
||||||
if _binary ~= nil and type( _binary ) ~= "boolean" then
|
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
|
end
|
||||||
return wrapRequest( _url, _url, _post, _headers, _binary )
|
return wrapRequest( _url, _url, _post, _headers, _binary )
|
||||||
end
|
end
|
||||||
@ -748,16 +748,16 @@ if http then
|
|||||||
url = _url.url
|
url = _url.url
|
||||||
else
|
else
|
||||||
if type( _url ) ~= "string" then
|
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
|
end
|
||||||
if _post ~= nil and type( _post ) ~= "string" then
|
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
|
end
|
||||||
if _headers ~= nil and type( _headers ) ~= "table" then
|
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
|
end
|
||||||
if _binary ~= nil and type( _binary ) ~= "boolean" then
|
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
|
end
|
||||||
|
|
||||||
url = _url.url
|
url = _url.url
|
||||||
@ -769,13 +769,13 @@ if http then
|
|||||||
end
|
end
|
||||||
return ok, err
|
return ok, err
|
||||||
end
|
end
|
||||||
|
|
||||||
local nativeCheckURL = http.checkURL
|
local nativeCheckURL = http.checkURL
|
||||||
http.checkURLAsync = nativeCheckURL
|
http.checkURLAsync = nativeCheckURL
|
||||||
http.checkURL = function( _url )
|
http.checkURL = function( _url )
|
||||||
local ok, err = nativeCheckURL( _url )
|
local ok, err = nativeCheckURL( _url )
|
||||||
if not ok then return ok, err end
|
if not ok then return ok, err end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local event, url, ok, err = os.pullEvent( "http_check" )
|
local event, url, ok, err = os.pullEvent( "http_check" )
|
||||||
if url == _url then return ok, err end
|
if url == _url then return ok, err end
|
||||||
@ -809,16 +809,16 @@ end
|
|||||||
local tEmpty = {}
|
local tEmpty = {}
|
||||||
function fs.complete( sPath, sLocation, bIncludeFiles, bIncludeDirs )
|
function fs.complete( sPath, sLocation, bIncludeFiles, bIncludeDirs )
|
||||||
if type( sPath ) ~= "string" then
|
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
|
end
|
||||||
if type( sLocation ) ~= "string" then
|
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
|
end
|
||||||
if bIncludeFiles ~= nil and type( bIncludeFiles ) ~= "boolean" then
|
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
|
end
|
||||||
if bIncludeDirs ~= nil and type( bIncludeDirs ) ~= "boolean" then
|
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
|
end
|
||||||
bIncludeFiles = (bIncludeFiles ~= false)
|
bIncludeFiles = (bIncludeFiles ~= false)
|
||||||
bIncludeDirs = (bIncludeDirs ~= false)
|
bIncludeDirs = (bIncludeDirs ~= false)
|
||||||
@ -960,7 +960,7 @@ end
|
|||||||
settings.set( "shell.allow_startup", true )
|
settings.set( "shell.allow_startup", true )
|
||||||
settings.set( "shell.allow_disk_startup", (commands == nil) )
|
settings.set( "shell.allow_disk_startup", (commands == nil) )
|
||||||
settings.set( "shell.autocomplete", true )
|
settings.set( "shell.autocomplete", true )
|
||||||
settings.set( "edit.autocomplete", true )
|
settings.set( "edit.autocomplete", true )
|
||||||
settings.set( "edit.default_extension", "lua" )
|
settings.set( "edit.default_extension", "lua" )
|
||||||
settings.set( "paint.default_extension", "nfp" )
|
settings.set( "paint.default_extension", "nfp" )
|
||||||
settings.set( "lua.autocomplete", true )
|
settings.set( "lua.autocomplete", true )
|
||||||
@ -1000,7 +1000,7 @@ end
|
|||||||
|
|
||||||
-- Run the shell
|
-- Run the shell
|
||||||
local ok, err = pcall( function()
|
local ok, err = pcall( function()
|
||||||
parallel.waitForAny(
|
parallel.waitForAny(
|
||||||
function()
|
function()
|
||||||
local sShell
|
local sShell
|
||||||
if term.isColour() and settings.get( "bios.use_multishell" ) then
|
if term.isColour() and settings.get( "bios.use_multishell" ) then
|
||||||
|
@ -57,7 +57,7 @@ function rgb8( r, g, b )
|
|||||||
elseif type(r) == "number" and g == nil and b == nil then
|
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
|
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
|
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(r * 255, 0xFF), 16 ) +
|
||||||
bit32.lshift( bit32.band(g * 255, 0xFF), 8 ) +
|
bit32.lshift( bit32.band(g * 255, 0xFF), 8 ) +
|
||||||
bit32.band(b * 255, 0xFF)
|
bit32.band(b * 255, 0xFF)
|
||||||
|
@ -1,87 +1,87 @@
|
|||||||
|
|
||||||
local function isDrive( name )
|
local function isDrive( name )
|
||||||
if type( name ) ~= "string" then
|
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
|
end
|
||||||
return peripheral.getType( name ) == "drive"
|
return peripheral.getType( name ) == "drive"
|
||||||
end
|
end
|
||||||
|
|
||||||
function isPresent( name )
|
function isPresent( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
return peripheral.call( name, "isDiskPresent" )
|
return peripheral.call( name, "isDiskPresent" )
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function getLabel( name )
|
function getLabel( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
return peripheral.call( name, "getDiskLabel" )
|
return peripheral.call( name, "getDiskLabel" )
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function setLabel( name, label )
|
function setLabel( name, label )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
peripheral.call( name, "setDiskLabel", label )
|
peripheral.call( name, "setDiskLabel", label )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function hasData( name )
|
function hasData( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
return peripheral.call( name, "hasData" )
|
return peripheral.call( name, "hasData" )
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function getMountPath( name )
|
function getMountPath( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
return peripheral.call( name, "getMountPath" )
|
return peripheral.call( name, "getMountPath" )
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function hasAudio( name )
|
function hasAudio( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
return peripheral.call( name, "hasAudio" )
|
return peripheral.call( name, "hasAudio" )
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function getAudioTitle( name )
|
function getAudioTitle( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
return peripheral.call( name, "getAudioTitle" )
|
return peripheral.call( name, "getAudioTitle" )
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function playAudio( name )
|
function playAudio( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
peripheral.call( name, "playAudio" )
|
peripheral.call( name, "playAudio" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function stopAudio( name )
|
function stopAudio( name )
|
||||||
if not name then
|
if not name then
|
||||||
for n,sName in ipairs( peripheral.getNames() ) do
|
for n,sName in ipairs( peripheral.getNames() ) do
|
||||||
stopAudio( sName )
|
stopAudio( sName )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
peripheral.call( name, "stopAudio" )
|
peripheral.call( name, "stopAudio" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function eject( name )
|
function eject( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
peripheral.call( name, "ejectDisk" )
|
peripheral.call( name, "ejectDisk" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function getID( name )
|
function getID( name )
|
||||||
if isDrive( name ) then
|
if isDrive( name ) then
|
||||||
return peripheral.call( name, "getDiskID" )
|
return peripheral.call( name, "getDiskID" )
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,122 +1,121 @@
|
|||||||
|
|
||||||
CHANNEL_GPS = 65534
|
CHANNEL_GPS = 65534
|
||||||
|
|
||||||
local function trilaterate( A, B, C )
|
local function trilaterate( A, B, C )
|
||||||
local a2b = B.vPosition - A.vPosition
|
local a2b = B.vPosition - A.vPosition
|
||||||
local a2c = C.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 r1 = A.nDistance
|
if math.abs( a2b:normalize():dot( a2c:normalize() ) ) > 0.999 then
|
||||||
local r2 = B.nDistance
|
return nil
|
||||||
local r3 = C.nDistance
|
end
|
||||||
|
|
||||||
local x = (r1*r1 - r2*r2 + d*d) / (2*d)
|
local d = a2b:length()
|
||||||
local y = (r1*r1 - r3*r3 - x*x + (x-i)*(x-i) + j*j) / (2*j)
|
local ex = a2b:normalize( )
|
||||||
|
local i = ex:dot( a2c )
|
||||||
local result = A.vPosition + (ex * x) + (ey * y)
|
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
|
end
|
||||||
|
|
||||||
local function narrow( p1, p2, fix )
|
local function narrow( p1, p2, fix )
|
||||||
local dist1 = math.abs( (p1 - fix.vPosition):length() - fix.nDistance )
|
local dist1 = math.abs( (p1 - fix.vPosition):length() - fix.nDistance )
|
||||||
local dist2 = math.abs( (p2 - fix.vPosition):length() - fix.nDistance )
|
local dist2 = math.abs( (p2 - fix.vPosition):length() - fix.nDistance )
|
||||||
|
|
||||||
if math.abs(dist1 - dist2) < 0.01 then
|
if math.abs(dist1 - dist2) < 0.01 then
|
||||||
return p1, p2
|
return p1, p2
|
||||||
elseif dist1 < dist2 then
|
elseif dist1 < dist2 then
|
||||||
return p1:round( 0.01 )
|
return p1:round( 0.01 )
|
||||||
else
|
else
|
||||||
return p2:round( 0.01 )
|
return p2:round( 0.01 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function locate( _nTimeout, _bDebug )
|
function locate( _nTimeout, _bDebug )
|
||||||
if _nTimeout ~= nil and type( _nTimeout ) ~= "number" then
|
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
|
end
|
||||||
if _bDebug ~= nil and type( _bDebug ) ~= "boolean" then
|
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
|
end
|
||||||
-- Let command computers use their magic fourth-wall-breaking special abilities
|
-- Let command computers use their magic fourth-wall-breaking special abilities
|
||||||
if commands then
|
if commands then
|
||||||
return commands.getBlockPosition()
|
return commands.getBlockPosition()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Find a modem
|
-- Find a modem
|
||||||
local sModemSide = nil
|
local sModemSide = nil
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
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
|
sModemSide = sSide
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if sModemSide == nil then
|
if sModemSide == nil then
|
||||||
if _bDebug then
|
if _bDebug then
|
||||||
print( "No wireless modem attached" )
|
print( "No wireless modem attached" )
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if _bDebug then
|
if _bDebug then
|
||||||
print( "Finding position..." )
|
print( "Finding position..." )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Open a channel
|
-- Open a channel
|
||||||
local modem = peripheral.wrap( sModemSide )
|
local modem = peripheral.wrap( sModemSide )
|
||||||
local bCloseChannel = false
|
local bCloseChannel = false
|
||||||
if not modem.isOpen( os.getComputerID() ) then
|
if not modem.isOpen( os.getComputerID() ) then
|
||||||
modem.open( os.getComputerID() )
|
modem.open( os.getComputerID() )
|
||||||
bCloseChannel = true
|
bCloseChannel = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Send a ping to listening GPS hosts
|
-- Send a ping to listening GPS hosts
|
||||||
modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" )
|
modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" )
|
||||||
|
|
||||||
-- Wait for the responses
|
-- Wait for the responses
|
||||||
local tFixes = {}
|
local tFixes = {}
|
||||||
local pos1, pos2 = nil, nil
|
local pos1, pos2 = nil, nil
|
||||||
local timeout = os.startTimer( _nTimeout or 2 )
|
local timeout = os.startTimer( _nTimeout or 2 )
|
||||||
while true do
|
while true do
|
||||||
local e, p1, p2, p3, p4, p5 = os.pullEvent()
|
local e, p1, p2, p3, p4, p5 = os.pullEvent()
|
||||||
if e == "modem_message" then
|
if e == "modem_message" then
|
||||||
-- We received a reply from a modem
|
-- We received a reply from a modem
|
||||||
local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5
|
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
|
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
|
-- 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
|
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 }
|
local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance }
|
||||||
if _bDebug then
|
if _bDebug then
|
||||||
print( tFix.nDistance.." metres from "..tostring( tFix.vPosition ) )
|
print( tFix.nDistance.." metres from "..tostring( tFix.vPosition ) )
|
||||||
end
|
end
|
||||||
if tFix.nDistance == 0 then
|
if tFix.nDistance == 0 then
|
||||||
pos1, pos2 = tFix.vPosition, nil
|
pos1, pos2 = tFix.vPosition, nil
|
||||||
else
|
else
|
||||||
table.insert( tFixes, tFix )
|
table.insert( tFixes, tFix )
|
||||||
if #tFixes >= 3 then
|
if #tFixes >= 3 then
|
||||||
if not pos1 then
|
if not pos1 then
|
||||||
@ -126,43 +125,43 @@ function locate( _nTimeout, _bDebug )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if pos1 and not pos2 then
|
if pos1 and not pos2 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif e == "timer" then
|
elseif e == "timer" then
|
||||||
-- We received a timeout
|
-- We received a timeout
|
||||||
local timer = p1
|
local timer = p1
|
||||||
if timer == timeout then
|
if timer == timeout then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Close the channel, if we opened one
|
-- Close the channel, if we opened one
|
||||||
if bCloseChannel then
|
if bCloseChannel then
|
||||||
modem.close( os.getComputerID() )
|
modem.close( os.getComputerID() )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Return the response
|
-- Return the response
|
||||||
if pos1 and pos2 then
|
if pos1 and pos2 then
|
||||||
if _bDebug then
|
if _bDebug then
|
||||||
print( "Ambiguous position" )
|
print( "Ambiguous position" )
|
||||||
print( "Could be "..pos1.x..","..pos1.y..","..pos1.z.." or "..pos2.x..","..pos2.y..","..pos2.z )
|
print( "Could be "..pos1.x..","..pos1.y..","..pos1.z.." or "..pos2.x..","..pos2.y..","..pos2.z )
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
elseif pos1 then
|
elseif pos1 then
|
||||||
if _bDebug then
|
if _bDebug then
|
||||||
print( "Position is "..pos1.x..","..pos1.y..","..pos1.z )
|
print( "Position is "..pos1.x..","..pos1.y..","..pos1.z )
|
||||||
end
|
end
|
||||||
return pos1.x, pos1.y, pos1.z
|
return pos1.x, pos1.y, pos1.z
|
||||||
else
|
else
|
||||||
if _bDebug then
|
if _bDebug then
|
||||||
print( "Could not determine position" )
|
print( "Could not determine position" )
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2,69 +2,69 @@
|
|||||||
local sPath = "/rom/help"
|
local sPath = "/rom/help"
|
||||||
|
|
||||||
function path()
|
function path()
|
||||||
return sPath
|
return sPath
|
||||||
end
|
end
|
||||||
|
|
||||||
function setPath( _sPath )
|
function setPath( _sPath )
|
||||||
if type( _sPath ) ~= "string" then
|
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
|
end
|
||||||
sPath = _sPath
|
sPath = _sPath
|
||||||
end
|
end
|
||||||
|
|
||||||
function lookup( _sTopic )
|
function lookup( _sTopic )
|
||||||
if type( _sTopic ) ~= "string" then
|
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
|
end
|
||||||
-- Look on the path variable
|
-- Look on the path variable
|
||||||
for sPath in string.gmatch(sPath, "[^:]+") do
|
for sPath in string.gmatch(sPath, "[^:]+") do
|
||||||
sPath = fs.combine( sPath, _sTopic )
|
sPath = fs.combine( sPath, _sTopic )
|
||||||
if fs.exists( sPath ) and not fs.isDir( sPath ) then
|
if fs.exists( sPath ) and not fs.isDir( sPath ) then
|
||||||
return sPath
|
return sPath
|
||||||
elseif fs.exists( sPath..".txt" ) and not fs.isDir( sPath..".txt" ) then
|
elseif fs.exists( sPath..".txt" ) and not fs.isDir( sPath..".txt" ) then
|
||||||
return sPath..".txt"
|
return sPath..".txt"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Not found
|
-- Not found
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function topics()
|
function topics()
|
||||||
-- Add index
|
-- Add index
|
||||||
local tItems = {
|
local tItems = {
|
||||||
[ "index" ] = true
|
[ "index" ] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Add topics from the path
|
-- Add topics from the path
|
||||||
for sPath in string.gmatch(sPath, "[^:]+") do
|
for sPath in string.gmatch(sPath, "[^:]+") do
|
||||||
if fs.isDir( sPath ) then
|
if fs.isDir( sPath ) then
|
||||||
local tList = fs.list( sPath )
|
local tList = fs.list( sPath )
|
||||||
for n,sFile in pairs( tList ) do
|
for n,sFile in pairs( tList ) do
|
||||||
if string.sub( sFile, 1, 1 ) ~= "." then
|
if string.sub( sFile, 1, 1 ) ~= "." then
|
||||||
if not fs.isDir( fs.combine( sPath, sFile ) ) then
|
if not fs.isDir( fs.combine( sPath, sFile ) ) then
|
||||||
if #sFile > 4 and sFile:sub(-4) == ".txt" then
|
if #sFile > 4 and sFile:sub(-4) == ".txt" then
|
||||||
sFile = sFile:sub(1,-5)
|
sFile = sFile:sub(1,-5)
|
||||||
end
|
end
|
||||||
tItems[ sFile ] = true
|
tItems[ sFile ] = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sort and return
|
-- Sort and return
|
||||||
local tItemList = {}
|
local tItemList = {}
|
||||||
for sItem, b in pairs( tItems ) do
|
for sItem, b in pairs( tItems ) do
|
||||||
table.insert( tItemList, sItem )
|
table.insert( tItemList, sItem )
|
||||||
end
|
end
|
||||||
table.sort( tItemList )
|
table.sort( tItemList )
|
||||||
return tItemList
|
return tItemList
|
||||||
end
|
end
|
||||||
|
|
||||||
function completeTopic( sText )
|
function completeTopic( sText )
|
||||||
if type( sText ) ~= "string" then
|
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
|
end
|
||||||
local tTopics = topics()
|
local tTopics = topics()
|
||||||
local tResults = {}
|
local tResults = {}
|
||||||
@ -74,7 +74,5 @@ function completeTopic( sText )
|
|||||||
table.insert( tResults, string.sub( sTopic, #sText + 1 ) )
|
table.insert( tResults, string.sub( sTopic, #sText + 1 ) )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return tResults
|
return tResults
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ function lines(_sFileName)
|
|||||||
local ok, err = open(_sFileName, "rb")
|
local ok, err = open(_sFileName, "rb")
|
||||||
if not ok then error(err, 2) end
|
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
|
-- closed automatically
|
||||||
ok._autoclose = true
|
ok._autoclose = true
|
||||||
return ok:lines()
|
return ok:lines()
|
||||||
|
@ -3,54 +3,54 @@
|
|||||||
-- See http://www.minecraftwiki.net/wiki/Key_codes for more info
|
-- See http://www.minecraftwiki.net/wiki/Key_codes for more info
|
||||||
|
|
||||||
local tKeys = {
|
local tKeys = {
|
||||||
nil, "one", "two", "three", "four", -- 1
|
nil, "one", "two", "three", "four", -- 1
|
||||||
"five", "six", "seven", "eight", "nine", -- 6
|
"five", "six", "seven", "eight", "nine", -- 6
|
||||||
"zero", "minus", "equals", "backspace","tab", -- 11
|
"zero", "minus", "equals", "backspace","tab", -- 11
|
||||||
"q", "w", "e", "r", "t", -- 16
|
"q", "w", "e", "r", "t", -- 16
|
||||||
"y", "u", "i", "o", "p", -- 21
|
"y", "u", "i", "o", "p", -- 21
|
||||||
"leftBracket","rightBracket","enter","leftCtrl","a", -- 26
|
"leftBracket","rightBracket","enter","leftCtrl","a", -- 26
|
||||||
"s", "d", "f", "g", "h", -- 31
|
"s", "d", "f", "g", "h", -- 31
|
||||||
"j", "k", "l", "semiColon","apostrophe", -- 36
|
"j", "k", "l", "semiColon","apostrophe", -- 36
|
||||||
"grave", "leftShift","backslash","z", "x", -- 41
|
"grave", "leftShift","backslash","z", "x", -- 41
|
||||||
"c", "v", "b", "n", "m", -- 46
|
"c", "v", "b", "n", "m", -- 46
|
||||||
"comma", "period", "slash", "rightShift","multiply", -- 51
|
"comma", "period", "slash", "rightShift","multiply", -- 51
|
||||||
"leftAlt", "space", "capsLock", "f1", "f2", -- 56
|
"leftAlt", "space", "capsLock", "f1", "f2", -- 56
|
||||||
"f3", "f4", "f5", "f6", "f7", -- 61
|
"f3", "f4", "f5", "f6", "f7", -- 61
|
||||||
"f8", "f9", "f10", "numLock", "scrollLock", -- 66
|
"f8", "f9", "f10", "numLock", "scrollLock", -- 66
|
||||||
"numPad7", "numPad8", "numPad9", "numPadSubtract","numPad4", -- 71
|
"numPad7", "numPad8", "numPad9", "numPadSubtract","numPad4", -- 71
|
||||||
"numPad5", "numPad6", "numPadAdd","numPad1", "numPad2", -- 76
|
"numPad5", "numPad6", "numPadAdd","numPad1", "numPad2", -- 76
|
||||||
"numPad3", "numPad0", "numPadDecimal",nil, nil, -- 81
|
"numPad3", "numPad0", "numPadDecimal",nil, nil, -- 81
|
||||||
nil, "f11", "f12", nil, nil, -- 86
|
nil, "f11", "f12", nil, nil, -- 86
|
||||||
nil, nil, nil, nil, nil, -- 91
|
nil, nil, nil, nil, nil, -- 91
|
||||||
nil, nil, nil, nil, "f13", -- 96
|
nil, nil, nil, nil, "f13", -- 96
|
||||||
"f14", "f15", nil, nil, nil, -- 101
|
"f14", "f15", nil, nil, nil, -- 101
|
||||||
nil, nil, nil, nil, nil, -- 106
|
nil, nil, nil, nil, nil, -- 106
|
||||||
nil, "kana", nil, nil, nil, -- 111
|
nil, "kana", nil, nil, nil, -- 111
|
||||||
nil, nil, nil, nil, nil, -- 116
|
nil, nil, nil, nil, nil, -- 116
|
||||||
"convert", nil, "noconvert",nil, "yen", -- 121
|
"convert", nil, "noconvert",nil, "yen", -- 121
|
||||||
nil, nil, nil, nil, nil, -- 126
|
nil, nil, nil, nil, nil, -- 126
|
||||||
nil, nil, nil, nil, nil, -- 131
|
nil, nil, nil, nil, nil, -- 131
|
||||||
nil, nil, nil, nil, nil, -- 136
|
nil, nil, nil, nil, nil, -- 136
|
||||||
"numPadEquals",nil, nil, "circumflex","at", -- 141
|
"numPadEquals",nil, nil, "circumflex","at", -- 141
|
||||||
"colon", "underscore","kanji", "stop", "ax", -- 146
|
"colon", "underscore","kanji", "stop", "ax", -- 146
|
||||||
nil, nil, nil, nil, nil, -- 151
|
nil, nil, nil, nil, nil, -- 151
|
||||||
"numPadEnter","rightCtrl",nil, nil, nil, -- 156
|
"numPadEnter","rightCtrl",nil, nil, nil, -- 156
|
||||||
nil, nil, nil, nil, nil, -- 161
|
nil, nil, nil, nil, nil, -- 161
|
||||||
nil, nil, nil, nil, nil, -- 166
|
nil, nil, nil, nil, nil, -- 166
|
||||||
nil, nil, nil, nil, nil, -- 171
|
nil, nil, nil, nil, nil, -- 171
|
||||||
nil, nil, nil, "numPadComma",nil, -- 176
|
nil, nil, nil, "numPadComma",nil, -- 176
|
||||||
"numPadDivide",nil, nil, "rightAlt", nil, -- 181
|
"numPadDivide",nil, nil, "rightAlt", nil, -- 181
|
||||||
nil, nil, nil, nil, nil, -- 186
|
nil, nil, nil, nil, nil, -- 186
|
||||||
nil, nil, nil, nil, nil, -- 191
|
nil, nil, nil, nil, nil, -- 191
|
||||||
nil, "pause", nil, "home", "up", -- 196
|
nil, "pause", nil, "home", "up", -- 196
|
||||||
"pageUp", nil, "left", nil, "right", -- 201
|
"pageUp", nil, "left", nil, "right", -- 201
|
||||||
nil, "end", "down", "pageDown", "insert", -- 206
|
nil, "end", "down", "pageDown", "insert", -- 206
|
||||||
"delete" -- 211
|
"delete" -- 211
|
||||||
}
|
}
|
||||||
|
|
||||||
local keys = _ENV
|
local keys = _ENV
|
||||||
for nKey, sKey in pairs( tKeys ) do
|
for nKey, sKey in pairs( tKeys ) do
|
||||||
keys[sKey] = nKey
|
keys[sKey] = nKey
|
||||||
end
|
end
|
||||||
keys["return"] = keys.enter
|
keys["return"] = keys.enter
|
||||||
--backwards compatibility to earlier, typo prone, versions
|
--backwards compatibility to earlier, typo prone, versions
|
||||||
@ -59,7 +59,7 @@ keys.cimcumflex = keys.circumflex
|
|||||||
|
|
||||||
function getName( _nKey )
|
function getName( _nKey )
|
||||||
if type( _nKey ) ~= "number" then
|
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
|
end
|
||||||
return tKeys[ _nKey ]
|
return tKeys[ _nKey ]
|
||||||
end
|
end
|
||||||
|
@ -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( 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 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
|
if nColour ~= nil and type( nColour ) ~= "number" then error( "bad argument #5 (expected number, got " .. type( nColour ) .. ")", 2 ) end
|
||||||
|
|
||||||
startX = math.floor(startX)
|
startX = math.floor(startX)
|
||||||
startY = math.floor(startY)
|
startY = math.floor(startY)
|
||||||
endX = math.floor(endX)
|
endX = math.floor(endX)
|
||||||
@ -71,7 +71,7 @@ function drawLine( startX, startY, endX, endY, nColour )
|
|||||||
drawPixelInternal( startX, startY )
|
drawPixelInternal( startX, startY )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local minX = math.min( startX, endX )
|
local minX = math.min( startX, endX )
|
||||||
local maxX, minY, maxY
|
local maxX, minY, maxY
|
||||||
if minX == startX then
|
if minX == startX then
|
||||||
@ -85,10 +85,10 @@ function drawLine( startX, startY, endX, endY, nColour )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: clip to screen rectangle?
|
-- TODO: clip to screen rectangle?
|
||||||
|
|
||||||
local xDiff = maxX - minX
|
local xDiff = maxX - minX
|
||||||
local yDiff = maxY - minY
|
local yDiff = maxY - minY
|
||||||
|
|
||||||
if xDiff > math.abs(yDiff) then
|
if xDiff > math.abs(yDiff) then
|
||||||
local y = minY
|
local y = minY
|
||||||
local dy = yDiff / xDiff
|
local dy = yDiff / xDiff
|
||||||
@ -134,7 +134,7 @@ function drawBox( startX, startY, endX, endY, nColour )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local minX = math.min( startX, endX )
|
local minX = math.min( startX, endX )
|
||||||
local maxX, minY, maxY
|
local maxX, minY, maxY
|
||||||
if minX == startX then
|
if minX == startX then
|
||||||
minY = startY
|
minY = startY
|
||||||
maxX = endX
|
maxX = endX
|
||||||
|
@ -4,54 +4,54 @@ local function create( ... )
|
|||||||
local tCos = {}
|
local tCos = {}
|
||||||
for i = 1, tFns.n, 1 do
|
for i = 1, tFns.n, 1 do
|
||||||
local fn = tFns[i]
|
local fn = tFns[i]
|
||||||
if type( fn ) ~= "function" then
|
if type( fn ) ~= "function" then
|
||||||
error( "bad argument #" .. i .. " (expected function, got " .. type( fn ) .. ")", 3 )
|
error( "bad argument #" .. i .. " (expected function, got " .. type( fn ) .. ")", 3 )
|
||||||
end
|
end
|
||||||
|
|
||||||
tCos[i] = coroutine.create(fn)
|
tCos[i] = coroutine.create(fn)
|
||||||
end
|
end
|
||||||
|
|
||||||
return tCos
|
return tCos
|
||||||
end
|
end
|
||||||
|
|
||||||
local function runUntilLimit( _routines, _limit )
|
local function runUntilLimit( _routines, _limit )
|
||||||
local count = #_routines
|
local count = #_routines
|
||||||
local living = count
|
local living = count
|
||||||
|
|
||||||
local tFilters = {}
|
local tFilters = {}
|
||||||
local eventData = { n = 0 }
|
local eventData = { n = 0 }
|
||||||
while true do
|
while true do
|
||||||
for n=1,count do
|
for n=1,count do
|
||||||
local r = _routines[n]
|
local r = _routines[n]
|
||||||
if r then
|
if r then
|
||||||
if tFilters[r] == nil or tFilters[r] == eventData[1] or eventData[1] == "terminate" 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 ) )
|
local ok, param = coroutine.resume( r, table.unpack( eventData, 1, eventData.n ) )
|
||||||
if not ok then
|
if not ok then
|
||||||
error( param, 0 )
|
error( param, 0 )
|
||||||
else
|
else
|
||||||
tFilters[r] = param
|
tFilters[r] = param
|
||||||
end
|
end
|
||||||
if coroutine.status( r ) == "dead" then
|
if coroutine.status( r ) == "dead" then
|
||||||
_routines[n] = nil
|
_routines[n] = nil
|
||||||
living = living - 1
|
living = living - 1
|
||||||
if living <= _limit then
|
if living <= _limit then
|
||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for n=1,count do
|
for n=1,count do
|
||||||
local r = _routines[n]
|
local r = _routines[n]
|
||||||
if r and coroutine.status( r ) == "dead" then
|
if r and coroutine.status( r ) == "dead" then
|
||||||
_routines[n] = nil
|
_routines[n] = nil
|
||||||
living = living - 1
|
living = living - 1
|
||||||
if living <= _limit then
|
if living <= _limit then
|
||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
eventData = table.pack( os.pullEventRaw() )
|
eventData = table.pack( os.pullEventRaw() )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -62,5 +62,5 @@ end
|
|||||||
|
|
||||||
function waitForAll( ... )
|
function waitForAll( ... )
|
||||||
local routines = create( ... )
|
local routines = create( ... )
|
||||||
runUntilLimit( routines, 0 )
|
runUntilLimit( routines, 0 )
|
||||||
end
|
end
|
||||||
|
@ -1,70 +1,70 @@
|
|||||||
local native = peripheral
|
local native = peripheral
|
||||||
|
|
||||||
function getNames()
|
function getNames()
|
||||||
local tResults = {}
|
local tResults = {}
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for n,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.isPresent( sSide ) then
|
if native.isPresent( sSide ) then
|
||||||
table.insert( tResults, sSide )
|
table.insert( tResults, sSide )
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
local tRemote = native.call( sSide, "getNamesRemote" )
|
local tRemote = native.call( sSide, "getNamesRemote" )
|
||||||
for n,sName in ipairs( tRemote ) do
|
for n,sName in ipairs( tRemote ) do
|
||||||
table.insert( tResults, sName )
|
table.insert( tResults, sName )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return tResults
|
return tResults
|
||||||
end
|
end
|
||||||
|
|
||||||
function isPresent( _sSide )
|
function isPresent( _sSide )
|
||||||
if type( _sSide ) ~= "string" then
|
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
|
end
|
||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for n,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function getType( _sSide )
|
function getType( _sSide )
|
||||||
if type( _sSide ) ~= "string" then
|
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
|
end
|
||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return native.getType( _sSide )
|
return native.getType( _sSide )
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for n,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return native.call( sSide, "getTypeRemote", _sSide )
|
return native.call( sSide, "getTypeRemote", _sSide )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function getMethods( _sSide )
|
function getMethods( _sSide )
|
||||||
if type( _sSide ) ~= "string" then
|
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
|
end
|
||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return native.getMethods( _sSide )
|
return native.getMethods( _sSide )
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for n,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return native.call( sSide, "getMethodsRemote", _sSide )
|
return native.call( sSide, "getMethodsRemote", _sSide )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function call( _sSide, _sMethod, ... )
|
function call( _sSide, _sMethod, ... )
|
||||||
@ -74,34 +74,34 @@ function call( _sSide, _sMethod, ... )
|
|||||||
if type( _sSide ) ~= "string" then
|
if type( _sSide ) ~= "string" then
|
||||||
error( "bad argument #2 (expected string, got " .. type( _sMethod ) .. ")", 2 )
|
error( "bad argument #2 (expected string, got " .. type( _sMethod ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
if native.isPresent( _sSide ) then
|
if native.isPresent( _sSide ) then
|
||||||
return native.call( _sSide, _sMethod, ... )
|
return native.call( _sSide, _sMethod, ... )
|
||||||
end
|
end
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for n,sSide in ipairs( rs.getSides() ) do
|
||||||
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then
|
||||||
if native.call( sSide, "isPresentRemote", _sSide ) then
|
if native.call( sSide, "isPresentRemote", _sSide ) then
|
||||||
return native.call( sSide, "callRemote", _sSide, _sMethod, ... )
|
return native.call( sSide, "callRemote", _sSide, _sMethod, ... )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function wrap( _sSide )
|
function wrap( _sSide )
|
||||||
if type( _sSide ) ~= "string" then
|
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
|
end
|
||||||
if peripheral.isPresent( _sSide ) then
|
if peripheral.isPresent( _sSide ) then
|
||||||
local tMethods = peripheral.getMethods( _sSide )
|
local tMethods = peripheral.getMethods( _sSide )
|
||||||
local tResult = {}
|
local tResult = {}
|
||||||
for n,sMethod in ipairs( tMethods ) do
|
for n,sMethod in ipairs( tMethods ) do
|
||||||
tResult[sMethod] = function( ... )
|
tResult[sMethod] = function( ... )
|
||||||
return peripheral.call( _sSide, sMethod, ... )
|
return peripheral.call( _sSide, sMethod, ... )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return tResult
|
return tResult
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function find( sType, fnFilter )
|
function find( sType, fnFilter )
|
||||||
@ -111,14 +111,14 @@ function find( sType, fnFilter )
|
|||||||
if fnFilter ~= nil and type( fnFilter ) ~= "function" then
|
if fnFilter ~= nil and type( fnFilter ) ~= "function" then
|
||||||
error( "bad argument #2 (expected function, got " .. type( fnFilter ) .. ")", 2 )
|
error( "bad argument #2 (expected function, got " .. type( fnFilter ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
local tResults = {}
|
local tResults = {}
|
||||||
for n,sName in ipairs( peripheral.getNames() ) do
|
for n,sName in ipairs( peripheral.getNames() ) do
|
||||||
if peripheral.getType( sName ) == sType then
|
if peripheral.getType( sName ) == sType then
|
||||||
local wrapped = peripheral.wrap( sName )
|
local wrapped = peripheral.wrap( sName )
|
||||||
if fnFilter == nil or fnFilter( sName, wrapped ) then
|
if fnFilter == nil or fnFilter( sName, wrapped ) then
|
||||||
table.insert( tResults, wrapped )
|
table.insert( tResults, wrapped )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return table.unpack( tResults )
|
return table.unpack( tResults )
|
||||||
end
|
end
|
||||||
|
@ -10,7 +10,7 @@ function open( sModem )
|
|||||||
if type( sModem ) ~= "string" then
|
if type( sModem ) ~= "string" then
|
||||||
error( "bad argument #1 (expected string, got " .. type( sModem ) .. ")", 2 )
|
error( "bad argument #1 (expected string, got " .. type( sModem ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
if peripheral.getType( sModem ) ~= "modem" then
|
if peripheral.getType( sModem ) ~= "modem" then
|
||||||
error( "No such modem: "..sModem, 2 )
|
error( "No such modem: "..sModem, 2 )
|
||||||
end
|
end
|
||||||
peripheral.call( sModem, "open", os.getComputerID() )
|
peripheral.call( sModem, "open", os.getComputerID() )
|
||||||
@ -244,7 +244,7 @@ function run()
|
|||||||
error( "rednet is already running", 2 )
|
error( "rednet is already running", 2 )
|
||||||
end
|
end
|
||||||
bRunning = true
|
bRunning = true
|
||||||
|
|
||||||
while bRunning do
|
while bRunning do
|
||||||
local sEvent, p1, p2, p3, p4 = os.pullEventRaw()
|
local sEvent, p1, p2, p3, p4 = os.pullEventRaw()
|
||||||
if sEvent == "modem_message" then
|
if sEvent == "modem_message" then
|
||||||
|
@ -3,10 +3,10 @@ local tSettings = {}
|
|||||||
|
|
||||||
function set( sName, value )
|
function set( sName, value )
|
||||||
if type( sName ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) end
|
if type( sName ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) end
|
||||||
|
|
||||||
local sValueTy = type(value)
|
local sValueTy = type(value)
|
||||||
if sValueTy ~= "number" and sValueTy ~= "string" and sValueTy ~= "boolean" and sValueTy ~= "table" then
|
if sValueTy ~= "number" and sValueTy ~= "string" and sValueTy ~= "boolean" and sValueTy ~= "table" then
|
||||||
error( "bad argument #2 (expected value, got " .. sValueTy .. ")", 2 )
|
error( "bad argument #2 (expected value, got " .. sValueTy .. ")", 2 )
|
||||||
end
|
end
|
||||||
if sValueTy == "table" then
|
if sValueTy == "table" then
|
||||||
-- Ensure value is serializeable
|
-- Ensure value is serializeable
|
||||||
@ -30,7 +30,7 @@ end
|
|||||||
|
|
||||||
function get( sName, default )
|
function get( sName, default )
|
||||||
if type(sName) ~= "string" then
|
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
|
end
|
||||||
local result = tSettings[ sName ]
|
local result = tSettings[ sName ]
|
||||||
if result ~= nil then
|
if result ~= nil then
|
||||||
@ -42,7 +42,7 @@ end
|
|||||||
|
|
||||||
function unset( sName )
|
function unset( sName )
|
||||||
if type(sName) ~= "string" then
|
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
|
end
|
||||||
tSettings[ sName ] = nil
|
tSettings[ sName ] = nil
|
||||||
end
|
end
|
||||||
@ -62,7 +62,7 @@ end
|
|||||||
|
|
||||||
function load( sPath )
|
function load( sPath )
|
||||||
if type(sPath) ~= "string" then
|
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
|
end
|
||||||
local file = fs.open( sPath, "r" )
|
local file = fs.open( sPath, "r" )
|
||||||
if not file then
|
if not file then
|
||||||
@ -89,7 +89,7 @@ end
|
|||||||
|
|
||||||
function save( sPath )
|
function save( sPath )
|
||||||
if type(sPath) ~= "string" then
|
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
|
end
|
||||||
local file = fs.open( sPath, "w" )
|
local file = fs.open( sPath, "w" )
|
||||||
if not file then
|
if not file then
|
||||||
|
@ -3,32 +3,32 @@ local native = (term.native and term.native()) or term
|
|||||||
local redirectTarget = native
|
local redirectTarget = native
|
||||||
|
|
||||||
local function wrap( _sFunction )
|
local function wrap( _sFunction )
|
||||||
return function( ... )
|
return function( ... )
|
||||||
return redirectTarget[ _sFunction ]( ... )
|
return redirectTarget[ _sFunction ]( ... )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local term = {}
|
local term = {}
|
||||||
|
|
||||||
term.redirect = function( target )
|
term.redirect = function( target )
|
||||||
if type( target ) ~= "table" then
|
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
|
end
|
||||||
if target == term then
|
if target == term then
|
||||||
error( "term is not a recommended redirect target, try term.current() instead", 2 )
|
error( "term is not a recommended redirect target, try term.current() instead", 2 )
|
||||||
end
|
end
|
||||||
for k,v in pairs( native ) do
|
for k,v in pairs( native ) do
|
||||||
if type( k ) == "string" and type( v ) == "function" then
|
if type( k ) == "string" and type( v ) == "function" then
|
||||||
if type( target[k] ) ~= "function" then
|
if type( target[k] ) ~= "function" then
|
||||||
target[k] = function()
|
target[k] = function()
|
||||||
error( "Redirect object is missing method "..k..".", 2 )
|
error( "Redirect object is missing method "..k..".", 2 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local oldRedirectTarget = redirectTarget
|
local oldRedirectTarget = redirectTarget
|
||||||
redirectTarget = target
|
redirectTarget = target
|
||||||
return oldRedirectTarget
|
return oldRedirectTarget
|
||||||
end
|
end
|
||||||
|
|
||||||
term.current = function()
|
term.current = function()
|
||||||
@ -43,14 +43,14 @@ term.native = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
for k,v in pairs( native ) do
|
for k,v in pairs( native ) do
|
||||||
if type( k ) == "string" and type( v ) == "function" then
|
if type( k ) == "string" and type( v ) == "function" then
|
||||||
if term[k] == nil then
|
if term[k] == nil then
|
||||||
term[k] = wrap( k )
|
term[k] = wrap( k )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local env = _ENV
|
local env = _ENV
|
||||||
for k,v in pairs( term ) do
|
for k,v in pairs( term ) do
|
||||||
env[k] = v
|
env[k] = v
|
||||||
end
|
end
|
||||||
|
@ -8,11 +8,11 @@ function slowWrite( sText, nRate )
|
|||||||
error( "Rate must be positive", 2 )
|
error( "Rate must be positive", 2 )
|
||||||
end
|
end
|
||||||
local nSleep = 1 / nRate
|
local nSleep = 1 / nRate
|
||||||
|
|
||||||
sText = tostring( sText )
|
sText = tostring( sText )
|
||||||
local x,y = term.getCursorPos()
|
local x,y = term.getCursorPos()
|
||||||
local len = string.len( sText )
|
local len = string.len( sText )
|
||||||
|
|
||||||
for n=1,len do
|
for n=1,len do
|
||||||
term.setCursorPos( x, y )
|
term.setCursorPos( x, y )
|
||||||
sleep( nSleep )
|
sleep( nSleep )
|
||||||
@ -32,7 +32,7 @@ function formatTime( nTime, bTwentyFourHour )
|
|||||||
error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 )
|
error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
if bTwentyFourHour ~= nil and type( bTwentyFourHour ) ~= "boolean" then
|
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
|
end
|
||||||
local sTOD = nil
|
local sTOD = nil
|
||||||
if not bTwentyFourHour then
|
if not bTwentyFourHour then
|
||||||
@ -61,7 +61,7 @@ local function makePagedScroll( _term, _nFreeLines )
|
|||||||
return function( _n )
|
return function( _n )
|
||||||
for n=1,_n do
|
for n=1,_n do
|
||||||
nativeScroll( 1 )
|
nativeScroll( 1 )
|
||||||
|
|
||||||
if nFreeLines <= 0 then
|
if nFreeLines <= 0 then
|
||||||
local w,h = _term.getSize()
|
local w,h = _term.getSize()
|
||||||
_term.setCursorPos( 1, h )
|
_term.setCursorPos( 1, h )
|
||||||
@ -78,7 +78,7 @@ end
|
|||||||
|
|
||||||
function pagedPrint( _sText, _nFreeLines )
|
function pagedPrint( _sText, _nFreeLines )
|
||||||
if _nFreeLines ~= nil and type( _nFreeLines ) ~= "number" then
|
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
|
end
|
||||||
-- Setup a redirector
|
-- Setup a redirector
|
||||||
local oldTerm = term.current()
|
local oldTerm = term.current()
|
||||||
@ -113,17 +113,17 @@ local function tabulateCommon( bPaged, ... )
|
|||||||
local tAll = { ... }
|
local tAll = { ... }
|
||||||
for k,v in ipairs( tAll ) do
|
for k,v in ipairs( tAll ) do
|
||||||
if type( v ) ~= "number" and type( v ) ~= "table" then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
local w,h = term.getSize()
|
local w,h = term.getSize()
|
||||||
local nMaxLen = w / 8
|
local nMaxLen = w / 8
|
||||||
for n, t in ipairs( tAll ) do
|
for n, t in ipairs( tAll ) do
|
||||||
if type(t) == "table" then
|
if type(t) == "table" then
|
||||||
for nu, sItem in pairs(t) do
|
for nu, sItem in pairs(t) do
|
||||||
if type( sItem ) ~= "string" then
|
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
|
end
|
||||||
nMaxLen = math.max( string.len( sItem ) + 1, nMaxLen )
|
nMaxLen = math.max( string.len( sItem ) + 1, nMaxLen )
|
||||||
end
|
end
|
||||||
@ -139,7 +139,7 @@ local function tabulateCommon( bPaged, ... )
|
|||||||
end
|
end
|
||||||
nLines = nLines + 1
|
nLines = nLines + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local function drawCols( _t )
|
local function drawCols( _t )
|
||||||
local nCol = 1
|
local nCol = 1
|
||||||
for n, s in ipairs( _t ) do
|
for n, s in ipairs( _t ) do
|
||||||
@ -153,7 +153,7 @@ local function tabulateCommon( bPaged, ... )
|
|||||||
term.setCursorPos( cx, cy )
|
term.setCursorPos( cx, cy )
|
||||||
term.write( s )
|
term.write( s )
|
||||||
|
|
||||||
nCol = nCol + 1
|
nCol = nCol + 1
|
||||||
end
|
end
|
||||||
print()
|
print()
|
||||||
end
|
end
|
||||||
@ -165,7 +165,7 @@ local function tabulateCommon( bPaged, ... )
|
|||||||
elseif type(t) == "number" then
|
elseif type(t) == "number" then
|
||||||
term.setTextColor( t )
|
term.setTextColor( t )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function tabulate( ... )
|
function tabulate( ... )
|
||||||
@ -234,16 +234,16 @@ local function serializeImpl( t, tTracking, sIndent )
|
|||||||
sResult = sResult .. sIndent .. "}"
|
sResult = sResult .. sIndent .. "}"
|
||||||
return sResult
|
return sResult
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif sType == "string" then
|
elseif sType == "string" then
|
||||||
return string.format( "%q", t )
|
return string.format( "%q", t )
|
||||||
|
|
||||||
elseif sType == "number" or sType == "boolean" or sType == "nil" then
|
elseif sType == "number" or sType == "boolean" or sType == "nil" then
|
||||||
return tostring(t)
|
return tostring(t)
|
||||||
|
|
||||||
else
|
else
|
||||||
error( "Cannot serialize type "..sType, 0 )
|
error( "Cannot serialize type "..sType, 0 )
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -365,7 +365,7 @@ function urlEncode( str )
|
|||||||
end )
|
end )
|
||||||
str = string.gsub(str, " ", "+")
|
str = string.gsub(str, " ", "+")
|
||||||
end
|
end
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
local tEmpty = {}
|
local tEmpty = {}
|
||||||
@ -403,7 +403,7 @@ function complete( sSearchText, tSearchTable )
|
|||||||
return tEmpty
|
return tEmpty
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sPart = string.sub( sSearchText, nStart )
|
local sPart = string.sub( sSearchText, nStart )
|
||||||
local nPartLength = string.len( sPart )
|
local nPartLength = string.len( sPart )
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
if not turtle then
|
if not turtle then
|
||||||
error( "Cannot load turtle API on computer", 2 )
|
error( "Cannot load turtle API on computer", 2 )
|
||||||
end
|
end
|
||||||
native = turtle.native or turtle
|
native = turtle.native or turtle
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ for k,v in pairs( native ) do
|
|||||||
return result, err
|
return result, err
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
env[k] = v
|
env[k] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
addCraftMethod( env )
|
addCraftMethod( env )
|
||||||
|
@ -84,11 +84,11 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
parent.setCursorPos( 0, 0 )
|
parent.setCursorPos( 0, 0 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateCursorBlink()
|
local function updateCursorBlink()
|
||||||
parent.setCursorBlink( bCursorBlink )
|
parent.setCursorBlink( bCursorBlink )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function updateCursorColor()
|
local function updateCursorColor()
|
||||||
parent.setTextColor( nTextColor )
|
parent.setTextColor( nTextColor )
|
||||||
end
|
end
|
||||||
@ -275,7 +275,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function setTextColor( color )
|
local function setTextColor( color )
|
||||||
if type( color ) ~= "number" then
|
if type( color ) ~= "number" then
|
||||||
error( "bad argument #1 (expected number, got " .. type( color ) .. ")", 2 )
|
error( "bad argument #1 (expected number, got " .. type( color ) .. ")", 2 )
|
||||||
elseif tHex[color] == nil then
|
elseif tHex[color] == nil then
|
||||||
error( "Invalid color (got " .. color .. ")" , 2 )
|
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 )
|
function window.setPaletteColour( colour, r, g, b )
|
||||||
if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end
|
if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end
|
||||||
|
|
||||||
if tHex[colour] == nil then
|
if tHex[colour] == nil then
|
||||||
error( "Invalid color (got " .. colour .. ")" , 2 )
|
error( "Invalid color (got " .. colour .. ")" , 2 )
|
||||||
end
|
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( 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( 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
|
if type( b ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( b ) .. ")", 2 ) end
|
||||||
|
|
||||||
tCol = tPalette[ colour ]
|
tCol = tPalette[ colour ]
|
||||||
tCol[1] = r
|
tCol[1] = r
|
||||||
tCol[2] = g
|
tCol[2] = g
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
alias assigns shell commands to run other programs.
|
alias assigns shell commands to run other programs.
|
||||||
|
|
||||||
ex:
|
ex:
|
||||||
"alias dir ls" will make the "dir" command run the "ls" program
|
"alias dir ls" will make the "dir" command run the "ls" program
|
||||||
"alias dir" will remove the alias set on "dir"
|
"alias dir" will remove the alias set on "dir"
|
||||||
"alias" will list all current aliases.
|
"alias" will list all current aliases.
|
@ -1,6 +1,6 @@
|
|||||||
The set program can be used to inspect and change system settings.
|
The set program can be used to inspect and change system settings.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
"set" will print all the system settings and their values
|
"set" will print all the system settings and their values
|
||||||
"set foo" will print the value of the system setting "foo"
|
"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"
|
"set foo bar" will set the value of the system setting "foo" to "bar"
|
||||||
|
@ -24,4 +24,3 @@ else
|
|||||||
table.sort( tList )
|
table.sort( tList )
|
||||||
textutils.pagedTabulate( tList )
|
textutils.pagedTabulate( tList )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ local function load( _sPath )
|
|||||||
end
|
end
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
if #tLines == 0 then
|
if #tLines == 0 then
|
||||||
table.insert( tLines, "" )
|
table.insert( tLines, "" )
|
||||||
end
|
end
|
||||||
@ -91,7 +91,7 @@ local function save( _sPath )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Save
|
-- Save
|
||||||
local file = nil
|
local file, fileerr
|
||||||
local function innerSave()
|
local function innerSave()
|
||||||
file, fileerr = fs.open( _sPath, "w" )
|
file, fileerr = fs.open( _sPath, "w" )
|
||||||
if file then
|
if file then
|
||||||
@ -102,9 +102,9 @@ local function save( _sPath )
|
|||||||
error( "Failed to open ".._sPath )
|
error( "Failed to open ".._sPath )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ok, err = pcall( innerSave )
|
local ok, err = pcall( innerSave )
|
||||||
if file then
|
if file then
|
||||||
file.close()
|
file.close()
|
||||||
end
|
end
|
||||||
return ok, err, fileerr
|
return ok, err, fileerr
|
||||||
@ -150,8 +150,8 @@ local function tryWrite( sLine, regex, colour )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function writeHighlighted( sLine )
|
local function writeHighlighted( sLine )
|
||||||
while string.len(sLine) > 0 do
|
while string.len(sLine) > 0 do
|
||||||
sLine =
|
sLine =
|
||||||
tryWrite( sLine, "^%-%-%[%[.-%]%]", commentColour ) or
|
tryWrite( sLine, "^%-%-%[%[.-%]%]", commentColour ) or
|
||||||
tryWrite( sLine, "^%-%-.*", commentColour ) or
|
tryWrite( sLine, "^%-%-.*", commentColour ) or
|
||||||
tryWrite( sLine, "^\"\"", stringColour ) or
|
tryWrite( sLine, "^\"\"", stringColour ) or
|
||||||
@ -282,7 +282,7 @@ local function redrawMenu()
|
|||||||
term.setCursorPos( x - scrollX, y - scrollY )
|
term.setCursorPos( x - scrollX, y - scrollY )
|
||||||
end
|
end
|
||||||
|
|
||||||
local tMenuFuncs = {
|
local tMenuFuncs = {
|
||||||
Save = function()
|
Save = function()
|
||||||
if bReadOnly then
|
if bReadOnly then
|
||||||
sStatus = "Access denied"
|
sStatus = "Access denied"
|
||||||
@ -326,9 +326,9 @@ local tMenuFuncs = {
|
|||||||
}
|
}
|
||||||
printerTerminal.scroll = function()
|
printerTerminal.scroll = function()
|
||||||
if nPage == 1 then
|
if nPage == 1 then
|
||||||
printer.setPageTitle( sName.." (page "..nPage..")" )
|
printer.setPageTitle( sName.." (page "..nPage..")" )
|
||||||
end
|
end
|
||||||
|
|
||||||
while not printer.newPage() do
|
while not printer.newPage() do
|
||||||
if printer.getInkLevel() < 1 then
|
if printer.getInkLevel() < 1 then
|
||||||
sStatus = "Printer out of ink, please refill"
|
sStatus = "Printer out of ink, please refill"
|
||||||
@ -337,11 +337,11 @@ local tMenuFuncs = {
|
|||||||
else
|
else
|
||||||
sStatus = "Printer output tray full, please empty"
|
sStatus = "Printer output tray full, please empty"
|
||||||
end
|
end
|
||||||
|
|
||||||
term.redirect( screenTerminal )
|
term.redirect( screenTerminal )
|
||||||
redrawMenu()
|
redrawMenu()
|
||||||
term.redirect( printerTerminal )
|
term.redirect( printerTerminal )
|
||||||
|
|
||||||
local timer = os.startTimer(0.5)
|
local timer = os.startTimer(0.5)
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
end
|
end
|
||||||
@ -353,7 +353,7 @@ local tMenuFuncs = {
|
|||||||
printer.setPageTitle( sName.." (page "..nPage..")" )
|
printer.setPageTitle( sName.." (page "..nPage..")" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bMenu = false
|
bMenu = false
|
||||||
term.redirect( printerTerminal )
|
term.redirect( printerTerminal )
|
||||||
local ok, error = pcall( function()
|
local ok, error = pcall( function()
|
||||||
@ -366,14 +366,14 @@ local tMenuFuncs = {
|
|||||||
if not ok then
|
if not ok then
|
||||||
print( error )
|
print( error )
|
||||||
end
|
end
|
||||||
|
|
||||||
while not printer.endPage() do
|
while not printer.endPage() do
|
||||||
sStatus = "Printer output tray full, please empty"
|
sStatus = "Printer output tray full, please empty"
|
||||||
redrawMenu()
|
redrawMenu()
|
||||||
sleep( 0.5 )
|
sleep( 0.5 )
|
||||||
end
|
end
|
||||||
bMenu = true
|
bMenu = true
|
||||||
|
|
||||||
if nPage > 1 then
|
if nPage > 1 then
|
||||||
sStatus = "Printed "..nPage.." Pages"
|
sStatus = "Printed "..nPage.." Pages"
|
||||||
else
|
else
|
||||||
@ -416,7 +416,7 @@ local function setCursor( newX, newY )
|
|||||||
x, y = newX, newY
|
x, y = newX, newY
|
||||||
local screenX = x - scrollX
|
local screenX = x - scrollX
|
||||||
local screenY = y - scrollY
|
local screenY = y - scrollY
|
||||||
|
|
||||||
local bRedraw = false
|
local bRedraw = false
|
||||||
if screenX < 1 then
|
if screenX < 1 then
|
||||||
scrollX = x - 1
|
scrollX = x - 1
|
||||||
@ -427,7 +427,7 @@ local function setCursor( newX, newY )
|
|||||||
screenX = w
|
screenX = w
|
||||||
bRedraw = true
|
bRedraw = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if screenY < 1 then
|
if screenY < 1 then
|
||||||
scrollY = y - 1
|
scrollY = y - 1
|
||||||
screenY = 1
|
screenY = 1
|
||||||
@ -694,7 +694,7 @@ while bRunning do
|
|||||||
redrawMenu()
|
redrawMenu()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif sEvent == "char" then
|
elseif sEvent == "char" then
|
||||||
if not bMenu and not bReadOnly then
|
if not bMenu and not bReadOnly then
|
||||||
-- Input text
|
-- Input text
|
||||||
@ -725,7 +725,7 @@ while bRunning do
|
|||||||
tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
|
tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x)
|
||||||
setCursor( x + string.len( param ), y )
|
setCursor( x + string.len( param ), y )
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif sEvent == "mouse_click" then
|
elseif sEvent == "mouse_click" then
|
||||||
if not bMenu then
|
if not bMenu then
|
||||||
if param == 1 then
|
if param == 1 then
|
||||||
@ -738,7 +738,7 @@ while bRunning do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif sEvent == "mouse_scroll" then
|
elseif sEvent == "mouse_scroll" then
|
||||||
if not bMenu then
|
if not bMenu then
|
||||||
if param == -1 then
|
if param == -1 then
|
||||||
@ -748,7 +748,7 @@ while bRunning do
|
|||||||
scrollY = scrollY - 1
|
scrollY = scrollY - 1
|
||||||
redrawText()
|
redrawText()
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif param == 1 then
|
elseif param == 1 then
|
||||||
-- Scroll down
|
-- Scroll down
|
||||||
local nMaxScroll = #tLines - (h-1)
|
local nMaxScroll = #tLines - (h-1)
|
||||||
@ -757,7 +757,7 @@ while bRunning do
|
|||||||
scrollY = scrollY + 1
|
scrollY = scrollY + 1
|
||||||
redrawText()
|
redrawText()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -774,4 +774,3 @@ end
|
|||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorBlink( false )
|
term.setCursorBlink( false )
|
||||||
term.setCursorPos( 1, 1 )
|
term.setCursorPos( 1, 1 )
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ local function getCharOf( colour )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return " "
|
return " "
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Converts a text character to colour value
|
Converts a text character to colour value
|
||||||
@ -94,7 +94,7 @@ local function getColourOf( char )
|
|||||||
return tColourLookup[char]
|
return tColourLookup[char]
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Loads the file into the canvas
|
Loads the file into the canvas
|
||||||
params: path = the path of the file to open
|
params: path = the path of the file to open
|
||||||
returns: nil
|
returns: nil
|
||||||
@ -116,8 +116,8 @@ local function load(path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Saves the current canvas to file
|
Saves the current canvas to file
|
||||||
params: path = the path of the file to save
|
params: path = the path of the file to save
|
||||||
returns: true if save was successful, false otherwise
|
returns: true if save was successful, false otherwise
|
||||||
]]
|
]]
|
||||||
@ -161,7 +161,7 @@ local function save(path)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Draws colour picker sidebar, the pallette and the footer
|
Draws colour picker sidebar, the pallette and the footer
|
||||||
returns: nil
|
returns: nil
|
||||||
]]
|
]]
|
||||||
@ -172,7 +172,7 @@ local function drawInterface()
|
|||||||
term.setTextColour(colours.yellow)
|
term.setTextColour(colours.yellow)
|
||||||
term.clearLine()
|
term.clearLine()
|
||||||
term.write(fMessage)
|
term.write(fMessage)
|
||||||
|
|
||||||
-- Colour Picker
|
-- Colour Picker
|
||||||
for i=1,16 do
|
for i=1,16 do
|
||||||
term.setCursorPos(w-1, i)
|
term.setCursorPos(w-1, i)
|
||||||
@ -184,7 +184,7 @@ local function drawInterface()
|
|||||||
term.setBackgroundColour( canvasColour )
|
term.setBackgroundColour( canvasColour )
|
||||||
term.setTextColour( colours.grey )
|
term.setTextColour( colours.grey )
|
||||||
term.write("\127\127")
|
term.write("\127\127")
|
||||||
|
|
||||||
-- Left and Right Selected Colours
|
-- Left and Right Selected Colours
|
||||||
for i=18,18 do
|
for i=18,18 do
|
||||||
term.setCursorPos(w-1, i)
|
term.setCursorPos(w-1, i)
|
||||||
@ -214,7 +214,7 @@ local function drawInterface()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Converts a single pixel of a single line of the canvas and draws it
|
Converts a single pixel of a single line of the canvas and draws it
|
||||||
returns: nil
|
returns: nil
|
||||||
]]
|
]]
|
||||||
@ -232,7 +232,7 @@ local function drawCanvasPixel( x, y )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Converts each colour in a single line of the canvas and draws it
|
Converts each colour in a single line of the canvas and draws it
|
||||||
returns: nil
|
returns: nil
|
||||||
]]
|
]]
|
||||||
@ -242,7 +242,7 @@ local function drawCanvasLine( y )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Converts each colour in the canvas and draws it
|
Converts each colour in the canvas and draws it
|
||||||
returns: nil
|
returns: nil
|
||||||
]]
|
]]
|
||||||
@ -259,7 +259,7 @@ end
|
|||||||
local function accessMenu()
|
local function accessMenu()
|
||||||
-- Selected menu option
|
-- Selected menu option
|
||||||
local selection = 1
|
local selection = 1
|
||||||
|
|
||||||
term.setBackgroundColour(colours.black)
|
term.setBackgroundColour(colours.black)
|
||||||
while true do
|
while true do
|
||||||
-- Draw the menu
|
-- Draw the menu
|
||||||
@ -267,7 +267,7 @@ local function accessMenu()
|
|||||||
term.clearLine()
|
term.clearLine()
|
||||||
term.setTextColour(colours.white)
|
term.setTextColour(colours.white)
|
||||||
for k,v in pairs(mChoices) do
|
for k,v in pairs(mChoices) do
|
||||||
if selection==k then
|
if selection==k then
|
||||||
term.setTextColour(colours.yellow)
|
term.setTextColour(colours.yellow)
|
||||||
local ox,_ = term.getCursorPos()
|
local ox,_ = term.getCursorPos()
|
||||||
term.write("["..string.rep(" ",#v).."]")
|
term.write("["..string.rep(" ",#v).."]")
|
||||||
@ -279,7 +279,7 @@ local function accessMenu()
|
|||||||
term.write(" "..v.." ")
|
term.write(" "..v.." ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Handle input in the menu
|
-- Handle input in the menu
|
||||||
local id,key = os.pullEvent("key")
|
local id,key = os.pullEvent("key")
|
||||||
if id == "key" then
|
if id == "key" then
|
||||||
@ -291,25 +291,25 @@ local function accessMenu()
|
|||||||
selection = 2
|
selection = 2
|
||||||
key = keys.enter
|
key = keys.enter
|
||||||
end
|
end
|
||||||
|
|
||||||
if key == keys.right then
|
if key == keys.right then
|
||||||
-- Move right
|
-- Move right
|
||||||
selection = selection + 1
|
selection = selection + 1
|
||||||
if selection > #mChoices then
|
if selection > #mChoices then
|
||||||
selection = 1
|
selection = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif key == keys.left and selection > 1 then
|
elseif key == keys.left and selection > 1 then
|
||||||
-- Move left
|
-- Move left
|
||||||
selection = selection - 1
|
selection = selection - 1
|
||||||
if selection < 1 then
|
if selection < 1 then
|
||||||
selection = #mChoices
|
selection = #mChoices
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif key == keys.enter then
|
elseif key == keys.enter then
|
||||||
-- Select an option
|
-- Select an option
|
||||||
if mChoices[selection]=="Save" then
|
if mChoices[selection]=="Save" then
|
||||||
if bReadOnly then
|
if bReadOnly then
|
||||||
fMessage = "Access denied"
|
fMessage = "Access denied"
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -324,18 +324,18 @@ local function accessMenu()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
elseif mChoices[selection]=="Exit" then
|
elseif mChoices[selection]=="Exit" then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
elseif key == keys.leftCtrl or keys == keys.rightCtrl then
|
elseif key == keys.leftCtrl or keys == keys.rightCtrl then
|
||||||
-- Cancel the menu
|
-- Cancel the menu
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
Runs the main thread of execution. Draws the canvas and interface, and handles
|
Runs the main thread of execution. Draws the canvas and interface, and handles
|
||||||
mouse and key events.
|
mouse and key events.
|
||||||
returns: nil
|
returns: nil
|
||||||
@ -405,4 +405,3 @@ term.setBackgroundColour(colours.black)
|
|||||||
term.setTextColour(colours.white)
|
term.setTextColour(colours.white)
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ end
|
|||||||
local function drawMap()
|
local function drawMap()
|
||||||
for x=1,SizeW do
|
for x=1,SizeW do
|
||||||
for y=1,SizeH do
|
for y=1,SizeH do
|
||||||
|
|
||||||
local obj = tScreen[x][y]
|
local obj = tScreen[x][y]
|
||||||
if obj.ground == true then
|
if obj.ground == true then
|
||||||
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cG)
|
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cG)
|
||||||
@ -274,7 +274,7 @@ local function drawMap()
|
|||||||
if obj.wall == true then
|
if obj.wall == true then
|
||||||
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cW)
|
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cW)
|
||||||
end
|
end
|
||||||
|
|
||||||
local ex = tostring(tScreen[x][y].exit)
|
local ex = tostring(tScreen[x][y].exit)
|
||||||
if not(ex == "zz" or ex == "nil") then
|
if not(ex == "zz" or ex == "nil") then
|
||||||
if ex == "a" then
|
if ex == "a" then
|
||||||
@ -293,7 +293,7 @@ local function drawMap()
|
|||||||
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
||||||
print("X")
|
print("X")
|
||||||
end
|
end
|
||||||
|
|
||||||
local st = tostring(tScreen[x][y].start)
|
local st = tostring(tScreen[x][y].start)
|
||||||
if not(st == "zz" or st == "nil") then
|
if not(st == "zz" or st == "nil") then
|
||||||
local Cr = string.sub(st,2,2)
|
local Cr = string.sub(st,2,2)
|
||||||
@ -308,11 +308,11 @@ local function drawMap()
|
|||||||
else
|
else
|
||||||
return error("Start Color Out")
|
return error("Start Color Out")
|
||||||
end
|
end
|
||||||
|
|
||||||
term.setTextColor(Cr)
|
term.setTextColor(Cr)
|
||||||
term.setBackgroundColor(cG)
|
term.setBackgroundColor(cG)
|
||||||
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
term.setCursorPos(XOrgin+x,YOrgin+y+1)
|
||||||
|
|
||||||
local sSide = string.sub(st,1,1)
|
local sSide = string.sub(st,1,1)
|
||||||
if sSide == "a" then
|
if sSide == "a" then
|
||||||
print("^")
|
print("^")
|
||||||
@ -326,11 +326,11 @@ local function drawMap()
|
|||||||
print("@")
|
print("@")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if obj.space == true then
|
if obj.space == true then
|
||||||
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cS)
|
paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cS)
|
||||||
end
|
end
|
||||||
|
|
||||||
local rb = tostring(tScreen[x][y].robot)
|
local rb = tostring(tScreen[x][y].robot)
|
||||||
if not(rb == "zz" or rb == "nil") then
|
if not(rb == "zz" or rb == "nil") then
|
||||||
local Cr = string.sub(rb,2,2)
|
local Cr = string.sub(rb,2,2)
|
||||||
@ -516,13 +516,13 @@ function InterFace.drawBar()
|
|||||||
term.setBackgroundColor( colors.black )
|
term.setBackgroundColor( colors.black )
|
||||||
term.setTextColor( InterFace.cTitle )
|
term.setTextColor( InterFace.cTitle )
|
||||||
printCentred( 1, " "..sLevelTitle.." " )
|
printCentred( 1, " "..sLevelTitle.." " )
|
||||||
|
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
term.setBackgroundColor( cW )
|
term.setBackgroundColor( cW )
|
||||||
write( " " )
|
write( " " )
|
||||||
term.setBackgroundColor( colors.black )
|
term.setBackgroundColor( colors.black )
|
||||||
write( " x "..tostring(Blocks).." " )
|
write( " x "..tostring(Blocks).." " )
|
||||||
|
|
||||||
term.setCursorPos( TermW-8,TermH )
|
term.setCursorPos( TermW-8,TermH )
|
||||||
term.setBackgroundColor( colors.black )
|
term.setBackgroundColor( colors.black )
|
||||||
term.setTextColour(InterFace.cSpeedD)
|
term.setTextColour(InterFace.cSpeedD)
|
||||||
@ -601,12 +601,12 @@ local function startG(LevelN)
|
|||||||
InterFace.drawBar()
|
InterFace.drawBar()
|
||||||
gRender("start")
|
gRender("start")
|
||||||
drawMap()
|
drawMap()
|
||||||
|
|
||||||
local NExit = true
|
local NExit = true
|
||||||
if aExits == 0 then
|
if aExits == 0 then
|
||||||
NExit = false
|
NExit = false
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
local isExit = InterFace.render()
|
local isExit = InterFace.render()
|
||||||
if isExit == "end" then
|
if isExit == "end" then
|
||||||
|
@ -279,7 +279,7 @@ local tRecipes = {
|
|||||||
["a crafting table"] = { "some planks" },
|
["a crafting table"] = { "some planks" },
|
||||||
["a furnace"] = { "some stone" },
|
["a furnace"] = { "some stone" },
|
||||||
["some torches"] = { "some sticks", "some coal" },
|
["some torches"] = { "some sticks", "some coal" },
|
||||||
|
|
||||||
["a wooden pickaxe"] = { "some planks", "some sticks" },
|
["a wooden pickaxe"] = { "some planks", "some sticks" },
|
||||||
["a stone pickaxe"] = { "some stone", "some sticks" },
|
["a stone pickaxe"] = { "some stone", "some sticks" },
|
||||||
["an iron pickaxe"] = { "some iron", "some sticks" },
|
["an iron pickaxe"] = { "some iron", "some sticks" },
|
||||||
@ -355,14 +355,14 @@ local function getRoom( x, y, z, dontCreate )
|
|||||||
nMonsters = 0,
|
nMonsters = 0,
|
||||||
}
|
}
|
||||||
tMap[x][y][z] = room
|
tMap[x][y][z] = room
|
||||||
|
|
||||||
if y == 0 then
|
if y == 0 then
|
||||||
-- Room is above ground
|
-- Room is above ground
|
||||||
|
|
||||||
-- Pick biome
|
-- Pick biome
|
||||||
room.nBiome = math.random( 1, #tBiomes )
|
room.nBiome = math.random( 1, #tBiomes )
|
||||||
room.trees = hasTrees( room.nBiome )
|
room.trees = hasTrees( room.nBiome )
|
||||||
|
|
||||||
-- Add animals
|
-- Add animals
|
||||||
if math.random(1,3) == 1 then
|
if math.random(1,3) == 1 then
|
||||||
for n = 1,math.random(1,2) do
|
for n = 1,math.random(1,2) do
|
||||||
@ -370,7 +370,7 @@ local function getRoom( x, y, z, dontCreate )
|
|||||||
room.items[ sAnimal ] = items[ sAnimal ]
|
room.items[ sAnimal ] = items[ sAnimal ]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add surface ore
|
-- Add surface ore
|
||||||
if math.random(1,5) == 1 or hasStone( room.nBiome ) then
|
if math.random(1,5) == 1 or hasStone( room.nBiome ) then
|
||||||
room.items[ "some stone" ] = items[ "some stone" ]
|
room.items[ "some stone" ] = items[ "some stone" ]
|
||||||
@ -393,7 +393,7 @@ local function getRoom( x, y, z, dontCreate )
|
|||||||
room.exits["down"] = true
|
room.exits["down"] = true
|
||||||
room.items["a cave entrance"] = items["a cave entrance"]
|
room.items["a cave entrance"] = items["a cave entrance"]
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
-- Room is underground
|
-- Room is underground
|
||||||
-- Add exits
|
-- Add exits
|
||||||
@ -409,7 +409,7 @@ local function getRoom( x, y, z, dontCreate )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if y == -1 then
|
if y == -1 then
|
||||||
local above = getRoom( x, y + 1, z )
|
local above = getRoom( x, y + 1, z )
|
||||||
if above.exits["down"] then
|
if above.exits["down"] then
|
||||||
@ -419,16 +419,16 @@ local function getRoom( x, y, z, dontCreate )
|
|||||||
else
|
else
|
||||||
tryExit( "up", "down", x, y + 1, z )
|
tryExit( "up", "down", x, y + 1, z )
|
||||||
end
|
end
|
||||||
|
|
||||||
if y > -3 then
|
if y > -3 then
|
||||||
tryExit( "down", "up", x, y - 1, z )
|
tryExit( "down", "up", x, y - 1, z )
|
||||||
end
|
end
|
||||||
|
|
||||||
tryExit( "east", "west", x - 1, y, z )
|
tryExit( "east", "west", x - 1, y, z )
|
||||||
tryExit( "west", "east", x + 1, y, z )
|
tryExit( "west", "east", x + 1, y, z )
|
||||||
tryExit( "north", "south", x, y, z + 1 )
|
tryExit( "north", "south", x, y, z + 1 )
|
||||||
tryExit( "south", "north", x, y, z - 1 )
|
tryExit( "south", "north", x, y, z - 1 )
|
||||||
|
|
||||||
-- Add ores
|
-- Add ores
|
||||||
room.items[ "some stone" ] = items[ "some stone" ]
|
room.items[ "some stone" ] = items[ "some stone" ]
|
||||||
if math.random(1,3) == 1 then
|
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
|
if y == -3 and math.random(1,15) == 1 then
|
||||||
room.items[ "some diamond" ] = items[ "some diamond" ]
|
room.items[ "some diamond" ] = items[ "some diamond" ]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Turn out the lights
|
-- Turn out the lights
|
||||||
room.dark = true
|
room.dark = true
|
||||||
end
|
end
|
||||||
@ -453,11 +453,11 @@ local function itemize( t )
|
|||||||
if item == nil then
|
if item == nil then
|
||||||
return "nothing"
|
return "nothing"
|
||||||
end
|
end
|
||||||
|
|
||||||
local text = ""
|
local text = ""
|
||||||
while item do
|
while item do
|
||||||
text = text .. item
|
text = text .. item
|
||||||
|
|
||||||
local nextItem = next( t, item )
|
local nextItem = next( t, item )
|
||||||
if nextItem ~= nil then
|
if nextItem ~= nil then
|
||||||
local nextNextItem = next( t, nextItem )
|
local nextNextItem = next( t, nextItem )
|
||||||
@ -611,7 +611,7 @@ local function doCommand( text )
|
|||||||
commands[ "noinput" ]()
|
commands[ "noinput" ]()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for sCommand, t in pairs( tMatches ) do
|
for sCommand, t in pairs( tMatches ) do
|
||||||
for n, sMatch in pairs( t ) do
|
for n, sMatch in pairs( t ) do
|
||||||
local tCaptures = { string.match( text, "^" .. sMatch .. "$" ) }
|
local tCaptures = { string.match( text, "^" .. sMatch .. "$" ) }
|
||||||
@ -659,7 +659,7 @@ function commands.look( _sTarget )
|
|||||||
if room.trees then
|
if room.trees then
|
||||||
print( "There are trees here." )
|
print( "There are trees here." )
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
-- Look at stuff
|
-- Look at stuff
|
||||||
if room.trees and (_sTarget == "tree" or _sTarget == "trees") then
|
if room.trees and (_sTarget == "tree" or _sTarget == "trees") then
|
||||||
@ -677,7 +677,7 @@ function commands.look( _sTarget )
|
|||||||
tItem = inventory[sItem]
|
tItem = inventory[sItem]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if tItem then
|
if tItem then
|
||||||
print( tItem.desc or ("You see nothing special about "..sItem..".") )
|
print( tItem.desc or ("You see nothing special about "..sItem..".") )
|
||||||
else
|
else
|
||||||
@ -693,7 +693,7 @@ function commands.go( _sDir )
|
|||||||
print( "Go where?" )
|
print( "Go where?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if nGoWest ~= nil then
|
if nGoWest ~= nil then
|
||||||
if _sDir == "west" then
|
if _sDir == "west" then
|
||||||
nGoWest = nGoWest + 1
|
nGoWest = nGoWest + 1
|
||||||
@ -707,12 +707,12 @@ function commands.go( _sDir )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if room.exits[_sDir] == nil then
|
if room.exits[_sDir] == nil then
|
||||||
print( "You can't go that way." )
|
print( "You can't go that way." )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if _sDir == "north" then
|
if _sDir == "north" then
|
||||||
z = z + 1
|
z = z + 1
|
||||||
elseif _sDir == "south" then
|
elseif _sDir == "south" then
|
||||||
@ -729,7 +729,7 @@ function commands.go( _sDir )
|
|||||||
print( "I don't understand that direction." )
|
print( "I don't understand that direction." )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
nTimeInRoom = 0
|
nTimeInRoom = 0
|
||||||
doCommand( "look" )
|
doCommand( "look" )
|
||||||
end
|
end
|
||||||
@ -740,7 +740,7 @@ function commands.dig( _sDir, _sTool )
|
|||||||
print( "Dig where?" )
|
print( "Dig where?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sTool = nil
|
local sTool = nil
|
||||||
local tTool = nil
|
local tTool = nil
|
||||||
if _sTool ~= nil then
|
if _sTool ~= nil then
|
||||||
@ -751,7 +751,7 @@ function commands.dig( _sDir, _sTool )
|
|||||||
end
|
end
|
||||||
tTool = inventory[ sTool ]
|
tTool = inventory[ sTool ]
|
||||||
end
|
end
|
||||||
|
|
||||||
local bActuallyDigging = (room.exits[ _sDir ] ~= true)
|
local bActuallyDigging = (room.exits[ _sDir ] ~= true)
|
||||||
if bActuallyDigging then
|
if bActuallyDigging then
|
||||||
if sTool == nil or tTool.toolType ~= "pick" then
|
if sTool == nil or tTool.toolType ~= "pick" then
|
||||||
@ -759,7 +759,7 @@ function commands.dig( _sDir, _sTool )
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if _sDir == "north" then
|
if _sDir == "north" then
|
||||||
room.exits["north"] = true
|
room.exits["north"] = true
|
||||||
z = z + 1
|
z = z + 1
|
||||||
@ -769,17 +769,17 @@ function commands.dig( _sDir, _sTool )
|
|||||||
room.exits["south"] = true
|
room.exits["south"] = true
|
||||||
z = z - 1
|
z = z - 1
|
||||||
getRoom( x, y, z ).exits["north"] = true
|
getRoom( x, y, z ).exits["north"] = true
|
||||||
|
|
||||||
elseif _sDir == "east" then
|
elseif _sDir == "east" then
|
||||||
room.exits["east"] = true
|
room.exits["east"] = true
|
||||||
x = x - 1
|
x = x - 1
|
||||||
getRoom( x, y, z ).exits["west"] = true
|
getRoom( x, y, z ).exits["west"] = true
|
||||||
|
|
||||||
elseif _sDir == "west" then
|
elseif _sDir == "west" then
|
||||||
room.exits["west"] = true
|
room.exits["west"] = true
|
||||||
x = x + 1
|
x = x + 1
|
||||||
getRoom( x, y, z ).exits["east"] = true
|
getRoom( x, y, z ).exits["east"] = true
|
||||||
|
|
||||||
elseif _sDir == "up" then
|
elseif _sDir == "up" then
|
||||||
if y == 0 then
|
if y == 0 then
|
||||||
print( "You can't dig that way." )
|
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" ]
|
room.items[ "an exit to the surface" ] = items[ "an exit to the surface" ]
|
||||||
end
|
end
|
||||||
y = y + 1
|
y = y + 1
|
||||||
|
|
||||||
room = getRoom( x, y, z )
|
room = getRoom( x, y, z )
|
||||||
room.exits["down"] = true
|
room.exits["down"] = true
|
||||||
if y == 0 then
|
if y == 0 then
|
||||||
room.items[ "a cave entrance" ] = items[ "a cave entrance" ]
|
room.items[ "a cave entrance" ] = items[ "a cave entrance" ]
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif _sDir == "down" then
|
elseif _sDir == "down" then
|
||||||
if y <= -3 then
|
if y <= -3 then
|
||||||
print( "You hit bedrock." )
|
print( "You hit bedrock." )
|
||||||
@ -809,18 +809,18 @@ function commands.dig( _sDir, _sTool )
|
|||||||
room.items[ "a cave entrance" ] = items[ "a cave entrance" ]
|
room.items[ "a cave entrance" ] = items[ "a cave entrance" ]
|
||||||
end
|
end
|
||||||
y = y - 1
|
y = y - 1
|
||||||
|
|
||||||
room = getRoom( x, y, z )
|
room = getRoom( x, y, z )
|
||||||
room.exits["up"] = true
|
room.exits["up"] = true
|
||||||
if y == -1 then
|
if y == -1 then
|
||||||
room.items[ "an exit to the surface" ] = items[ "an exit to the surface" ]
|
room.items[ "an exit to the surface" ] = items[ "an exit to the surface" ]
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
print( "I don't understand that direction." )
|
print( "I don't understand that direction." )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
if bActuallyDigging then
|
if bActuallyDigging then
|
||||||
if _sDir == "down" and y == -1 or
|
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." )
|
print( "You dig ".._sDir.." using "..sTool.." and collect some stone." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nTimeInRoom = 0
|
nTimeInRoom = 0
|
||||||
doCommand( "look" )
|
doCommand( "look" )
|
||||||
end
|
end
|
||||||
@ -847,7 +847,7 @@ function commands.drop( _sItem )
|
|||||||
print( "Drop what?" )
|
print( "Drop what?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local room = getRoom( x,y,z )
|
local room = getRoom( x,y,z )
|
||||||
local sItem = findItem( inventory, _sItem )
|
local sItem = findItem( inventory, _sItem )
|
||||||
if sItem then
|
if sItem then
|
||||||
@ -869,7 +869,7 @@ function commands.place( _sItem )
|
|||||||
print( "Place what?" )
|
print( "Place what?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if _sItem == "torch" or _sItem == "a torch" then
|
if _sItem == "torch" or _sItem == "a torch" then
|
||||||
local room = getRoom( x,y,z )
|
local room = getRoom( x,y,z )
|
||||||
if inventory["some torches"] or inventory["a torch"] then
|
if inventory["some torches"] or inventory["a torch"] then
|
||||||
@ -888,7 +888,7 @@ function commands.place( _sItem )
|
|||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
commands.drop( _sItem )
|
commands.drop( _sItem )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -911,7 +911,7 @@ function commands.take( _sItem )
|
|||||||
room.items[ sItem ] = nil
|
room.items[ sItem ] = nil
|
||||||
end
|
end
|
||||||
inventory[ sItem ] = tItem
|
inventory[ sItem ] = tItem
|
||||||
|
|
||||||
if inventory["some torches"] and inventory["a torch"] then
|
if inventory["some torches"] and inventory["a torch"] then
|
||||||
inventory["a torch"] = nil
|
inventory["a torch"] = nil
|
||||||
end
|
end
|
||||||
@ -935,7 +935,7 @@ function commands.mine( _sItem, _sTool )
|
|||||||
if _sTool == nil then
|
if _sTool == nil then
|
||||||
print( "Mine ".._sItem.." with what?" )
|
print( "Mine ".._sItem.." with what?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
commands.cbreak( _sItem, _sTool )
|
commands.cbreak( _sItem, _sTool )
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -952,7 +952,7 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
print( "Break what?" )
|
print( "Break what?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sTool = nil
|
local sTool = nil
|
||||||
if _sTool ~= nil then
|
if _sTool ~= nil then
|
||||||
sTool = findItem( inventory, _sTool )
|
sTool = findItem( inventory, _sTool )
|
||||||
@ -977,7 +977,7 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
bRunning = false
|
bRunning = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sItem = findItem( room.items, _sItem )
|
local sItem = findItem( room.items, _sItem )
|
||||||
if sItem then
|
if sItem then
|
||||||
local tItem = room.items[ sItem ]
|
local tItem = room.items[ sItem ]
|
||||||
@ -1003,7 +1003,7 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
else
|
else
|
||||||
print( "You can't break "..sItem.." with "..sTool..".")
|
print( "You can't break "..sItem.." with "..sTool..".")
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif tItem.creature == true then
|
elseif tItem.creature == true then
|
||||||
-- Fighting monsters (or pigs)
|
-- Fighting monsters (or pigs)
|
||||||
local toolLevel = 0
|
local toolLevel = 0
|
||||||
@ -1014,12 +1014,12 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
toolLevel = tTool.toolLevel
|
toolLevel = tTool.toolLevel
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tChances = { 0.2, 0.4, 0.55, 0.8, 1 }
|
local tChances = { 0.2, 0.4, 0.55, 0.8, 1 }
|
||||||
if math.random() <= tChances[ toolLevel + 1 ] then
|
if math.random() <= tChances[ toolLevel + 1 ] then
|
||||||
room.items[ sItem ] = nil
|
room.items[ sItem ] = nil
|
||||||
print( "The "..tItem.aliases[1].." dies." )
|
print( "The "..tItem.aliases[1].." dies." )
|
||||||
|
|
||||||
if tItem.drops then
|
if tItem.drops then
|
||||||
for n, sDrop in pairs( tItem.drops ) do
|
for n, sDrop in pairs( tItem.drops ) do
|
||||||
if not room.items[sDrop] then
|
if not room.items[sDrop] then
|
||||||
@ -1028,14 +1028,14 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if tItem.monster then
|
if tItem.monster then
|
||||||
room.nMonsters = room.nMonsters - 1
|
room.nMonsters = room.nMonsters - 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print( "The "..tItem.aliases[1].." is injured by your blow." )
|
print( "The "..tItem.aliases[1].." is injured by your blow." )
|
||||||
end
|
end
|
||||||
|
|
||||||
if tItem.hitDrops then
|
if tItem.hitDrops then
|
||||||
for n, sDrop in pairs( tItem.hitDrops ) do
|
for n, sDrop in pairs( tItem.hitDrops ) do
|
||||||
if not room.items[sDrop] then
|
if not room.items[sDrop] then
|
||||||
@ -1044,7 +1044,7 @@ function commands.cbreak( _sItem, _sTool )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
print( "You can't break "..sItem.."." )
|
print( "You can't break "..sItem.."." )
|
||||||
end
|
end
|
||||||
@ -1058,7 +1058,7 @@ function commands.craft( _sItem )
|
|||||||
print( "Craft what?" )
|
print( "Craft what?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if _sItem == "computer" or _sItem == "a computer" then
|
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." )
|
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
|
if term.isColour() then
|
||||||
@ -1070,7 +1070,7 @@ function commands.craft( _sItem )
|
|||||||
bRunning = false
|
bRunning = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local room = getRoom( x,y,z )
|
local room = getRoom( x,y,z )
|
||||||
local sItem = findItem( items, _sItem )
|
local sItem = findItem( items, _sItem )
|
||||||
local tRecipe = (sItem and tRecipes[ sItem ]) or nil
|
local tRecipe = (sItem and tRecipes[ sItem ]) or nil
|
||||||
@ -1081,7 +1081,7 @@ function commands.craft( _sItem )
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for n,sReq in ipairs( tRecipe ) do
|
for n,sReq in ipairs( tRecipe ) do
|
||||||
inventory[sReq] = nil
|
inventory[sReq] = nil
|
||||||
end
|
end
|
||||||
@ -1092,7 +1092,7 @@ function commands.craft( _sItem )
|
|||||||
print( "Crafted." )
|
print( "Crafted." )
|
||||||
else
|
else
|
||||||
print( "You don't know how to make "..(sItem or _sItem).."." )
|
print( "You don't know how to make "..(sItem or _sItem).."." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function commands.build( _sThing, _sMaterial )
|
function commands.build( _sThing, _sMaterial )
|
||||||
@ -1100,7 +1100,7 @@ function commands.build( _sThing, _sMaterial )
|
|||||||
print( "Build what?" )
|
print( "Build what?" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sMaterial = nil
|
local sMaterial = nil
|
||||||
if _sMaterial == nil then
|
if _sMaterial == nil then
|
||||||
for sItem, tItem in pairs( inventory ) do
|
for sItem, tItem in pairs( inventory ) do
|
||||||
@ -1119,18 +1119,18 @@ function commands.build( _sThing, _sMaterial )
|
|||||||
print( "You don't have any ".._sMaterial )
|
print( "You don't have any ".._sMaterial )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if inventory[sMaterial].material ~= true then
|
if inventory[sMaterial].material ~= true then
|
||||||
print( sMaterial.." is not a good building material." )
|
print( sMaterial.." is not a good building material." )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local alias = nil
|
local alias = nil
|
||||||
if string.sub(_sThing, 1, 1) == "a" then
|
if string.sub(_sThing, 1, 1) == "a" then
|
||||||
alias = string.match( _sThing, "a ([%a ]+)" )
|
alias = string.match( _sThing, "a ([%a ]+)" )
|
||||||
end
|
end
|
||||||
|
|
||||||
local room = getRoom( x,y,z )
|
local room = getRoom( x,y,z )
|
||||||
inventory[sMaterial] = nil
|
inventory[sMaterial] = nil
|
||||||
room.items[ _sThing ] = {
|
room.items[ _sThing ] = {
|
||||||
@ -1143,7 +1143,7 @@ function commands.build( _sThing, _sMaterial )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function commands.help()
|
function commands.help()
|
||||||
local sText =
|
local sText =
|
||||||
"Welcome to adventure, the greatest text adventure game on CraftOS. " ..
|
"Welcome to adventure, the greatest text adventure game on CraftOS. " ..
|
||||||
"To get around the world, type actions, and the adventure will " ..
|
"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, " ..
|
"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.."." )
|
print( "You don't have any ".._sItem.."." )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local tItem = inventory[sItem]
|
local tItem = inventory[sItem]
|
||||||
if tItem.food then
|
if tItem.food then
|
||||||
print( "That was delicious!" )
|
print( "That was delicious!" )
|
||||||
inventory[sItem] = nil
|
inventory[sItem] = nil
|
||||||
|
|
||||||
if bInjured then
|
if bInjured then
|
||||||
print( "You are no longer injured." )
|
print( "You are no longer injured." )
|
||||||
bInjured = false
|
bInjured = false
|
||||||
@ -1212,7 +1212,7 @@ end
|
|||||||
|
|
||||||
local function simulate()
|
local function simulate()
|
||||||
local bNewMonstersThisRoom = false
|
local bNewMonstersThisRoom = false
|
||||||
|
|
||||||
-- Spawn monsters in nearby rooms
|
-- Spawn monsters in nearby rooms
|
||||||
for sx = -2,2 do
|
for sx = -2,2 do
|
||||||
for sy = -1,1 do
|
for sy = -1,1 do
|
||||||
@ -1220,24 +1220,24 @@ local function simulate()
|
|||||||
local h = y + sy
|
local h = y + sy
|
||||||
if h >= -3 and h <= 0 then
|
if h >= -3 and h <= 0 then
|
||||||
local room = getRoom( x + sx, h, z + sz )
|
local room = getRoom( x + sx, h, z + sz )
|
||||||
|
|
||||||
-- Spawn monsters
|
-- Spawn monsters
|
||||||
if room.nMonsters < 2 and
|
if room.nMonsters < 2 and
|
||||||
((h == 0 and not isSunny() and not room.items["a torch"]) or room.dark) and
|
((h == 0 and not isSunny() and not room.items["a torch"]) or room.dark) and
|
||||||
math.random(1,6) == 1 then
|
math.random(1,6) == 1 then
|
||||||
|
|
||||||
local sMonster = tMonsters[ math.random(1,#tMonsters) ]
|
local sMonster = tMonsters[ math.random(1,#tMonsters) ]
|
||||||
if room.items[ sMonster ] == nil then
|
if room.items[ sMonster ] == nil then
|
||||||
room.items[ sMonster ] = items[ sMonster ]
|
room.items[ sMonster ] = items[ sMonster ]
|
||||||
room.nMonsters = room.nMonsters + 1
|
room.nMonsters = room.nMonsters + 1
|
||||||
|
|
||||||
if sx == 0 and sy == 0 and sz == 0 and not room.dark then
|
if sx == 0 and sy == 0 and sz == 0 and not room.dark then
|
||||||
print( "From the shadows, "..sMonster.." appears." )
|
print( "From the shadows, "..sMonster.." appears." )
|
||||||
bNewMonstersThisRoom = true
|
bNewMonstersThisRoom = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Burn monsters
|
-- Burn monsters
|
||||||
if h == 0 and isSunny() then
|
if h == 0 and isSunny() then
|
||||||
for n,sMonster in ipairs( tMonsters ) do
|
for n,sMonster in ipairs( tMonsters ) do
|
||||||
@ -1249,7 +1249,7 @@ local function simulate()
|
|||||||
room.nMonsters = room.nMonsters - 1
|
room.nMonsters = room.nMonsters - 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1277,7 +1277,7 @@ local function simulate()
|
|||||||
print( "The "..items[sMonster].aliases[1].." attacks you." )
|
print( "The "..items[sMonster].aliases[1].." attacks you." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if bInjured then
|
if bInjured then
|
||||||
if term.isColour() then
|
if term.isColour() then
|
||||||
term.setTextColour( colours.red )
|
term.setTextColour( colours.red )
|
||||||
@ -1290,13 +1290,13 @@ local function simulate()
|
|||||||
else
|
else
|
||||||
bInjured = true
|
bInjured = true
|
||||||
end
|
end
|
||||||
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Always print this
|
-- Always print this
|
||||||
if bInjured then
|
if bInjured then
|
||||||
if term.isColour() then
|
if term.isColour() then
|
||||||
@ -1305,7 +1305,7 @@ local function simulate()
|
|||||||
print( "You are injured." )
|
print( "You are injured." )
|
||||||
term.setTextColour( colours.white )
|
term.setTextColour( colours.white )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Advance time
|
-- Advance time
|
||||||
nTurn = nTurn + 1
|
nTurn = nTurn + 1
|
||||||
nTimeInRoom = nTimeInRoom + 1
|
nTimeInRoom = nTimeInRoom + 1
|
||||||
@ -1321,10 +1321,10 @@ while bRunning do
|
|||||||
end
|
end
|
||||||
write( "? " )
|
write( "? " )
|
||||||
term.setTextColour( colours.white )
|
term.setTextColour( colours.white )
|
||||||
|
|
||||||
local sRawLine = read( nil, tCommandHistory )
|
local sRawLine = read( nil, tCommandHistory )
|
||||||
table.insert( tCommandHistory, sRawLine )
|
table.insert( tCommandHistory, sRawLine )
|
||||||
|
|
||||||
local sLine = nil
|
local sLine = nil
|
||||||
for match in string.gmatch(sRawLine, "%a+") do
|
for match in string.gmatch(sRawLine, "%a+") do
|
||||||
if sLine then
|
if sLine then
|
||||||
@ -1333,7 +1333,7 @@ while bRunning do
|
|||||||
sLine = string.lower(match)
|
sLine = string.lower(match)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
doCommand( sLine or "" )
|
doCommand( sLine or "" )
|
||||||
if bRunning then
|
if bRunning then
|
||||||
simulate()
|
simulate()
|
||||||
|
@ -43,8 +43,8 @@ elseif sCommand == "play" or sCommand == nil then
|
|||||||
print( "No Music Disc in disk drive: "..sName )
|
print( "No Music Disc in disk drive: "..sName )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
printUsage()
|
printUsage()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -75,7 +75,7 @@ local function addFruit()
|
|||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nFruit = nFruit + 1
|
nFruit = nFruit + 1
|
||||||
if nFruit > #tFruits then
|
if nFruit > #tFruits then
|
||||||
nFruit = 1
|
nFruit = 1
|
||||||
@ -86,7 +86,7 @@ local function drawMenu()
|
|||||||
term.setTextColour( headingColour )
|
term.setTextColour( headingColour )
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
term.write( "SCORE " )
|
term.write( "SCORE " )
|
||||||
|
|
||||||
term.setTextColour( textColour )
|
term.setTextColour( textColour )
|
||||||
term.setCursorPos(7,1)
|
term.setCursorPos(7,1)
|
||||||
term.write( tostring(nScore) )
|
term.write( tostring(nScore) )
|
||||||
@ -97,7 +97,7 @@ local function drawMenu()
|
|||||||
|
|
||||||
term.setTextColour( textColour )
|
term.setTextColour( textColour )
|
||||||
term.setCursorPos(w,1)
|
term.setCursorPos(w,1)
|
||||||
term.write( tostring(nDifficulty or "?") )
|
term.write( tostring(nDifficulty or "?") )
|
||||||
|
|
||||||
term.setTextColour( colours.white )
|
term.setTextColour( colours.white )
|
||||||
end
|
end
|
||||||
@ -120,7 +120,7 @@ local function update( )
|
|||||||
else
|
else
|
||||||
nExtraLength = nExtraLength - 1
|
nExtraLength = nExtraLength - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update the head
|
-- Update the head
|
||||||
local head = screen[xPos][yPos]
|
local head = screen[xPos][yPos]
|
||||||
local newXPos = xPos + xVel
|
local newXPos = xPos + xVel
|
||||||
@ -135,11 +135,11 @@ local function update( )
|
|||||||
elseif newYPos > h then
|
elseif newYPos > h then
|
||||||
newYPos = 2
|
newYPos = 2
|
||||||
end
|
end
|
||||||
|
|
||||||
local newHead = screen[newXPos][newYPos]
|
local newHead = screen[newXPos][newYPos]
|
||||||
if newHead.snake == true or newHead.wall == true then
|
if newHead.snake == true or newHead.wall == true then
|
||||||
bRunning = false
|
bRunning = false
|
||||||
|
|
||||||
else
|
else
|
||||||
if newHead.fruit == true then
|
if newHead.fruit == true then
|
||||||
nScore = nScore + 10
|
nScore = nScore + 10
|
||||||
@ -151,9 +151,9 @@ local function update( )
|
|||||||
head.nextX = newXPos
|
head.nextX = newXPos
|
||||||
head.nextY = newYPos
|
head.nextY = newYPos
|
||||||
screen[newXPos][newYPos] = { snake = true }
|
screen[newXPos][newYPos] = { snake = true }
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
term.setCursorPos(xPos,yPos)
|
term.setCursorPos(xPos,yPos)
|
||||||
term.setBackgroundColour( wormColour )
|
term.setBackgroundColour( wormColour )
|
||||||
term.write(" ")
|
term.write(" ")
|
||||||
@ -172,7 +172,7 @@ local function drawFrontend()
|
|||||||
printCentred( math.floor(h/2) - 3, "" )
|
printCentred( math.floor(h/2) - 3, "" )
|
||||||
printCentred( math.floor(h/2) - 2, " SELECT DIFFICULTY " )
|
printCentred( math.floor(h/2) - 2, " SELECT DIFFICULTY " )
|
||||||
printCentred( math.floor(h/2) - 1, "" )
|
printCentred( math.floor(h/2) - 1, "" )
|
||||||
|
|
||||||
printCentred( math.floor(h/2) + 0, " " )
|
printCentred( math.floor(h/2) + 0, " " )
|
||||||
printCentred( math.floor(h/2) + 1, " " )
|
printCentred( math.floor(h/2) + 1, " " )
|
||||||
printCentred( math.floor(h/2) + 2, " " )
|
printCentred( math.floor(h/2) + 2, " " )
|
||||||
@ -232,7 +232,7 @@ while bRunning do
|
|||||||
if event == "timer" and p1 == timer then
|
if event == "timer" and p1 == timer then
|
||||||
timer = os.startTimer(nInterval)
|
timer = os.startTimer(nInterval)
|
||||||
update( false )
|
update( false )
|
||||||
|
|
||||||
elseif event == "key" then
|
elseif event == "key" then
|
||||||
local key = p1
|
local key = p1
|
||||||
if key == keys.up or key == keys.w then
|
if key == keys.up or key == keys.w then
|
||||||
@ -250,14 +250,14 @@ while bRunning do
|
|||||||
if xVel == 0 then
|
if xVel == 0 then
|
||||||
pxVel,pyVel = -1,0
|
pxVel,pyVel = -1,0
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif key == keys.right or key == keys.d then
|
elseif key == keys.right or key == keys.d then
|
||||||
-- Right
|
-- Right
|
||||||
if xVel == 0 then
|
if xVel == 0 then
|
||||||
pxVel,pyVel = 1,0
|
pxVel,pyVel = 1,0
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -285,5 +285,3 @@ until e == "char"
|
|||||||
|
|
||||||
term.clear()
|
term.clear()
|
||||||
term.setCursorPos(1,1)
|
term.setCursorPos(1,1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ if #tArgs < 1 then
|
|||||||
printUsage()
|
printUsage()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sCommand = tArgs[1]
|
local sCommand = tArgs[1]
|
||||||
if sCommand == "locate" then
|
if sCommand == "locate" then
|
||||||
-- "gps locate"
|
-- "gps locate"
|
||||||
-- Just locate this computer (this will print the results)
|
-- Just locate this computer (this will print the results)
|
||||||
gps.locate( 2, true )
|
gps.locate( 2, true )
|
||||||
|
|
||||||
elseif sCommand == "host" then
|
elseif sCommand == "host" then
|
||||||
-- "gps host"
|
-- "gps host"
|
||||||
-- Act as a GPS host
|
-- Act as a GPS host
|
||||||
@ -29,7 +29,7 @@ elseif sCommand == "host" then
|
|||||||
-- Find a modem
|
-- Find a modem
|
||||||
local sModemSide = nil
|
local sModemSide = nil
|
||||||
for n,sSide in ipairs( rs.getSides() ) do
|
for 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
|
sModemSide = sSide
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -53,14 +53,14 @@ elseif sCommand == "host" then
|
|||||||
end
|
end
|
||||||
print( "Position is "..x..","..y..","..z )
|
print( "Position is "..x..","..y..","..z )
|
||||||
else
|
else
|
||||||
-- Position is to be determined using locate
|
-- Position is to be determined using locate
|
||||||
x,y,z = gps.locate( 2, true )
|
x,y,z = gps.locate( 2, true )
|
||||||
if x == nil then
|
if x == nil then
|
||||||
print( "Run \"gps host <x> <y> <z>\" to set position manually" )
|
print( "Run \"gps host <x> <y> <z>\" to set position manually" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Open a channel
|
-- Open a channel
|
||||||
local modem = peripheral.wrap( sModemSide )
|
local modem = peripheral.wrap( sModemSide )
|
||||||
print( "Opening channel on modem "..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
|
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
|
-- We received a ping message on the GPS channel, send a response
|
||||||
modem.transmit( sReplyChannel, gps.CHANNEL_GPS, { x, y, z } )
|
modem.transmit( sReplyChannel, gps.CHANNEL_GPS, { x, y, z } )
|
||||||
|
|
||||||
-- Print the number of requests handled
|
-- Print the number of requests handled
|
||||||
nServed = nServed + 1
|
nServed = nServed + 1
|
||||||
if nServed > 1 then
|
if nServed > 1 then
|
||||||
@ -91,5 +91,4 @@ else
|
|||||||
-- "gps somethingelse"
|
-- "gps somethingelse"
|
||||||
-- Error
|
-- Error
|
||||||
printUsage()
|
printUsage()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,7 @@ if sTopic == "index" then
|
|||||||
textutils.pagedTabulate( tTopics )
|
textutils.pagedTabulate( tTopics )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local sFile = help.lookup( sTopic )
|
local sFile = help.lookup( sTopic )
|
||||||
local file = ((sFile ~= nil) and io.open( sFile )) or nil
|
local file = ((sFile ~= nil) and io.open( sFile )) or nil
|
||||||
if file then
|
if file then
|
||||||
|
@ -5,28 +5,28 @@ local function printUsage()
|
|||||||
print( "pastebin get <code> <filename>" )
|
print( "pastebin get <code> <filename>" )
|
||||||
print( "pastebin run <code> <arguments>" )
|
print( "pastebin run <code> <arguments>" )
|
||||||
end
|
end
|
||||||
|
|
||||||
local tArgs = { ... }
|
local tArgs = { ... }
|
||||||
if #tArgs < 2 then
|
if #tArgs < 2 then
|
||||||
printUsage()
|
printUsage()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not http then
|
if not http then
|
||||||
printError( "Pastebin requires http API" )
|
printError( "Pastebin requires http API" )
|
||||||
printError( "Set http_enable to true in ComputerCraft.cfg" )
|
printError( "Set http_enable to true in ComputerCraft.cfg" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get(paste)
|
local function get(paste)
|
||||||
write( "Connecting to pastebin.com... " )
|
write( "Connecting to pastebin.com... " )
|
||||||
local response = http.get(
|
local response = http.get(
|
||||||
"https://pastebin.com/raw/"..textutils.urlEncode( paste )
|
"https://pastebin.com/raw/"..textutils.urlEncode( paste )
|
||||||
)
|
)
|
||||||
|
|
||||||
if response then
|
if response then
|
||||||
print( "Success." )
|
print( "Success." )
|
||||||
|
|
||||||
local sResponse = response.readAll()
|
local sResponse = response.readAll()
|
||||||
response.close()
|
response.close()
|
||||||
return sResponse
|
return sResponse
|
||||||
@ -34,7 +34,7 @@ local function get(paste)
|
|||||||
print( "Failed." )
|
print( "Failed." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sCommand = tArgs[1]
|
local sCommand = tArgs[1]
|
||||||
if sCommand == "put" then
|
if sCommand == "put" then
|
||||||
-- Upload a file to pastebin.com
|
-- Upload a file to pastebin.com
|
||||||
@ -45,46 +45,46 @@ if sCommand == "put" then
|
|||||||
print( "No such file" )
|
print( "No such file" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Read in the file
|
-- Read in the file
|
||||||
local sName = fs.getName( sPath )
|
local sName = fs.getName( sPath )
|
||||||
local file = fs.open( sPath, "r" )
|
local file = fs.open( sPath, "r" )
|
||||||
local sText = file.readAll()
|
local sText = file.readAll()
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
-- POST the contents to pastebin
|
-- POST the contents to pastebin
|
||||||
write( "Connecting to pastebin.com... " )
|
write( "Connecting to pastebin.com... " )
|
||||||
local key = "0ec2eb25b6166c0c27a394ae118ad829"
|
local key = "0ec2eb25b6166c0c27a394ae118ad829"
|
||||||
local response = http.post(
|
local response = http.post(
|
||||||
"https://pastebin.com/api/api_post.php",
|
"https://pastebin.com/api/api_post.php",
|
||||||
"api_option=paste&"..
|
"api_option=paste&"..
|
||||||
"api_dev_key="..key.."&"..
|
"api_dev_key="..key.."&"..
|
||||||
"api_paste_format=lua&"..
|
"api_paste_format=lua&"..
|
||||||
"api_paste_name="..textutils.urlEncode(sName).."&"..
|
"api_paste_name="..textutils.urlEncode(sName).."&"..
|
||||||
"api_paste_code="..textutils.urlEncode(sText)
|
"api_paste_code="..textutils.urlEncode(sText)
|
||||||
)
|
)
|
||||||
|
|
||||||
if response then
|
if response then
|
||||||
print( "Success." )
|
print( "Success." )
|
||||||
|
|
||||||
local sResponse = response.readAll()
|
local sResponse = response.readAll()
|
||||||
response.close()
|
response.close()
|
||||||
|
|
||||||
local sCode = string.match( sResponse, "[^/]+$" )
|
local sCode = string.match( sResponse, "[^/]+$" )
|
||||||
print( "Uploaded as "..sResponse )
|
print( "Uploaded as "..sResponse )
|
||||||
print( "Run \"pastebin get "..sCode.."\" to download anywhere" )
|
print( "Run \"pastebin get "..sCode.."\" to download anywhere" )
|
||||||
|
|
||||||
else
|
else
|
||||||
print( "Failed." )
|
print( "Failed." )
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif sCommand == "get" then
|
elseif sCommand == "get" then
|
||||||
-- Download a file from pastebin.com
|
-- Download a file from pastebin.com
|
||||||
if #tArgs < 3 then
|
if #tArgs < 3 then
|
||||||
printUsage()
|
printUsage()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Determine file to download
|
-- Determine file to download
|
||||||
local sCode = tArgs[2]
|
local sCode = tArgs[2]
|
||||||
local sFile = tArgs[3]
|
local sFile = tArgs[3]
|
||||||
@ -93,19 +93,19 @@ elseif sCommand == "get" then
|
|||||||
print( "File already exists" )
|
print( "File already exists" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- GET the contents from pastebin
|
-- GET the contents from pastebin
|
||||||
local res = get(sCode)
|
local res = get(sCode)
|
||||||
if res then
|
if res then
|
||||||
local file = fs.open( sPath, "w" )
|
local file = fs.open( sPath, "w" )
|
||||||
file.write( res )
|
file.write( res )
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
print( "Downloaded as "..sFile )
|
print( "Downloaded as "..sFile )
|
||||||
end
|
end
|
||||||
elseif sCommand == "run" then
|
elseif sCommand == "run" then
|
||||||
local sCode = tArgs[2]
|
local sCode = tArgs[2]
|
||||||
|
|
||||||
local res = get(sCode)
|
local res = get(sCode)
|
||||||
if res then
|
if res then
|
||||||
local func, err = load(res, sCode, "t", _ENV)
|
local func, err = load(res, sCode, "t", _ENV)
|
||||||
|
@ -3,13 +3,13 @@ local function printUsage()
|
|||||||
print( "Usage:" )
|
print( "Usage:" )
|
||||||
print( "wget <url> [filename]" )
|
print( "wget <url> [filename]" )
|
||||||
end
|
end
|
||||||
|
|
||||||
local tArgs = { ... }
|
local tArgs = { ... }
|
||||||
if #tArgs < 1 then
|
if #tArgs < 1 then
|
||||||
printUsage()
|
printUsage()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not http then
|
if not http then
|
||||||
printError( "wget requires http API" )
|
printError( "wget requires http API" )
|
||||||
printError( "Set http_enable to true in ComputerCraft.cfg" )
|
printError( "Set http_enable to true in ComputerCraft.cfg" )
|
||||||
|
@ -7,7 +7,7 @@ end
|
|||||||
|
|
||||||
if sDrive == nil then
|
if sDrive == nil then
|
||||||
print( "This is computer #"..os.getComputerID() )
|
print( "This is computer #"..os.getComputerID() )
|
||||||
|
|
||||||
local label = os.getComputerLabel()
|
local label = os.getComputerLabel()
|
||||||
if label then
|
if label then
|
||||||
print( "This computer is labelled \""..label.."\"" )
|
print( "This computer is labelled \""..label.."\"" )
|
||||||
@ -19,7 +19,7 @@ else
|
|||||||
print( "No disk in drive "..sDrive )
|
print( "No disk in drive "..sDrive )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
print( "The disk is #"..disk.getID( sDrive ) )
|
print( "The disk is #"..disk.getID( sDrive ) )
|
||||||
|
|
||||||
local label = disk.getLabel( sDrive )
|
local label = disk.getLabel( sDrive )
|
||||||
@ -27,4 +27,3 @@ else
|
|||||||
print( "The disk is labelled \""..label.."\"" )
|
print( "The disk is labelled \""..label.."\"" )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ while bRunning do
|
|||||||
if s:match("%S") and tCommandHistory[#tCommandHistory] ~= s then
|
if s:match("%S") and tCommandHistory[#tCommandHistory] ~= s then
|
||||||
table.insert( tCommandHistory, s )
|
table.insert( tCommandHistory, s )
|
||||||
end
|
end
|
||||||
|
|
||||||
local nForcePrint = 0
|
local nForcePrint = 0
|
||||||
local func, e = load( s, "lua", "t", tEnv )
|
local func, e = load( s, "lua", "t", tEnv )
|
||||||
local func2, e2 = load( "return _echo("..s..");", "lua", "t", tEnv )
|
local func2, e2 = load( "return _echo("..s..");", "lua", "t", tEnv )
|
||||||
@ -62,7 +62,7 @@ while bRunning do
|
|||||||
func = func2
|
func = func2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if func then
|
if func then
|
||||||
local tResults = table.pack( pcall( func ) )
|
local tResults = table.pack( pcall( func ) )
|
||||||
if tResults[1] then
|
if tResults[1] then
|
||||||
@ -92,5 +92,5 @@ while bRunning do
|
|||||||
else
|
else
|
||||||
printError( e )
|
printError( e )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
local function printUsage()
|
local function printUsage()
|
||||||
print( "Usage: monitor <name> <program> <arguments>" )
|
print( "Usage: monitor <name> <program> <arguments>" )
|
||||||
return
|
return
|
||||||
@ -64,4 +63,3 @@ term.redirect( previousTerm )
|
|||||||
if not ok then
|
if not ok then
|
||||||
printError( param )
|
printError( param )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@ if not ok then
|
|||||||
printError( "Nothing to unequip" )
|
printError( "Nothing to unequip" )
|
||||||
else
|
else
|
||||||
print( "Item unequipped" )
|
print( "Item unequipped" )
|
||||||
end
|
end
|
||||||
|
@ -15,14 +15,14 @@ else
|
|||||||
print( #tModems .. " modems found." )
|
print( #tModems .. " modems found." )
|
||||||
end
|
end
|
||||||
|
|
||||||
function open( nChannel )
|
local function open( nChannel )
|
||||||
for n=1,#tModems do
|
for n=1,#tModems do
|
||||||
local sModem = tModems[n]
|
local sModem = tModems[n]
|
||||||
peripheral.call( sModem, "open", nChannel )
|
peripheral.call( sModem, "open", nChannel )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function close( nChannel )
|
local function close( nChannel )
|
||||||
for n=1,#tModems do
|
for n=1,#tModems do
|
||||||
local sModem = tModems[n]
|
local sModem = tModems[n]
|
||||||
peripheral.call( sModem, "close", nChannel )
|
peripheral.call( sModem, "close", nChannel )
|
||||||
|
@ -254,7 +254,7 @@ function shell.resolveProgram( _sCommand )
|
|||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Otherwise, look on the path variable
|
-- Otherwise, look on the path variable
|
||||||
for sPath in string.gmatch(sPath, "[^:]+") do
|
for sPath in string.gmatch(sPath, "[^:]+") do
|
||||||
sPath = fs.combine( shell.resolve( sPath ), _sCommand )
|
sPath = fs.combine( shell.resolve( sPath ), _sCommand )
|
||||||
@ -267,14 +267,14 @@ function shell.resolveProgram( _sCommand )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Not found
|
-- Not found
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function shell.programs( _bIncludeHidden )
|
function shell.programs( _bIncludeHidden )
|
||||||
local tItems = {}
|
local tItems = {}
|
||||||
|
|
||||||
-- Add programs from the path
|
-- Add programs from the path
|
||||||
for sPath in string.gmatch(sPath, "[^:]+") do
|
for sPath in string.gmatch(sPath, "[^:]+") do
|
||||||
sPath = shell.resolve( sPath )
|
sPath = shell.resolve( sPath )
|
||||||
@ -291,7 +291,7 @@ function shell.programs( _bIncludeHidden )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sort and return
|
-- Sort and return
|
||||||
local tItemList = {}
|
local tItemList = {}
|
||||||
|
@ -96,7 +96,7 @@ parallel.waitForAny(
|
|||||||
if key ~= keys.escape then
|
if key ~= keys.escape then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
function()
|
function()
|
||||||
while true do
|
while true do
|
||||||
|
@ -11,7 +11,7 @@ if size < 1 then
|
|||||||
print( "Excavate diameter must be positive" )
|
print( "Excavate diameter must be positive" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local depth = 0
|
local depth = 0
|
||||||
local unloaded = 0
|
local unloaded = 0
|
||||||
local collected = 0
|
local collected = 0
|
||||||
@ -21,18 +21,18 @@ local xDir,zDir = 0,1
|
|||||||
|
|
||||||
local goTo -- Filled in further down
|
local goTo -- Filled in further down
|
||||||
local refuel -- Filled in further down
|
local refuel -- Filled in further down
|
||||||
|
|
||||||
local function unload( _bKeepOneFuelStack )
|
local function unload( _bKeepOneFuelStack )
|
||||||
print( "Unloading items..." )
|
print( "Unloading items..." )
|
||||||
for n=1,16 do
|
for n=1,16 do
|
||||||
local nCount = turtle.getItemCount(n)
|
local nCount = turtle.getItemCount(n)
|
||||||
if nCount > 0 then
|
if nCount > 0 then
|
||||||
turtle.select(n)
|
turtle.select(n)
|
||||||
local bDrop = true
|
local bDrop = true
|
||||||
if _bKeepOneFuelStack and turtle.refuel(0) then
|
if _bKeepOneFuelStack and turtle.refuel(0) then
|
||||||
bDrop = false
|
bDrop = false
|
||||||
_bKeepOneFuelStack = false
|
_bKeepOneFuelStack = false
|
||||||
end
|
end
|
||||||
if bDrop then
|
if bDrop then
|
||||||
turtle.drop()
|
turtle.drop()
|
||||||
unloaded = unloaded + nCount
|
unloaded = unloaded + nCount
|
||||||
@ -47,7 +47,7 @@ local function returnSupplies()
|
|||||||
local x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
|
local x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir
|
||||||
print( "Returning to surface..." )
|
print( "Returning to surface..." )
|
||||||
goTo( 0,0,0,0,-1 )
|
goTo( 0,0,0,0,-1 )
|
||||||
|
|
||||||
local fuelNeeded = 2*(x+y+z) + 1
|
local fuelNeeded = 2*(x+y+z) + 1
|
||||||
if not refuel( fuelNeeded ) then
|
if not refuel( fuelNeeded ) then
|
||||||
unload( true )
|
unload( true )
|
||||||
@ -56,14 +56,14 @@ local function returnSupplies()
|
|||||||
os.pullEvent( "turtle_inventory" )
|
os.pullEvent( "turtle_inventory" )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
unload( true )
|
unload( true )
|
||||||
end
|
end
|
||||||
|
|
||||||
print( "Resuming mining..." )
|
print( "Resuming mining..." )
|
||||||
goTo( x,y,z,xd,zd )
|
goTo( x,y,z,xd,zd )
|
||||||
end
|
end
|
||||||
|
|
||||||
local function collect()
|
local function collect()
|
||||||
local bFull = true
|
local bFull = true
|
||||||
local nTotalItems = 0
|
local nTotalItems = 0
|
||||||
for n=1,16 do
|
for n=1,16 do
|
||||||
@ -73,14 +73,14 @@ local function collect()
|
|||||||
end
|
end
|
||||||
nTotalItems = nTotalItems + nCount
|
nTotalItems = nTotalItems + nCount
|
||||||
end
|
end
|
||||||
|
|
||||||
if nTotalItems > collected then
|
if nTotalItems > collected then
|
||||||
collected = nTotalItems
|
collected = nTotalItems
|
||||||
if math.fmod(collected + unloaded, 50) == 0 then
|
if math.fmod(collected + unloaded, 50) == 0 then
|
||||||
print( "Mined "..(collected + unloaded).." items." )
|
print( "Mined "..(collected + unloaded).." items." )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if bFull then
|
if bFull then
|
||||||
print( "No empty slots left." )
|
print( "No empty slots left." )
|
||||||
return false
|
return false
|
||||||
@ -93,7 +93,7 @@ function refuel( ammount )
|
|||||||
if fuelLevel == "unlimited" then
|
if fuelLevel == "unlimited" then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local needed = ammount or (xPos + zPos + depth + 2)
|
local needed = ammount or (xPos + zPos + depth + 2)
|
||||||
if turtle.getFuelLevel() < needed then
|
if turtle.getFuelLevel() < needed then
|
||||||
local fueled = false
|
local fueled = false
|
||||||
@ -114,7 +114,7 @@ function refuel( ammount )
|
|||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ local function tryForwards()
|
|||||||
print( "Not enough Fuel" )
|
print( "Not enough Fuel" )
|
||||||
returnSupplies()
|
returnSupplies()
|
||||||
end
|
end
|
||||||
|
|
||||||
while not turtle.forward() do
|
while not turtle.forward() do
|
||||||
if turtle.detect() then
|
if turtle.detect() then
|
||||||
if turtle.dig() then
|
if turtle.dig() then
|
||||||
@ -141,7 +141,7 @@ local function tryForwards()
|
|||||||
sleep( 0.5 )
|
sleep( 0.5 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
xPos = xPos + xDir
|
xPos = xPos + xDir
|
||||||
zPos = zPos + zDir
|
zPos = zPos + zDir
|
||||||
return true
|
return true
|
||||||
@ -152,7 +152,7 @@ local function tryDown()
|
|||||||
print( "Not enough Fuel" )
|
print( "Not enough Fuel" )
|
||||||
returnSupplies()
|
returnSupplies()
|
||||||
end
|
end
|
||||||
|
|
||||||
while not turtle.down() do
|
while not turtle.down() do
|
||||||
if turtle.detectDown() then
|
if turtle.detectDown() then
|
||||||
if turtle.digDown() then
|
if turtle.digDown() then
|
||||||
@ -227,7 +227,7 @@ function goTo( x, y, z, xd, zd )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if zPos > z then
|
if zPos > z then
|
||||||
while zDir ~= -1 do
|
while zDir ~= -1 do
|
||||||
turnLeft()
|
turnLeft()
|
||||||
@ -253,9 +253,9 @@ function goTo( x, y, z, xd, zd )
|
|||||||
else
|
else
|
||||||
sleep( 0.5 )
|
sleep( 0.5 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
while depth < y do
|
while depth < y do
|
||||||
if turtle.down() then
|
if turtle.down() then
|
||||||
depth = depth + 1
|
depth = depth + 1
|
||||||
@ -265,7 +265,7 @@ function goTo( x, y, z, xd, zd )
|
|||||||
sleep( 0.5 )
|
sleep( 0.5 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
while zDir ~= zd or xDir ~= xd do
|
while zDir ~= zd or xDir ~= xd do
|
||||||
turnLeft()
|
turnLeft()
|
||||||
end
|
end
|
||||||
@ -318,7 +318,7 @@ while not done do
|
|||||||
if done then
|
if done then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
if size > 1 then
|
if size > 1 then
|
||||||
if math.fmod(size,2) == 0 then
|
if math.fmod(size,2) == 0 then
|
||||||
turnRight()
|
turnRight()
|
||||||
@ -331,7 +331,7 @@ while not done do
|
|||||||
alternate = 1 - alternate
|
alternate = 1 - alternate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not tryDown() then
|
if not tryDown() then
|
||||||
done = true
|
done = true
|
||||||
break
|
break
|
||||||
|
@ -11,7 +11,7 @@ if length < 1 then
|
|||||||
print( "Tunnel length must be positive" )
|
print( "Tunnel length must be positive" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local depth = 0
|
local depth = 0
|
||||||
local collected = 0
|
local collected = 0
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ local function refuel()
|
|||||||
if fuelLevel == "unlimited" or fuelLevel > 0 then
|
if fuelLevel == "unlimited" or fuelLevel > 0 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tryRefuel()
|
local function tryRefuel()
|
||||||
for n=1,16 do
|
for n=1,16 do
|
||||||
if turtle.getItemCount(n) > 0 then
|
if turtle.getItemCount(n) > 0 then
|
||||||
@ -77,7 +77,7 @@ local function refuel()
|
|||||||
turtle.select(1)
|
turtle.select(1)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if not tryRefuel() then
|
if not tryRefuel() then
|
||||||
print( "Add more fuel to continue." )
|
print( "Add more fuel to continue." )
|
||||||
while not tryRefuel() do
|
while not tryRefuel() do
|
||||||
@ -150,7 +150,7 @@ for n=1,length do
|
|||||||
tryDown()
|
tryDown()
|
||||||
tryDig()
|
tryDig()
|
||||||
turtle.turnLeft()
|
turtle.turnLeft()
|
||||||
|
|
||||||
if n<length then
|
if n<length then
|
||||||
tryDig()
|
tryDig()
|
||||||
if not tryForward() then
|
if not tryForward() then
|
||||||
|
@ -34,5 +34,4 @@ while nArg <= #tArgs do
|
|||||||
print( "Try: left, right" )
|
print( "Try: left, right" )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -168,7 +168,7 @@ local function completeSet( shell, nIndex, sText, tPreviousText )
|
|||||||
return completeMultipleChoice( sText, settings.getNames(), true )
|
return completeMultipleChoice( sText, settings.getNames(), true )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local tCommands
|
local tCommands
|
||||||
if commands then
|
if commands then
|
||||||
tCommands = commands.list()
|
tCommands = commands.list()
|
||||||
end
|
end
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,159 +1,159 @@
|
|||||||
function new(_sizeX, _sizeY, _color)
|
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}}
|
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)
|
redirect.write = function(text)
|
||||||
text = tostring(text)
|
text = tostring(text)
|
||||||
local pos = redirect.buffer.cursorX
|
local pos = redirect.buffer.cursorX
|
||||||
if redirect.buffer.cursorY > redirect.buffer.sizeY or redirect.buffer.cursorY < 1 then
|
if redirect.buffer.cursorY > redirect.buffer.sizeY or redirect.buffer.cursorY < 1 then
|
||||||
redirect.buffer.cursorX = pos + #text
|
redirect.buffer.cursorX = pos + #text
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local writeText
|
local writeText
|
||||||
if pos + #text <= 1 then
|
if pos + #text <= 1 then
|
||||||
--skip entirely.
|
--skip entirely.
|
||||||
redirect.buffer.cursorX = pos + #text
|
redirect.buffer.cursorX = pos + #text
|
||||||
return
|
return
|
||||||
elseif pos < 1 then
|
elseif pos < 1 then
|
||||||
--adjust text to fit on screen starting at one.
|
--adjust text to fit on screen starting at one.
|
||||||
writeText = string.sub(text, math.abs(redirect.buffer.cursorX) + 2)
|
writeText = string.sub(text, math.abs(redirect.buffer.cursorX) + 2)
|
||||||
redirect.buffer.cursorX = 1
|
redirect.buffer.cursorX = 1
|
||||||
elseif pos > redirect.buffer.sizeX then
|
elseif pos > redirect.buffer.sizeX then
|
||||||
--if we're off the edge to the right, skip entirely.
|
--if we're off the edge to the right, skip entirely.
|
||||||
redirect.buffer.cursorX = pos + #text
|
redirect.buffer.cursorX = pos + #text
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
writeText = text
|
writeText = text
|
||||||
end
|
end
|
||||||
local lineText = redirect.buffer.text[redirect.buffer.cursorY]
|
local lineText = redirect.buffer.text[redirect.buffer.cursorY]
|
||||||
local lineColor = redirect.buffer.textColor[redirect.buffer.cursorY]
|
local lineColor = redirect.buffer.textColor[redirect.buffer.cursorY]
|
||||||
local lineBack = redirect.buffer.backColor[redirect.buffer.cursorY]
|
local lineBack = redirect.buffer.backColor[redirect.buffer.cursorY]
|
||||||
local preStop = redirect.buffer.cursorX - 1
|
local preStop = redirect.buffer.cursorX - 1
|
||||||
local preStart = math.min(1, preStop)
|
local preStart = math.min(1, preStop)
|
||||||
local postStart = redirect.buffer.cursorX + string.len(writeText)
|
local postStart = redirect.buffer.cursorX + string.len(writeText)
|
||||||
local postStop = redirect.buffer.sizeX
|
local postStop = redirect.buffer.sizeX
|
||||||
redirect.buffer.text[redirect.buffer.cursorY] = string.sub(lineText, preStart, preStop)..writeText..string.sub(lineText, postStart, postStop)
|
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.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.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)
|
redirect.buffer.cursorX = pos + string.len(text)
|
||||||
end
|
end
|
||||||
redirect.clear = function()
|
redirect.clear = function()
|
||||||
for i=1, redirect.buffer.sizeY do
|
for i=1, redirect.buffer.sizeY do
|
||||||
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
|
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
|
||||||
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, 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)
|
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect.clearLine = function()
|
redirect.clearLine = function()
|
||||||
redirect.buffer.text[redirect.buffer.cursorY] = string.rep(" ", redirect.buffer.sizeX)
|
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.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)
|
redirect.buffer.backColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
|
||||||
end
|
end
|
||||||
redirect.getCursorPos = function()
|
redirect.getCursorPos = function()
|
||||||
return redirect.buffer.cursorX, redirect.buffer.cursorY
|
return redirect.buffer.cursorX, redirect.buffer.cursorY
|
||||||
end
|
end
|
||||||
redirect.setCursorPos = function(x, y)
|
redirect.setCursorPos = function(x, y)
|
||||||
redirect.buffer.cursorX = math.floor(tonumber(x)) or redirect.buffer.cursorX
|
redirect.buffer.cursorX = math.floor(tonumber(x)) or redirect.buffer.cursorX
|
||||||
redirect.buffer.cursorY = math.floor(tonumber(y)) or redirect.buffer.cursorY
|
redirect.buffer.cursorY = math.floor(tonumber(y)) or redirect.buffer.cursorY
|
||||||
end
|
end
|
||||||
redirect.setCursorBlink = function(b)
|
redirect.setCursorBlink = function(b)
|
||||||
redirect.buffer.cursorBlink = b
|
redirect.buffer.cursorBlink = b
|
||||||
end
|
end
|
||||||
redirect.getSize = function()
|
redirect.getSize = function()
|
||||||
return redirect.buffer.sizeX, redirect.buffer.sizeY
|
return redirect.buffer.sizeX, redirect.buffer.sizeY
|
||||||
end
|
end
|
||||||
redirect.scroll = function(n)
|
redirect.scroll = function(n)
|
||||||
n = tonumber(n) or 1
|
n = tonumber(n) or 1
|
||||||
if n > 0 then
|
if n > 0 then
|
||||||
for i = 1, redirect.buffer.sizeY - n do
|
for i = 1, redirect.buffer.sizeY - n do
|
||||||
if redirect.buffer.text[i + n] then
|
if redirect.buffer.text[i + n] then
|
||||||
redirect.buffer.text[i] = redirect.buffer.text[i + n]
|
redirect.buffer.text[i] = redirect.buffer.text[i + n]
|
||||||
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
|
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
|
||||||
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
|
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i = redirect.buffer.sizeY, redirect.buffer.sizeY - n + 1, -1 do
|
for i = redirect.buffer.sizeY, redirect.buffer.sizeY - n + 1, -1 do
|
||||||
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
|
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
|
||||||
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, 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)
|
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
|
||||||
end
|
end
|
||||||
elseif n < 0 then
|
elseif n < 0 then
|
||||||
for i = redirect.buffer.sizeY, math.abs(n) + 1, -1 do
|
for i = redirect.buffer.sizeY, math.abs(n) + 1, -1 do
|
||||||
if redirect.buffer.text[i + n] then
|
if redirect.buffer.text[i + n] then
|
||||||
redirect.buffer.text[i] = redirect.buffer.text[i + n]
|
redirect.buffer.text[i] = redirect.buffer.text[i + n]
|
||||||
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
|
redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n]
|
||||||
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
|
redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i = 1, math.abs(n) do
|
for i = 1, math.abs(n) do
|
||||||
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
|
redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX)
|
||||||
redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, 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)
|
redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect.setTextColor = function(clr)
|
redirect.setTextColor = function(clr)
|
||||||
if clr and clr <= 32768 and clr >= 1 then
|
if clr and clr <= 32768 and clr >= 1 then
|
||||||
if redirect.buffer.color then
|
if redirect.buffer.color then
|
||||||
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
||||||
elseif clr == 1 or clr == 32768 then
|
elseif clr == 1 or clr == 32768 then
|
||||||
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
||||||
else
|
else
|
||||||
return nil, "Colour not supported"
|
return nil, "Colour not supported"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect.setTextColour = redirect.setTextColor
|
redirect.setTextColour = redirect.setTextColor
|
||||||
redirect.setBackgroundColor = function(clr)
|
redirect.setBackgroundColor = function(clr)
|
||||||
if clr and clr <= 32768 and clr >= 1 then
|
if clr and clr <= 32768 and clr >= 1 then
|
||||||
if redirect.buffer.color then
|
if redirect.buffer.color then
|
||||||
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
||||||
elseif clr == 32768 or clr == 1 then
|
elseif clr == 32768 or clr == 1 then
|
||||||
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2)))
|
||||||
else
|
else
|
||||||
return nil, "Colour not supported"
|
return nil, "Colour not supported"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect.setBackgroundColour = redirect.setBackgroundColor
|
redirect.setBackgroundColour = redirect.setBackgroundColor
|
||||||
redirect.isColor = function()
|
redirect.isColor = function()
|
||||||
return redirect.buffer.color == true
|
return redirect.buffer.color == true
|
||||||
end
|
end
|
||||||
redirect.isColour = redirect.isColor
|
redirect.isColour = redirect.isColor
|
||||||
redirect.render = function(inputBuffer)
|
redirect.render = function(inputBuffer)
|
||||||
for i = 1, redirect.buffer.sizeY do
|
for i = 1, redirect.buffer.sizeY do
|
||||||
redirect.buffer.text[i] = inputBuffer.text[i]
|
redirect.buffer.text[i] = inputBuffer.text[i]
|
||||||
redirect.buffer.textColor[i] = inputBuffer.textColor[i]
|
redirect.buffer.textColor[i] = inputBuffer.textColor[i]
|
||||||
redirect.buffer.backColor[i] = inputBuffer.backColor[i]
|
redirect.buffer.backColor[i] = inputBuffer.backColor[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect.clear()
|
redirect.clear()
|
||||||
return redirect
|
return redirect
|
||||||
end
|
end
|
||||||
|
|
||||||
function draw(buffer, current)
|
function draw(buffer, current)
|
||||||
for i=1, buffer.sizeY do
|
for i=1, buffer.sizeY do
|
||||||
term.setCursorPos(1,i)
|
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
|
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 lineEnd = false
|
||||||
local offset = 1
|
local offset = 1
|
||||||
while not lineEnd do
|
while not lineEnd do
|
||||||
local textColorString = string.match(string.sub(buffer.textColor[i], offset), string.sub(buffer.textColor[i], offset, offset).."*")
|
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).."*")
|
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.setTextColor(2 ^ tonumber(string.sub(textColorString, 1, 1), 16))
|
||||||
term.setBackgroundColor(2 ^ tonumber(string.sub(backColorString, 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))
|
term.write(string.sub(buffer.text[i], offset, offset + math.min(#textColorString, #backColorString) - 1))
|
||||||
offset = offset + math.min(#textColorString, #backColorString)
|
offset = offset + math.min(#textColorString, #backColorString)
|
||||||
if offset > buffer.sizeX then lineEnd = true end
|
if offset > buffer.sizeX then lineEnd = true end
|
||||||
end
|
end
|
||||||
if current then
|
if current then
|
||||||
current.text[i] = buffer.text[i]
|
current.text[i] = buffer.text[i]
|
||||||
current.textColor[i] = buffer.textColor[i]
|
current.textColor[i] = buffer.textColor[i]
|
||||||
current.backColor[i] = buffer.backColor[i]
|
current.backColor[i] = buffer.backColor[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
term.setCursorPos(buffer.cursorX, buffer.cursorY)
|
term.setCursorPos(buffer.cursorX, buffer.cursorY)
|
||||||
term.setTextColor(2 ^ tonumber(buffer.curTextColor, 16))
|
term.setTextColor(2 ^ tonumber(buffer.curTextColor, 16))
|
||||||
term.setBackgroundColor(2 ^ tonumber(buffer.curBackColor, 16))
|
term.setBackgroundColor(2 ^ tonumber(buffer.curBackColor, 16))
|
||||||
term.setCursorBlink(buffer.cursorBlink)
|
term.setCursorBlink(buffer.cursorBlink)
|
||||||
return current
|
return current
|
||||||
end
|
end
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
if not nsh then print("No nsh session!") return end
|
if not nsh then print("No nsh session!") return end
|
||||||
|
|
||||||
local args = {...}
|
local args = {...}
|
||||||
|
|
||||||
if #args < 2 then
|
if #args < 2 then
|
||||||
print("Usage: get <remote> <local>")
|
print("Usage: get <remote> <local>")
|
||||||
print("<remote>: any file on the server")
|
print("<remote>: any file on the server")
|
||||||
print("<local>: any non-existant file on the client")
|
print("<local>: any non-existant file on the client")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if fs.exists(args[1]) then
|
if fs.exists(args[1]) then
|
||||||
nsh.send("FS:;t="..args[2])
|
nsh.send("FS:;t="..args[2])
|
||||||
local message = nsh.receive()
|
local message = nsh.receive()
|
||||||
if message == "FR:;ok" then
|
if message == "FR:;ok" then
|
||||||
nsh.send("FH:;"..args[1])
|
nsh.send("FH:;"..args[1])
|
||||||
local handle = io.open(args[1], "r")
|
local handle = io.open(args[1], "r")
|
||||||
if handle then
|
if handle then
|
||||||
nsh.send("FD:;t="..handle:read("*a"))
|
nsh.send("FD:;t="..handle:read("*a"))
|
||||||
handle:close()
|
handle:close()
|
||||||
end
|
end
|
||||||
nsh.send("FE:;end")
|
nsh.send("FE:;end")
|
||||||
else
|
else
|
||||||
print("Client rejected file!")
|
print("Client rejected file!")
|
||||||
end
|
end
|
||||||
end
|
end
|
File diff suppressed because it is too large
Load Diff
@ -1,35 +1,35 @@
|
|||||||
if not nsh then print("No nsh session!") return end
|
if not nsh then print("No nsh session!") return end
|
||||||
|
|
||||||
local args = {...}
|
local args = {...}
|
||||||
|
|
||||||
if #args < 2 then
|
if #args < 2 then
|
||||||
print("Usage: put <local> <remote>")
|
print("Usage: put <local> <remote>")
|
||||||
print("<local>: any file on the client")
|
print("<local>: any file on the client")
|
||||||
print("<remote>: any file on the server")
|
print("<remote>: any file on the server")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local fileData = ""
|
local fileData = ""
|
||||||
|
|
||||||
nsh.send("FQ:;t="..args[1])
|
nsh.send("FQ:;t="..args[1])
|
||||||
local message = nsh.receive()
|
local message = nsh.receive()
|
||||||
if message ~= "fileNotFound" then
|
if message ~= "fileNotFound" then
|
||||||
while true do
|
while true do
|
||||||
message = nsh.receive()
|
message = nsh.receive()
|
||||||
pType = string.sub(message, 1, 2)
|
pType = string.sub(message, 1, 2)
|
||||||
if pType == "FD" then
|
if pType == "FD" then
|
||||||
fileData = fileData..string.match(message, "^FD:;t=(.*)")
|
fileData = fileData..string.match(message, "^FD:;t=(.*)")
|
||||||
elseif pType == "FE" then
|
elseif pType == "FE" then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #fileData > 0 then
|
if #fileData > 0 then
|
||||||
local handle = io.open(args[2], "w")
|
local handle = io.open(args[2], "w")
|
||||||
if handle then
|
if handle then
|
||||||
handle:write(fileData)
|
handle:write(fileData)
|
||||||
handle:close()
|
handle:close()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
print("Empty file not written!")
|
print("Empty file not written!")
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,178 +1,178 @@
|
|||||||
board = {}
|
board = {}
|
||||||
tArgs = { ... }
|
tArgs = { ... }
|
||||||
generation = 0
|
generation = 0
|
||||||
sleeptime = 0.5
|
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
|
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])
|
mon = peripheral.wrap(tArgs[1])
|
||||||
else
|
else
|
||||||
mon = term
|
mon = term
|
||||||
end
|
end
|
||||||
|
|
||||||
if(mon.isColor() or mon.isColor)then
|
if(mon.isColor() or mon.isColor)then
|
||||||
colored = true
|
colored = true
|
||||||
else
|
else
|
||||||
colored = false
|
colored = false
|
||||||
end
|
end
|
||||||
|
|
||||||
w, h = mon.getSize()
|
w, h = mon.getSize()
|
||||||
for x = 1, w do
|
for x = 1, w do
|
||||||
board[x] = {}
|
board[x] = {}
|
||||||
for y = 1, h do
|
for y = 1, h do
|
||||||
board[x][y] = 0
|
board[x][y] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function drawScreen()
|
function drawScreen()
|
||||||
w, h = mon.getSize()
|
w, h = mon.getSize()
|
||||||
for x = 1, w do
|
for x = 1, w do
|
||||||
for y = 1, h do
|
for y = 1, h do
|
||||||
nei = getNeighbours(x, y)
|
nei = getNeighbours(x, y)
|
||||||
if(board[x][y] == 1)then
|
if(board[x][y] == 1)then
|
||||||
if colored then
|
if colored then
|
||||||
if(nei < 2 or nei > 3)then
|
if(nei < 2 or nei > 3)then
|
||||||
mon.setBackgroundColor(colors.red)
|
mon.setBackgroundColor(colors.red)
|
||||||
else
|
else
|
||||||
mon.setBackgroundColor(colors.green)
|
mon.setBackgroundColor(colors.green)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
mon.setBackgroundColor(colors.white)
|
mon.setBackgroundColor(colors.white)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if colored then
|
if colored then
|
||||||
if(nei == 3)then
|
if(nei == 3)then
|
||||||
mon.setBackgroundColor(colors.yellow)
|
mon.setBackgroundColor(colors.yellow)
|
||||||
else
|
else
|
||||||
mon.setBackgroundColor(colors.black)
|
mon.setBackgroundColor(colors.black)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
mon.setBackgroundColor(colors.black)
|
mon.setBackgroundColor(colors.black)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mon.setCursorPos(x, y)
|
mon.setCursorPos(x, y)
|
||||||
mon.write(" ")
|
mon.write(" ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
mon.setCursorPos(1,1)
|
mon.setCursorPos(1,1)
|
||||||
if colored then
|
if colored then
|
||||||
mon.setTextColor(colors.blue)
|
mon.setTextColor(colors.blue)
|
||||||
end
|
end
|
||||||
mon.write(generation)
|
mon.write(generation)
|
||||||
end
|
end
|
||||||
|
|
||||||
function getNeighbours(x, y)
|
function getNeighbours(x, y)
|
||||||
w, h = mon.getSize()
|
w, h = mon.getSize()
|
||||||
total = 0
|
total = 0
|
||||||
if(x > 1 and y > 1)then if(board[x-1][y-1] == 1)then total = total + 1 end end
|
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(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 < 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 > 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 < 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(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(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
|
if(x < w and y < h)then if(board[x+1][y+1] == 1)then total = total + 1 end end
|
||||||
return total
|
return total
|
||||||
end
|
end
|
||||||
|
|
||||||
function compute()
|
function compute()
|
||||||
w, h = mon.getSize()
|
w, h = mon.getSize()
|
||||||
while true do
|
while true do
|
||||||
newBoard = {}
|
newBoard = {}
|
||||||
for x = 1, w do
|
for x = 1, w do
|
||||||
newBoard[x] = {}
|
newBoard[x] = {}
|
||||||
for y = 1, h do
|
for y = 1, h do
|
||||||
nei = getNeighbours(x, y)
|
nei = getNeighbours(x, y)
|
||||||
if(board[x][y] == 1)then
|
if(board[x][y] == 1)then
|
||||||
if(nei < 2)then
|
if(nei < 2)then
|
||||||
newBoard[x][y] = 0
|
newBoard[x][y] = 0
|
||||||
elseif(nei > 3)then
|
elseif(nei > 3)then
|
||||||
newBoard[x][y] = 0
|
newBoard[x][y] = 0
|
||||||
else
|
else
|
||||||
newBoard[x][y] = 1
|
newBoard[x][y] = 1
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if(nei == 3)then
|
if(nei == 3)then
|
||||||
newBoard[x][y] = 1
|
newBoard[x][y] = 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
board = newBoard
|
board = newBoard
|
||||||
generation = generation + 1
|
generation = generation + 1
|
||||||
sleep(sleeptime)
|
sleep(sleeptime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function loop()
|
function loop()
|
||||||
while true do
|
while true do
|
||||||
event, variable, xPos, yPos = os.pullEvent()
|
event, variable, xPos, yPos = os.pullEvent()
|
||||||
if event == "mouse_click" or event == "monitor_touch" or event == "mouse_drag" then
|
if event == "mouse_click" or event == "monitor_touch" or event == "mouse_drag" then
|
||||||
if variable == 1 then
|
if variable == 1 then
|
||||||
board[xPos][yPos] = 1
|
board[xPos][yPos] = 1
|
||||||
else
|
else
|
||||||
board[xPos][yPos] = 0
|
board[xPos][yPos] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if event == "key" then
|
if event == "key" then
|
||||||
if tostring(variable) == "28" then
|
if tostring(variable) == "28" then
|
||||||
return true
|
return true
|
||||||
elseif tostring(variable) == "57" then
|
elseif tostring(variable) == "57" then
|
||||||
if(mon.isColor() or mon.isColor)then
|
if(mon.isColor() or mon.isColor)then
|
||||||
colored = not colored
|
colored = not colored
|
||||||
end
|
end
|
||||||
elseif tostring(variable) == "200" then
|
elseif tostring(variable) == "200" then
|
||||||
if sleeptime > 0.1 then
|
if sleeptime > 0.1 then
|
||||||
sleeptime = sleeptime - 0.1
|
sleeptime = sleeptime - 0.1
|
||||||
end
|
end
|
||||||
elseif tostring(variable) == "208" then
|
elseif tostring(variable) == "208" then
|
||||||
if sleeptime < 1 then
|
if sleeptime < 1 then
|
||||||
sleeptime = sleeptime + 0.1
|
sleeptime = sleeptime + 0.1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
drawScreen()
|
drawScreen()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function intro()
|
function intro()
|
||||||
mon.setBackgroundColor(colors.black)
|
mon.setBackgroundColor(colors.black)
|
||||||
mon.clear()
|
mon.clear()
|
||||||
mon.setCursorPos(1,1)
|
mon.setCursorPos(1,1)
|
||||||
mon.write("Conway's Game Of Life")
|
mon.write("Conway's Game Of Life")
|
||||||
mon.setCursorPos(1,2)
|
mon.setCursorPos(1,2)
|
||||||
mon.write("It is a game which represents life.")
|
mon.write("It is a game which represents life.")
|
||||||
mon.setCursorPos(1,3)
|
mon.setCursorPos(1,3)
|
||||||
mon.write("The game runs by 4 basic rules:")
|
mon.write("The game runs by 4 basic rules:")
|
||||||
mon.setCursorPos(1,4)
|
mon.setCursorPos(1,4)
|
||||||
mon.write("1. If a cell has less than 2 neighbours, it dies.")
|
mon.write("1. If a cell has less than 2 neighbours, it dies.")
|
||||||
mon.setCursorPos(1,5)
|
mon.setCursorPos(1,5)
|
||||||
mon.write("2. If a cell has 2 or 3 neightbours, it lives.")
|
mon.write("2. If a cell has 2 or 3 neightbours, it lives.")
|
||||||
mon.setCursorPos(1,6)
|
mon.setCursorPos(1,6)
|
||||||
mon.write("3. If a cell has more than 3 neighbours, it dies.")
|
mon.write("3. If a cell has more than 3 neighbours, it dies.")
|
||||||
mon.setCursorPos(1,7)
|
mon.setCursorPos(1,7)
|
||||||
mon.write("4. If a cell has exactly 3 neighbours it is born.")
|
mon.write("4. If a cell has exactly 3 neighbours it is born.")
|
||||||
mon.setCursorPos(1,9)
|
mon.setCursorPos(1,9)
|
||||||
mon.write("At the top left is the generation count.")
|
mon.write("At the top left is the generation count.")
|
||||||
mon.setCursorPos(1,10)
|
mon.setCursorPos(1,10)
|
||||||
mon.write("Press spacebar to switch between color modes")
|
mon.write("Press spacebar to switch between color modes")
|
||||||
mon.setCursorPos(1,11)
|
mon.setCursorPos(1,11)
|
||||||
mon.write("Press enter to start the game")
|
mon.write("Press enter to start the game")
|
||||||
mon.setCursorPos(1,13)
|
mon.setCursorPos(1,13)
|
||||||
mon.write("Colors:")
|
mon.write("Colors:")
|
||||||
mon.setCursorPos(1,14)
|
mon.setCursorPos(1,14)
|
||||||
mon.write("Red - Cell will die in next generation")
|
mon.write("Red - Cell will die in next generation")
|
||||||
mon.setCursorPos(1,15)
|
mon.setCursorPos(1,15)
|
||||||
mon.write("Green - Cell will live in next generation")
|
mon.write("Green - Cell will live in next generation")
|
||||||
mon.setCursorPos(1,16)
|
mon.setCursorPos(1,16)
|
||||||
mon.write("Yellow - Cell will be born in next generation")
|
mon.write("Yellow - Cell will be born in next generation")
|
||||||
mon.setCursorPos(1,18)
|
mon.setCursorPos(1,18)
|
||||||
mon.write("Press any key to continue!")
|
mon.write("Press any key to continue!")
|
||||||
event, variable, xPos, yPos = os.pullEvent("key")
|
event, variable, xPos, yPos = os.pullEvent("key")
|
||||||
end
|
end
|
||||||
|
|
||||||
intro()
|
intro()
|
||||||
drawScreen()
|
drawScreen()
|
||||||
while true do
|
while true do
|
||||||
loop()
|
loop()
|
||||||
parallel.waitForAny(loop, compute)
|
parallel.waitForAny(loop, compute)
|
||||||
end
|
end
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/computer_front_blink_advanced",
|
"front": "computercraft:blocks/computer_front_blink_advanced",
|
||||||
"side": "computercraft:blocks/computer_side_advanced",
|
"side": "computercraft:blocks/computer_side_advanced",
|
||||||
"top": "computercraft:blocks/computer_top_advanced"
|
"top": "computercraft:blocks/computer_top_advanced"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/computer_front_advanced",
|
"front": "computercraft:blocks/computer_front_advanced",
|
||||||
"side": "computercraft:blocks/computer_side_advanced",
|
"side": "computercraft:blocks/computer_side_advanced",
|
||||||
"top": "computercraft:blocks/computer_top_advanced"
|
"top": "computercraft:blocks/computer_top_advanced"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/computer_front_on_advanced",
|
"front": "computercraft:blocks/computer_front_on_advanced",
|
||||||
"side": "computercraft:blocks/computer_side_advanced",
|
"side": "computercraft:blocks/computer_side_advanced",
|
||||||
"top": "computercraft:blocks/computer_top_advanced"
|
"top": "computercraft:blocks/computer_top_advanced"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/modem",
|
"parent": "computercraft:block/modem",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_modem_face",
|
"front": "computercraft:blocks/adv_modem_face",
|
||||||
"back": "computercraft:blocks/modem_back"
|
"back": "computercraft:blocks/modem_back"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/modem",
|
"parent": "computercraft:block/modem",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_modem_face_on",
|
"front": "computercraft:blocks/adv_modem_face_on",
|
||||||
"back": "computercraft:blocks/modem_back"
|
"back": "computercraft:blocks/modem_back"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor16",
|
"front": "computercraft:blocks/adv_monitor16",
|
||||||
"side": "computercraft:blocks/adv_monitor4",
|
"side": "computercraft:blocks/adv_monitor4",
|
||||||
"top": "computercraft:blocks/adv_monitor0",
|
"top": "computercraft:blocks/adv_monitor0",
|
||||||
"back": "computercraft:blocks/adv_monitor4"
|
"back": "computercraft:blocks/adv_monitor4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor20",
|
"front": "computercraft:blocks/adv_monitor20",
|
||||||
"side": "computercraft:blocks/adv_monitor36",
|
"side": "computercraft:blocks/adv_monitor36",
|
||||||
"top": "computercraft:blocks/adv_monitor0",
|
"top": "computercraft:blocks/adv_monitor0",
|
||||||
"back": "computercraft:blocks/adv_monitor36"
|
"back": "computercraft:blocks/adv_monitor36"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor15",
|
"front": "computercraft:blocks/adv_monitor15",
|
||||||
"side": "computercraft:blocks/adv_monitor4",
|
"side": "computercraft:blocks/adv_monitor4",
|
||||||
"top": "computercraft:blocks/adv_monitor0"
|
"top": "computercraft:blocks/adv_monitor0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor19",
|
"front": "computercraft:blocks/adv_monitor19",
|
||||||
"side": "computercraft:blocks/adv_monitor4",
|
"side": "computercraft:blocks/adv_monitor4",
|
||||||
"top": "computercraft:blocks/adv_monitor1",
|
"top": "computercraft:blocks/adv_monitor1",
|
||||||
"back": "computercraft:blocks/adv_monitor33"
|
"back": "computercraft:blocks/adv_monitor33"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor31",
|
"front": "computercraft:blocks/adv_monitor31",
|
||||||
"side": "computercraft:blocks/adv_monitor7",
|
"side": "computercraft:blocks/adv_monitor7",
|
||||||
"top": "computercraft:blocks/adv_monitor1",
|
"top": "computercraft:blocks/adv_monitor1",
|
||||||
"back": "computercraft:blocks/adv_monitor45"
|
"back": "computercraft:blocks/adv_monitor45"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor18",
|
"front": "computercraft:blocks/adv_monitor18",
|
||||||
"side": "computercraft:blocks/adv_monitor4",
|
"side": "computercraft:blocks/adv_monitor4",
|
||||||
"top": "computercraft:blocks/adv_monitor2",
|
"top": "computercraft:blocks/adv_monitor2",
|
||||||
"back": "computercraft:blocks/adv_monitor34"
|
"back": "computercraft:blocks/adv_monitor34"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor30",
|
"front": "computercraft:blocks/adv_monitor30",
|
||||||
"side": "computercraft:blocks/adv_monitor7",
|
"side": "computercraft:blocks/adv_monitor7",
|
||||||
"top": "computercraft:blocks/adv_monitor2",
|
"top": "computercraft:blocks/adv_monitor2",
|
||||||
"back": "computercraft:blocks/adv_monitor46"
|
"back": "computercraft:blocks/adv_monitor46"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor24",
|
"front": "computercraft:blocks/adv_monitor24",
|
||||||
"side": "computercraft:blocks/adv_monitor38",
|
"side": "computercraft:blocks/adv_monitor38",
|
||||||
"top": "computercraft:blocks/adv_monitor2",
|
"top": "computercraft:blocks/adv_monitor2",
|
||||||
"back": "computercraft:blocks/adv_monitor40"
|
"back": "computercraft:blocks/adv_monitor40"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor27",
|
"front": "computercraft:blocks/adv_monitor27",
|
||||||
"side": "computercraft:blocks/adv_monitor37",
|
"side": "computercraft:blocks/adv_monitor37",
|
||||||
"top": "computercraft:blocks/adv_monitor2",
|
"top": "computercraft:blocks/adv_monitor2",
|
||||||
"back": "computercraft:blocks/adv_monitor43"
|
"back": "computercraft:blocks/adv_monitor43"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor25",
|
"front": "computercraft:blocks/adv_monitor25",
|
||||||
"side": "computercraft:blocks/adv_monitor38",
|
"side": "computercraft:blocks/adv_monitor38",
|
||||||
"top": "computercraft:blocks/adv_monitor1",
|
"top": "computercraft:blocks/adv_monitor1",
|
||||||
"back": "computercraft:blocks/adv_monitor39"
|
"back": "computercraft:blocks/adv_monitor39"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor28",
|
"front": "computercraft:blocks/adv_monitor28",
|
||||||
"side": "computercraft:blocks/adv_monitor37",
|
"side": "computercraft:blocks/adv_monitor37",
|
||||||
"top": "computercraft:blocks/adv_monitor1",
|
"top": "computercraft:blocks/adv_monitor1",
|
||||||
"back": "computercraft:blocks/adv_monitor42"
|
"back": "computercraft:blocks/adv_monitor42"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor17",
|
"front": "computercraft:blocks/adv_monitor17",
|
||||||
"side": "computercraft:blocks/adv_monitor4",
|
"side": "computercraft:blocks/adv_monitor4",
|
||||||
"top": "computercraft:blocks/adv_monitor3",
|
"top": "computercraft:blocks/adv_monitor3",
|
||||||
"back": "computercraft:blocks/adv_monitor35"
|
"back": "computercraft:blocks/adv_monitor35"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor29",
|
"front": "computercraft:blocks/adv_monitor29",
|
||||||
"side": "computercraft:blocks/adv_monitor7",
|
"side": "computercraft:blocks/adv_monitor7",
|
||||||
"top": "computercraft:blocks/adv_monitor3",
|
"top": "computercraft:blocks/adv_monitor3",
|
||||||
"back": "computercraft:blocks/adv_monitor47"
|
"back": "computercraft:blocks/adv_monitor47"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor23",
|
"front": "computercraft:blocks/adv_monitor23",
|
||||||
"side": "computercraft:blocks/adv_monitor38",
|
"side": "computercraft:blocks/adv_monitor38",
|
||||||
"top": "computercraft:blocks/adv_monitor3",
|
"top": "computercraft:blocks/adv_monitor3",
|
||||||
"back": "computercraft:blocks/adv_monitor41"
|
"back": "computercraft:blocks/adv_monitor41"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor26",
|
"front": "computercraft:blocks/adv_monitor26",
|
||||||
"side": "computercraft:blocks/adv_monitor37",
|
"side": "computercraft:blocks/adv_monitor37",
|
||||||
"top": "computercraft:blocks/adv_monitor3",
|
"top": "computercraft:blocks/adv_monitor3",
|
||||||
"back": "computercraft:blocks/adv_monitor44"
|
"back": "computercraft:blocks/adv_monitor44"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor22",
|
"front": "computercraft:blocks/adv_monitor22",
|
||||||
"side": "computercraft:blocks/adv_monitor38",
|
"side": "computercraft:blocks/adv_monitor38",
|
||||||
"top": "computercraft:blocks/adv_monitor0",
|
"top": "computercraft:blocks/adv_monitor0",
|
||||||
"back": "computercraft:blocks/adv_monitor38"
|
"back": "computercraft:blocks/adv_monitor38"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/adv_monitor21",
|
"front": "computercraft:blocks/adv_monitor21",
|
||||||
"side": "computercraft:blocks/adv_monitor37",
|
"side": "computercraft:blocks/adv_monitor37",
|
||||||
"top": "computercraft:blocks/adv_monitor0",
|
"top": "computercraft:blocks/adv_monitor0",
|
||||||
"back": "computercraft:blocks/adv_monitor37"
|
"back": "computercraft:blocks/adv_monitor37"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/turtle_base",
|
"parent": "computercraft:block/turtle_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"texture": "computercraft:blocks/turtle_advanced"
|
"texture": "computercraft:blocks/turtle_advanced"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/turtle_upgrade_base_left",
|
"parent": "computercraft:block/turtle_upgrade_base_left",
|
||||||
"textures": {
|
"textures": {
|
||||||
"texture": "computercraft:blocks/adv_modem_face"
|
"texture": "computercraft:blocks/adv_modem_face"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/turtle_upgrade_base_right",
|
"parent": "computercraft:block/turtle_upgrade_base_right",
|
||||||
"textures": {
|
"textures": {
|
||||||
"texture": "computercraft:blocks/adv_modem_face"
|
"texture": "computercraft:blocks/adv_modem_face"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/turtle_upgrade_base_left",
|
"parent": "computercraft:block/turtle_upgrade_base_left",
|
||||||
"textures": {
|
"textures": {
|
||||||
"texture": "computercraft:blocks/adv_modem_face_on"
|
"texture": "computercraft:blocks/adv_modem_face_on"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/turtle_upgrade_base_right",
|
"parent": "computercraft:block/turtle_upgrade_base_right",
|
||||||
"textures": {
|
"textures": {
|
||||||
"texture": "computercraft:blocks/adv_modem_face_on"
|
"texture": "computercraft:blocks/adv_modem_face_on"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/block",
|
"parent": "block/block",
|
||||||
"textures": {
|
"textures": {
|
||||||
"particle": "computercraft:blocks/cable_core",
|
"particle": "computercraft:blocks/cable_core",
|
||||||
"side": "computercraft:blocks/cable_side"
|
"side": "computercraft:blocks/cable_side"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"from": [ 6, 6, 10 ],
|
"from": [ 6, 6, 10 ],
|
||||||
"to": [ 10, 10, 16 ],
|
"to": [ 10, 10, 16 ],
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 6, 0, 10, 6 ], "texture": "#side" },
|
"down": { "uv": [ 6, 0, 10, 6 ], "texture": "#side" },
|
||||||
"up": { "uv": [ 6, 10, 10, 16 ], "texture": "#side" },
|
"up": { "uv": [ 6, 10, 10, 16 ], "texture": "#side" },
|
||||||
"west": { "uv": [ 0, 6, 6, 10 ], "texture": "#side" },
|
"west": { "uv": [ 0, 6, 6, 10 ], "texture": "#side" },
|
||||||
"east": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" }
|
"east": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"side": "computercraft:blocks/cable_side"
|
"side": "computercraft:blocks/cable_side"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"from": [ 6, 6, 6 ],
|
"from": [ 6, 6, 6 ],
|
||||||
"to": [ 10, 10, 10 ],
|
"to": [ 10, 10, 10 ],
|
||||||
"faces": {
|
"faces": {
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/block",
|
"parent": "block/block",
|
||||||
"textures": {
|
"textures": {
|
||||||
"particle": "computercraft:blocks/cable_core",
|
"particle": "computercraft:blocks/cable_core",
|
||||||
"side": "computercraft:blocks/cable_side",
|
"side": "computercraft:blocks/cable_side",
|
||||||
"end": "computercraft:blocks/cable_core"
|
"end": "computercraft:blocks/cable_core"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"from": [ 6, 6, 2 ],
|
"from": [ 6, 6, 2 ],
|
||||||
"to": [ 10, 10, 14 ],
|
"to": [ 10, 10, 14 ],
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
|
"down": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
|
||||||
"up": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
|
"up": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" },
|
||||||
"north": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
|
"north": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
|
||||||
"south": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
|
"south": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" },
|
||||||
"west": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" },
|
"west": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" },
|
||||||
"east": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" }
|
"east": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/command_computer_front_blink",
|
"front": "computercraft:blocks/command_computer_front_blink",
|
||||||
"side": "computercraft:blocks/command_computer_side",
|
"side": "computercraft:blocks/command_computer_side",
|
||||||
"top": "computercraft:blocks/command_computer_top"
|
"top": "computercraft:blocks/command_computer_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/command_computer_front",
|
"front": "computercraft:blocks/command_computer_front",
|
||||||
"side": "computercraft:blocks/command_computer_side",
|
"side": "computercraft:blocks/command_computer_side",
|
||||||
"top": "computercraft:blocks/command_computer_top"
|
"top": "computercraft:blocks/command_computer_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/command_computer_front_on",
|
"front": "computercraft:blocks/command_computer_front_on",
|
||||||
"side": "computercraft:blocks/command_computer_side",
|
"side": "computercraft:blocks/command_computer_side",
|
||||||
"top": "computercraft:blocks/command_computer_top"
|
"top": "computercraft:blocks/command_computer_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/computer_front_blink",
|
"front": "computercraft:blocks/computer_front_blink",
|
||||||
"side": "computercraft:blocks/computer_side",
|
"side": "computercraft:blocks/computer_side",
|
||||||
"top": "computercraft:blocks/computer_top"
|
"top": "computercraft:blocks/computer_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/computer_front",
|
"front": "computercraft:blocks/computer_front",
|
||||||
"side": "computercraft:blocks/computer_side",
|
"side": "computercraft:blocks/computer_side",
|
||||||
"top": "computercraft:blocks/computer_top"
|
"top": "computercraft:blocks/computer_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/computer_front_on",
|
"front": "computercraft:blocks/computer_front_on",
|
||||||
"side": "computercraft:blocks/computer_side",
|
"side": "computercraft:blocks/computer_side",
|
||||||
"top": "computercraft:blocks/computer_top"
|
"top": "computercraft:blocks/computer_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/disk_drive_front",
|
"front": "computercraft:blocks/disk_drive_front",
|
||||||
"side": "computercraft:blocks/disk_drive_side",
|
"side": "computercraft:blocks/disk_drive_side",
|
||||||
"top": "computercraft:blocks/disk_drive_top"
|
"top": "computercraft:blocks/disk_drive_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/disk_drive_front_accepted",
|
"front": "computercraft:blocks/disk_drive_front_accepted",
|
||||||
"side": "computercraft:blocks/disk_drive_side",
|
"side": "computercraft:blocks/disk_drive_side",
|
||||||
"top": "computercraft:blocks/disk_drive_top"
|
"top": "computercraft:blocks/disk_drive_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/disk_drive_front_rejected",
|
"front": "computercraft:blocks/disk_drive_front_rejected",
|
||||||
"side": "computercraft:blocks/disk_drive_side",
|
"side": "computercraft:blocks/disk_drive_side",
|
||||||
"top": "computercraft:blocks/disk_drive_top"
|
"top": "computercraft:blocks/disk_drive_top"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/block",
|
"parent": "block/block",
|
||||||
"textures": {
|
"textures": {
|
||||||
"particle": "#front"
|
"particle": "#front"
|
||||||
},
|
},
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"from": [ 2, 2, 0 ],
|
"from": [ 2, 2, 0 ],
|
||||||
"to": [ 14, 14, 3 ],
|
"to": [ 14, 14, 3 ],
|
||||||
"faces": {
|
"faces": {
|
||||||
"down": { "uv": [ 2, 13, 14, 16 ], "texture": "#front" },
|
"down": { "uv": [ 2, 13, 14, 16 ], "texture": "#front" },
|
||||||
"up": { "uv": [ 2, 0, 14, 3 ], "texture": "#front" },
|
"up": { "uv": [ 2, 0, 14, 3 ], "texture": "#front" },
|
||||||
"north": { "uv": [ 2, 2, 14, 14 ], "texture": "#back" },
|
"north": { "uv": [ 2, 2, 14, 14 ], "texture": "#back" },
|
||||||
"south": { "uv": [ 2, 2, 14, 14 ], "texture": "#front" },
|
"south": { "uv": [ 2, 2, 14, 14 ], "texture": "#front" },
|
||||||
"west": { "uv": [ 0, 2, 3, 14 ], "texture": "#front" },
|
"west": { "uv": [ 0, 2, 3, 14 ], "texture": "#front" },
|
||||||
"east": { "uv": [ 13, 2, 16, 14 ], "texture": "#front" }
|
"east": { "uv": [ 13, 2, 16, 14 ], "texture": "#front" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"display": {
|
"display": {
|
||||||
"gui": {
|
"gui": {
|
||||||
"rotation": [ 30, 45, 0 ],
|
"rotation": [ 30, 45, 0 ],
|
||||||
"translation": [ 3.2, -2, 0],
|
"translation": [ 3.2, -2, 0],
|
||||||
"scale":[ 0.75, 0.75, 0.75 ]
|
"scale":[ 0.75, 0.75, 0.75 ]
|
||||||
},
|
},
|
||||||
"ground": {
|
"ground": {
|
||||||
"rotation": [ 0, 0, 0 ],
|
"rotation": [ 0, 0, 0 ],
|
||||||
"translation": [ 0, 3, 0],
|
"translation": [ 0, 3, 0],
|
||||||
"scale":[ 0.25, 0.25, 0.25 ]
|
"scale":[ 0.25, 0.25, 0.25 ]
|
||||||
},
|
},
|
||||||
"fixed": {
|
"fixed": {
|
||||||
"rotation": [ 0, 0, 0 ],
|
"rotation": [ 0, 0, 0 ],
|
||||||
"translation": [ 0, 0, 0],
|
"translation": [ 0, 0, 0],
|
||||||
"scale":[ 0.5, 0.5, 0.5 ]
|
"scale":[ 0.5, 0.5, 0.5 ]
|
||||||
},
|
},
|
||||||
"thirdperson_righthand": {
|
"thirdperson_righthand": {
|
||||||
"rotation": [ 75, 180, 0 ],
|
"rotation": [ 75, 180, 0 ],
|
||||||
"translation": [ 0, 2.5, 0],
|
"translation": [ 0, 2.5, 0],
|
||||||
"scale": [ 0.375, 0.375, 0.375 ]
|
"scale": [ 0.375, 0.375, 0.375 ]
|
||||||
},
|
},
|
||||||
"firstperson_righthand": {
|
"firstperson_righthand": {
|
||||||
"rotation": [ 0, 45, 0 ],
|
"rotation": [ 0, 45, 0 ],
|
||||||
"translation": [ 0, 0, 0 ],
|
"translation": [ 0, 0, 0 ],
|
||||||
"scale": [ 0.40, 0.40, 0.40 ]
|
"scale": [ 0.40, 0.40, 0.40 ]
|
||||||
},
|
},
|
||||||
"firstperson_lefthand": {
|
"firstperson_lefthand": {
|
||||||
"rotation": [ 0, 45, 0 ],
|
"rotation": [ 0, 45, 0 ],
|
||||||
"translation": [ 0, 0, 0 ],
|
"translation": [ 0, 0, 0 ],
|
||||||
"scale": [ 0.40, 0.40, 0.40 ]
|
"scale": [ 0.40, 0.40, 0.40 ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/monitor16",
|
"front": "computercraft:blocks/monitor16",
|
||||||
"side": "computercraft:blocks/monitor4",
|
"side": "computercraft:blocks/monitor4",
|
||||||
"top": "computercraft:blocks/monitor0",
|
"top": "computercraft:blocks/monitor0",
|
||||||
"back": "computercraft:blocks/monitor4"
|
"back": "computercraft:blocks/monitor4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/cube",
|
"parent": "block/cube",
|
||||||
"textures": {
|
"textures": {
|
||||||
"particle": "#front",
|
"particle": "#front",
|
||||||
"down": "#top",
|
"down": "#top",
|
||||||
"up": "#top",
|
"up": "#top",
|
||||||
"north": "#front",
|
"north": "#front",
|
||||||
"east": "#side",
|
"east": "#side",
|
||||||
"south": "#back",
|
"south": "#back",
|
||||||
"west": "#side"
|
"west": "#side"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/monitor20",
|
"front": "computercraft:blocks/monitor20",
|
||||||
"side": "computercraft:blocks/monitor36",
|
"side": "computercraft:blocks/monitor36",
|
||||||
"top": "computercraft:blocks/monitor0",
|
"top": "computercraft:blocks/monitor0",
|
||||||
"back": "computercraft:blocks/monitor36"
|
"back": "computercraft:blocks/monitor36"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"parent": "block/orientable",
|
"parent": "block/orientable",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/monitor15",
|
"front": "computercraft:blocks/monitor15",
|
||||||
"side": "computercraft:blocks/monitor4",
|
"side": "computercraft:blocks/monitor4",
|
||||||
"top": "computercraft:blocks/monitor0"
|
"top": "computercraft:blocks/monitor0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/monitor19",
|
"front": "computercraft:blocks/monitor19",
|
||||||
"side": "computercraft:blocks/monitor4",
|
"side": "computercraft:blocks/monitor4",
|
||||||
"top": "computercraft:blocks/monitor1",
|
"top": "computercraft:blocks/monitor1",
|
||||||
"back": "computercraft:blocks/monitor33"
|
"back": "computercraft:blocks/monitor33"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/monitor31",
|
"front": "computercraft:blocks/monitor31",
|
||||||
"side": "computercraft:blocks/monitor7",
|
"side": "computercraft:blocks/monitor7",
|
||||||
"top": "computercraft:blocks/monitor1",
|
"top": "computercraft:blocks/monitor1",
|
||||||
"back": "computercraft:blocks/monitor45"
|
"back": "computercraft:blocks/monitor45"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/monitor18",
|
"front": "computercraft:blocks/monitor18",
|
||||||
"side": "computercraft:blocks/monitor4",
|
"side": "computercraft:blocks/monitor4",
|
||||||
"top": "computercraft:blocks/monitor2",
|
"top": "computercraft:blocks/monitor2",
|
||||||
"back": "computercraft:blocks/monitor34"
|
"back": "computercraft:blocks/monitor34"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"parent": "computercraft:block/monitor_base",
|
"parent": "computercraft:block/monitor_base",
|
||||||
"textures": {
|
"textures": {
|
||||||
"front": "computercraft:blocks/monitor30",
|
"front": "computercraft:blocks/monitor30",
|
||||||
"side": "computercraft:blocks/monitor7",
|
"side": "computercraft:blocks/monitor7",
|
||||||
"top": "computercraft:blocks/monitor2",
|
"top": "computercraft:blocks/monitor2",
|
||||||
"back": "computercraft:blocks/monitor46"
|
"back": "computercraft:blocks/monitor46"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user