From 86569533e99b0ec28ad94d5d70dc452dc507c42a Mon Sep 17 00:00:00 2001 From: SquidDev Date: Mon, 17 Dec 2018 17:22:15 +0000 Subject: [PATCH] The big massive reformat - Normalise all line endings to be LF rather than CLRF - Trim all trailing whitespace - Remove any tabs --- .../client/gui/widgets/MousePos.java | 19 - .../advancements/recipes/wired_modem.json | 4 +- .../blockstates/advanced_modem.json | 34 +- .../blockstates/command_computer.json | 36 +- .../computercraft/blockstates/computer.json | 9 +- .../computercraft/blockstates/peripheral.json | 4 +- .../assets/computercraft/lua/bios.lua | 118 +- .../computercraft/lua/rom/apis/colors.lua | 2 +- .../computercraft/lua/rom/apis/disk.lua | 96 +- .../assets/computercraft/lua/rom/apis/gps.lua | 273 ++- .../computercraft/lua/rom/apis/help.lua | 78 +- .../assets/computercraft/lua/rom/apis/io.lua | 2 +- .../computercraft/lua/rom/apis/keys.lua | 92 +- .../computercraft/lua/rom/apis/paintutils.lua | 10 +- .../computercraft/lua/rom/apis/parallel.lua | 74 +- .../computercraft/lua/rom/apis/peripheral.lua | 158 +- .../computercraft/lua/rom/apis/rednet.lua | 4 +- .../computercraft/lua/rom/apis/settings.lua | 14 +- .../computercraft/lua/rom/apis/term.lua | 46 +- .../computercraft/lua/rom/apis/textutils.lua | 34 +- .../lua/rom/apis/turtle/turtle.lua | 4 +- .../computercraft/lua/rom/apis/window.lua | 10 +- .../computercraft/lua/rom/help/alias.txt | 8 +- .../assets/computercraft/lua/rom/help/set.txt | 12 +- .../computercraft/lua/rom/programs/alias.lua | 1 - .../computercraft/lua/rom/programs/edit.lua | 43 +- .../lua/rom/programs/fun/advanced/paint.lua | 43 +- .../rom/programs/fun/advanced/redirection.lua | 22 +- .../lua/rom/programs/fun/adventure.lua | 140 +- .../computercraft/lua/rom/programs/fun/dj.lua | 4 +- .../lua/rom/programs/fun/worm.lua | 28 +- .../computercraft/lua/rom/programs/gps.lua | 13 +- .../computercraft/lua/rom/programs/help.lua | 2 +- .../lua/rom/programs/http/pastebin.lua | 40 +- .../lua/rom/programs/http/wget.lua | 4 +- .../computercraft/lua/rom/programs/id.lua | 5 +- .../computercraft/lua/rom/programs/lua.lua | 6 +- .../lua/rom/programs/monitor.lua | 2 - .../lua/rom/programs/pocket/unequip.lua | 2 +- .../lua/rom/programs/rednet/repeat.lua | 4 +- .../computercraft/lua/rom/programs/shell.lua | 8 +- .../lua/rom/programs/turtle/dance.lua | 2 +- .../lua/rom/programs/turtle/excavate.lua | 42 +- .../lua/rom/programs/turtle/tunnel.lua | 8 +- .../lua/rom/programs/turtle/turn.lua | 1 - .../assets/computercraft/lua/rom/startup.lua | 2 +- .../GopherAtl/battleship/battleship.lua | 1748 ++++++++--------- .../lua/treasure/Lyqyd/nsh/framebuffer.lua | 318 +-- .../lua/treasure/Lyqyd/nsh/get.lua | 50 +- .../lua/treasure/Lyqyd/nsh/nsh.lua | 1440 +++++++------- .../lua/treasure/Lyqyd/nsh/put.lua | 68 +- .../treasure/vilsol/gameoflife/gameoflife.lua | 354 ++-- .../block/advanced_computer_blinking.json | 16 +- .../models/block/advanced_computer_off.json | 16 +- .../models/block/advanced_computer_on.json | 16 +- .../models/block/advanced_modem_off.json | 14 +- .../models/block/advanced_modem_on.json | 14 +- .../models/block/advanced_monitor.json | 18 +- .../models/block/advanced_monitor_d.json | 18 +- .../models/block/advanced_monitor_item.json | 16 +- .../models/block/advanced_monitor_l.json | 18 +- .../models/block/advanced_monitor_ld.json | 18 +- .../models/block/advanced_monitor_lr.json | 18 +- .../models/block/advanced_monitor_lrd.json | 18 +- .../models/block/advanced_monitor_lru.json | 18 +- .../models/block/advanced_monitor_lrud.json | 18 +- .../models/block/advanced_monitor_lu.json | 18 +- .../models/block/advanced_monitor_lud.json | 18 +- .../models/block/advanced_monitor_r.json | 18 +- .../models/block/advanced_monitor_rd.json | 18 +- .../models/block/advanced_monitor_ru.json | 18 +- .../models/block/advanced_monitor_rud.json | 18 +- .../models/block/advanced_monitor_u.json | 18 +- .../models/block/advanced_monitor_ud.json | 18 +- .../models/block/advanced_turtle.json | 12 +- .../block/advanced_turtle_modem_off_left.json | 12 +- .../advanced_turtle_modem_off_right.json | 12 +- .../block/advanced_turtle_modem_on_left.json | 12 +- .../block/advanced_turtle_modem_on_right.json | 12 +- .../computercraft/models/block/cable_arm.json | 38 +- .../models/block/cable_core_any.json | 2 +- .../models/block/cable_item.json | 44 +- .../block/command_computer_blinking.json | 16 +- .../models/block/command_computer_off.json | 16 +- .../models/block/command_computer_on.json | 16 +- .../models/block/computer_blinking.json | 16 +- .../models/block/computer_off.json | 16 +- .../models/block/computer_on.json | 16 +- .../models/block/disk_drive_empty.json | 16 +- .../models/block/disk_drive_full.json | 16 +- .../models/block/disk_drive_invalid.json | 16 +- .../computercraft/models/block/modem.json | 104 +- .../computercraft/models/block/monitor.json | 18 +- .../models/block/monitor_base.json | 24 +- .../computercraft/models/block/monitor_d.json | 18 +- .../models/block/monitor_item.json | 16 +- .../computercraft/models/block/monitor_l.json | 18 +- .../models/block/monitor_ld.json | 18 +- .../models/block/monitor_lr.json | 18 +- .../models/block/monitor_lrd.json | 18 +- .../models/block/monitor_lru.json | 18 +- .../models/block/monitor_lrud.json | 18 +- .../models/block/monitor_lu.json | 18 +- .../models/block/monitor_lud.json | 18 +- .../computercraft/models/block/monitor_r.json | 18 +- .../models/block/monitor_rd.json | 18 +- .../models/block/monitor_ru.json | 18 +- .../models/block/monitor_rud.json | 18 +- .../computercraft/models/block/monitor_u.json | 18 +- .../models/block/monitor_ud.json | 18 +- .../models/block/printer_both_full.json | 16 +- .../models/block/printer_bottom_full.json | 16 +- .../models/block/printer_empty.json | 16 +- .../models/block/printer_top_full.json | 16 +- .../computercraft/models/block/turtle.json | 12 +- .../models/block/turtle_base.json | 62 +- .../block/turtle_crafting_table_left.json | 12 +- .../block/turtle_crafting_table_right.json | 12 +- .../models/block/turtle_elf_overlay.json | 12 +- .../models/block/turtle_modem_off_left.json | 12 +- .../models/block/turtle_modem_off_right.json | 12 +- .../models/block/turtle_modem_on_left.json | 12 +- .../models/block/turtle_modem_on_right.json | 12 +- .../models/block/turtle_overlay.json | 86 +- .../block/turtle_upgrade_base_left.json | 38 +- .../block/turtle_upgrade_base_right.json | 38 +- .../models/block/turtle_white.json | 108 +- .../models/block/wired_modem_off.json | 14 +- .../block/wired_modem_off_peripheral.json | 14 +- .../models/block/wired_modem_on.json | 14 +- .../block/wired_modem_on_peripheral.json | 14 +- .../models/block/wireless_modem_off.json | 14 +- .../models/block/wireless_modem_on.json | 14 +- .../models/item/advanced_computer.json | 6 +- .../models/item/advanced_modem.json | 6 +- .../models/item/advanced_monitor.json | 6 +- .../advanced_pocket_computer_blinking.json | 16 +- .../item/advanced_pocket_computer_on.json | 16 +- .../computercraft/models/item/book.json | 12 +- .../models/item/command_computer.json | 6 +- .../computercraft/models/item/disk.json | 14 +- .../computercraft/models/item/monitor.json | 6 +- .../computercraft/models/item/pages.json | 12 +- .../models/item/pocket_computer_blinking.json | 16 +- .../models/item/pocket_computer_on.json | 16 +- .../computercraft/models/item/printer.json | 6 +- .../computercraft/models/item/printout.json | 12 +- .../models/item/turtle_elf_overlay.json | 6 +- .../models/item/turtle_white.json | 6 +- .../models/item/wired_modem.json | 6 +- .../models/item/wireless_modem.json | 6 +- .../computercraft/recipes/_factories.json | 2 +- .../computercraft/recipes/skull_cloudy.json | 4 +- .../computercraft/recipes/skull_dan200.json | 4 +- 154 files changed, 3684 insertions(+), 3717 deletions(-) delete mode 100644 src/main/java/dan200/computercraft/client/gui/widgets/MousePos.java diff --git a/src/main/java/dan200/computercraft/client/gui/widgets/MousePos.java b/src/main/java/dan200/computercraft/client/gui/widgets/MousePos.java deleted file mode 100644 index 4994e7c3f..000000000 --- a/src/main/java/dan200/computercraft/client/gui/widgets/MousePos.java +++ /dev/null @@ -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; - } -} diff --git a/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json b/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json index 8b7110e69..9a5ebe1f4 100644 --- a/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json +++ b/src/main/resources/assets/computercraft/advancements/recipes/wired_modem.json @@ -1,8 +1,8 @@ { "parent": "minecraft:recipes/root", "rewards": { - "recipes": [ - "computercraft:wired_modem", + "recipes": [ + "computercraft:wired_modem", "computercraft:wired_modem_full_to", "computercraft:wired_modem_full_from" ] diff --git a/src/main/resources/assets/computercraft/blockstates/advanced_modem.json b/src/main/resources/assets/computercraft/blockstates/advanced_modem.json index 7c5ec977c..f69eb2120 100644 --- a/src/main/resources/assets/computercraft/blockstates/advanced_modem.json +++ b/src/main/resources/assets/computercraft/blockstates/advanced_modem.json @@ -1,17 +1,17 @@ -{ - "variants": { - "facing=up,on=false": { "model": "computercraft:advanced_modem_off", "x": 270 }, - "facing=down,on=false": { "model": "computercraft:advanced_modem_off", "x": 90 }, - "facing=north,on=false": { "model": "computercraft:advanced_modem_off" }, - "facing=south,on=false": { "model": "computercraft:advanced_modem_off", "y": 180 }, - "facing=west,on=false": { "model": "computercraft:advanced_modem_off", "y": 270 }, - "facing=east,on=false": { "model": "computercraft:advanced_modem_off", "y": 90 }, - - "facing=up,on=true": { "model": "computercraft:advanced_modem_on", "x": 270 }, - "facing=down,on=true": { "model": "computercraft:advanced_modem_on", "x": 90 }, - "facing=north,on=true": { "model": "computercraft:advanced_modem_on" }, - "facing=south,on=true": { "model": "computercraft:advanced_modem_on", "y": 180 }, - "facing=west,on=true": { "model": "computercraft:advanced_modem_on", "y": 270 }, - "facing=east,on=true": { "model": "computercraft:advanced_modem_on", "y": 90 } - } -} +{ + "variants": { + "facing=up,on=false": { "model": "computercraft:advanced_modem_off", "x": 270 }, + "facing=down,on=false": { "model": "computercraft:advanced_modem_off", "x": 90 }, + "facing=north,on=false": { "model": "computercraft:advanced_modem_off" }, + "facing=south,on=false": { "model": "computercraft:advanced_modem_off", "y": 180 }, + "facing=west,on=false": { "model": "computercraft:advanced_modem_off", "y": 270 }, + "facing=east,on=false": { "model": "computercraft:advanced_modem_off", "y": 90 }, + + "facing=up,on=true": { "model": "computercraft:advanced_modem_on", "x": 270 }, + "facing=down,on=true": { "model": "computercraft:advanced_modem_on", "x": 90 }, + "facing=north,on=true": { "model": "computercraft:advanced_modem_on" }, + "facing=south,on=true": { "model": "computercraft:advanced_modem_on", "y": 180 }, + "facing=west,on=true": { "model": "computercraft:advanced_modem_on", "y": 270 }, + "facing=east,on=true": { "model": "computercraft:advanced_modem_on", "y": 90 } + } +} diff --git a/src/main/resources/assets/computercraft/blockstates/command_computer.json b/src/main/resources/assets/computercraft/blockstates/command_computer.json index a34e3addb..6845f3a60 100644 --- a/src/main/resources/assets/computercraft/blockstates/command_computer.json +++ b/src/main/resources/assets/computercraft/blockstates/command_computer.json @@ -1,18 +1,18 @@ -{ - "variants": { - "facing=north,state=off": { "model": "computercraft:command_computer_off" }, - "facing=south,state=off": { "model": "computercraft:command_computer_off", "y": 180 }, - "facing=west,state=off": { "model": "computercraft:command_computer_off", "y": 270 }, - "facing=east,state=off": { "model": "computercraft:command_computer_off", "y": 90 }, - - "facing=north,state=on": { "model": "computercraft:command_computer_on" }, - "facing=south,state=on": { "model": "computercraft:command_computer_on", "y": 180 }, - "facing=west,state=on": { "model": "computercraft:command_computer_on", "y": 270 }, - "facing=east,state=on": { "model": "computercraft:command_computer_on", "y": 90 }, - - "facing=north,state=blinking": { "model": "computercraft:command_computer_blinking" }, - "facing=south,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 180 }, - "facing=west,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 270 }, - "facing=east,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 90 } - } -} +{ + "variants": { + "facing=north,state=off": { "model": "computercraft:command_computer_off" }, + "facing=south,state=off": { "model": "computercraft:command_computer_off", "y": 180 }, + "facing=west,state=off": { "model": "computercraft:command_computer_off", "y": 270 }, + "facing=east,state=off": { "model": "computercraft:command_computer_off", "y": 90 }, + + "facing=north,state=on": { "model": "computercraft:command_computer_on" }, + "facing=south,state=on": { "model": "computercraft:command_computer_on", "y": 180 }, + "facing=west,state=on": { "model": "computercraft:command_computer_on", "y": 270 }, + "facing=east,state=on": { "model": "computercraft:command_computer_on", "y": 90 }, + + "facing=north,state=blinking": { "model": "computercraft:command_computer_blinking" }, + "facing=south,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 180 }, + "facing=west,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 270 }, + "facing=east,state=blinking": { "model": "computercraft:command_computer_blinking", "y": 90 } + } +} diff --git a/src/main/resources/assets/computercraft/blockstates/computer.json b/src/main/resources/assets/computercraft/blockstates/computer.json index 6358c1123..9bd051689 100644 --- a/src/main/resources/assets/computercraft/blockstates/computer.json +++ b/src/main/resources/assets/computercraft/blockstates/computer.json @@ -1,16 +1,15 @@ { "variants": { - "advanced=false,facing=north,state=off": { "model": "computercraft:computer_off" }, "advanced=false,facing=south,state=off": { "model": "computercraft:computer_off", "y": 180 }, "advanced=false,facing=west,state=off": { "model": "computercraft:computer_off", "y": 270 }, "advanced=false,facing=east,state=off": { "model": "computercraft:computer_off", "y": 90 }, - + "advanced=false,facing=north,state=on": { "model": "computercraft:computer_on" }, "advanced=false,facing=south,state=on": { "model": "computercraft:computer_on", "y": 180 }, "advanced=false,facing=west,state=on": { "model": "computercraft:computer_on", "y": 270 }, "advanced=false,facing=east,state=on": { "model": "computercraft:computer_on", "y": 90 }, - + "advanced=false,facing=north,state=blinking": { "model": "computercraft:computer_blinking" }, "advanced=false,facing=south,state=blinking": { "model": "computercraft:computer_blinking", "y": 180 }, "advanced=false,facing=west,state=blinking": { "model": "computercraft:computer_blinking", "y": 270 }, @@ -20,12 +19,12 @@ "advanced=true,facing=south,state=off": { "model": "computercraft:advanced_computer_off", "y": 180 }, "advanced=true,facing=west,state=off": { "model": "computercraft:advanced_computer_off", "y": 270 }, "advanced=true,facing=east,state=off": { "model": "computercraft:advanced_computer_off", "y": 90 }, - + "advanced=true,facing=north,state=on": { "model": "computercraft:advanced_computer_on" }, "advanced=true,facing=south,state=on": { "model": "computercraft:advanced_computer_on", "y": 180 }, "advanced=true,facing=west,state=on": { "model": "computercraft:advanced_computer_on", "y": 270 }, "advanced=true,facing=east,state=on": { "model": "computercraft:advanced_computer_on", "y": 90 }, - + "advanced=true,facing=north,state=blinking": { "model": "computercraft:advanced_computer_blinking" }, "advanced=true,facing=south,state=blinking": { "model": "computercraft:advanced_computer_blinking", "y": 180 }, "advanced=true,facing=west,state=blinking": { "model": "computercraft:advanced_computer_blinking", "y": 270 }, diff --git a/src/main/resources/assets/computercraft/blockstates/peripheral.json b/src/main/resources/assets/computercraft/blockstates/peripheral.json index ac7a745c5..506ad4f46 100644 --- a/src/main/resources/assets/computercraft/blockstates/peripheral.json +++ b/src/main/resources/assets/computercraft/blockstates/peripheral.json @@ -34,7 +34,7 @@ "facing=south,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 180 }, "facing=west,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 270 }, "facing=east,variant=printer_both_full": { "model": "computercraft:printer_both_full", "y": 90 }, - + "facing=north,variant=wireless_modem_off": { "model": "computercraft:wireless_modem_off" }, "facing=south,variant=wireless_modem_off": { "model": "computercraft:wireless_modem_off", "y": 180 }, "facing=west,variant=wireless_modem_off": { "model": "computercraft:wireless_modem_off", "y": 270 }, @@ -256,7 +256,7 @@ "facing=south,variant=monitor_down_lu": { "model": "computercraft:monitor_lu", "y": 180, "x": 90 }, "facing=west,variant=monitor_down_lu": { "model": "computercraft:monitor_lu", "y": 270, "x": 90 }, "facing=east,variant=monitor_down_lu": { "model": "computercraft:monitor_lu", "y": 90, "x": 90 }, - + "facing=north,variant=advanced_monitor": { "model": "computercraft:advanced_monitor" }, "facing=south,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 180 }, "facing=west,variant=advanced_monitor": { "model": "computercraft:advanced_monitor", "y": 270 }, diff --git a/src/main/resources/assets/computercraft/lua/bios.lua b/src/main/resources/assets/computercraft/lua/bios.lua index ba53c2c62..0b9719999 100644 --- a/src/main/resources/assets/computercraft/lua/bios.lua +++ b/src/main/resources/assets/computercraft/lua/bios.lua @@ -7,18 +7,18 @@ if _VERSION == "Lua 5.1" then local nativesetfenv = setfenv function load( x, name, mode, env ) if type( x ) ~= "string" and type( x ) ~= "function" then - error( "bad argument #1 (expected string or function, got " .. type( x ) .. ")", 2 ) + error( "bad argument #1 (expected string or function, got " .. type( x ) .. ")", 2 ) end if name ~= nil and type( name ) ~= "string" then - error( "bad argument #2 (expected string, got " .. type( name ) .. ")", 2 ) + error( "bad argument #2 (expected string, got " .. type( name ) .. ")", 2 ) end if mode ~= nil and type( mode ) ~= "string" then - error( "bad argument #3 (expected string, got " .. type( mode ) .. ")", 2 ) + error( "bad argument #3 (expected string, got " .. type( mode ) .. ")", 2 ) end if env ~= nil and type( env) ~= "table" then - error( "bad argument #4 (expected table, got " .. type( env ) .. ")", 2 ) + error( "bad argument #4 (expected table, got " .. type( env ) .. ")", 2 ) end - local ok, p1, p2 = pcall( function() + local ok, p1, p2 = pcall( function() if type(x) == "string" then local result, err = nativeloadstring( x, name ) if result then @@ -47,7 +47,7 @@ if _VERSION == "Lua 5.1" then return p1, p2 else error( p1, 2 ) - end + end end table.unpack = unpack table.pack = function( ... ) return { n = select( "#", ... ), ... } end @@ -159,7 +159,7 @@ end -- Install globals function sleep( nTime ) if nTime ~= nil and type( nTime ) ~= "number" then - error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 ) + error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 ) end local timer = os.startTimer( nTime or 0 ) repeat @@ -169,12 +169,12 @@ end function write( sText ) if type( sText ) ~= "string" and type( sText ) ~= "number" then - error( "bad argument #1 (expected string or number, got " .. type( sText ) .. ")", 2 ) + error( "bad argument #1 (expected string or number, got " .. type( sText ) .. ")", 2 ) end - local w,h = term.getSize() + local w,h = term.getSize() local x,y = term.getCursorPos() - + local nLinesPrinted = 0 local function newLine() if y + 1 <= h then @@ -186,7 +186,7 @@ function write( sText ) x, y = term.getCursorPos() nLinesPrinted = nLinesPrinted + 1 end - + -- Print the line with proper word wrapping while string.len(sText) > 0 do local whitespace = string.match( sText, "^[ \t]+" ) @@ -196,19 +196,19 @@ function write( sText ) x,y = term.getCursorPos() sText = string.sub( sText, string.len(whitespace) + 1 ) end - + local newline = string.match( sText, "^\n" ) if newline then -- Print newlines newLine() sText = string.sub( sText, 2 ) end - + local text = string.match( sText, "^[^ \t\n]+" ) if text then sText = string.sub( sText, string.len(text) + 1 ) if string.len(text) > w then - -- Print a multiline word + -- Print a multiline word while string.len( text ) > 0 do if x > w then newLine() @@ -227,7 +227,7 @@ function write( sText ) end end end - + return nLinesPrinted end @@ -259,16 +259,16 @@ end function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault ) if _sReplaceChar ~= nil and type( _sReplaceChar ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sReplaceChar ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sReplaceChar ) .. ")", 2 ) end if _tHistory ~= nil and type( _tHistory ) ~= "table" then - error( "bad argument #2 (expected table, got " .. type( _tHistory ) .. ")", 2 ) + error( "bad argument #2 (expected table, got " .. type( _tHistory ) .. ")", 2 ) end if _fnComplete ~= nil and type( _fnComplete ) ~= "function" then - error( "bad argument #3 (expected function, got " .. type( _fnComplete ) .. ")", 2 ) + error( "bad argument #3 (expected function, got " .. type( _fnComplete ) .. ")", 2 ) end if _sDefault ~= nil and type( _sDefault ) ~= "string" then - error( "bad argument #4 (expected string, got " .. type( _sDefault ) .. ")", 2 ) + error( "bad argument #4 (expected string, got " .. type( _sDefault ) .. ")", 2 ) end term.setCursorBlink( true ) @@ -345,7 +345,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault ) term.setCursorPos( sx + nPos - nScroll, cy ) end - + local function clear() redraw( true ) end @@ -395,7 +395,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault ) redraw() end break - + elseif param == keys.left then -- Left if nPos > 0 then @@ -404,9 +404,9 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault ) recomplete() redraw() end - + elseif param == keys.right then - -- Right + -- Right if nPos < string.len(sLine) then -- Move right clear() @@ -454,11 +454,11 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault ) nHistoryPos = nil elseif nHistoryPos ~= nil then nHistoryPos = nHistoryPos + 1 - end + end end if nHistoryPos then sLine = _tHistory[nHistoryPos] - nPos = string.len( sLine ) + nPos = string.len( sLine ) else sLine = "" nPos = 0 @@ -491,7 +491,7 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault ) -- Delete if nPos < string.len(sLine) then clear() - sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 ) + sLine = string.sub( sLine, 1, nPos ) .. string.sub( sLine, nPos + 2 ) recomplete() redraw() end @@ -523,16 +523,16 @@ function read( _sReplaceChar, _tHistory, _fnComplete, _sDefault ) term.setCursorBlink( false ) term.setCursorPos( w + 1, cy ) print() - + return sLine end loadfile = function( _sFile, _tEnv ) if type( _sFile ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 ) end if _tEnv ~= nil and type( _tEnv ) ~= "table" then - error( "bad argument #2 (expected table, got " .. type( _tEnv ) .. ")", 2 ) + error( "bad argument #2 (expected table, got " .. type( _tEnv ) .. ")", 2 ) end local file = fs.open( _sFile, "r" ) if file then @@ -545,7 +545,7 @@ end dofile = function( _sFile ) if type( _sFile ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sFile ) .. ")", 2 ) end local fnFile, e = loadfile( _sFile, _G ) if fnFile then @@ -558,10 +558,10 @@ end -- Install the rest of the OS api function os.run( _tEnv, _sPath, ... ) if type( _tEnv ) ~= "table" then - error( "bad argument #1 (expected table, got " .. type( _tEnv ) .. ")", 2 ) + error( "bad argument #1 (expected table, got " .. type( _tEnv ) .. ")", 2 ) end if type( _sPath ) ~= "string" then - error( "bad argument #2 (expected string, got " .. type( _sPath ) .. ")", 2 ) + error( "bad argument #2 (expected string, got " .. type( _sPath ) .. ")", 2 ) end local tArgs = table.pack( ... ) local tEnv = _tEnv @@ -588,7 +588,7 @@ end local tAPIsLoading = {} function os.loadAPI( _sPath ) if type( _sPath ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 ) end local sName = fs.getName( _sPath ) if sName:sub(-4) == ".lua" then @@ -613,7 +613,7 @@ function os.loadAPI( _sPath ) tAPIsLoading[sName] = nil return error( "Failed to load API " .. sName .. " due to " .. err, 1 ) end - + local tAPI = {} for k,v in pairs( tEnv ) do if k ~= "_ENV" then @@ -621,14 +621,14 @@ function os.loadAPI( _sPath ) end end - _G[sName] = tAPI + _G[sName] = tAPI tAPIsLoading[sName] = nil return true end function os.unloadAPI( _sName ) if type( _sName ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sName ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sName ) .. ")", 2 ) end if _sName ~= "_G" and type(_G[_sName]) == "table" then _G[_sName] = nil @@ -667,7 +667,7 @@ if http then local function checkKey( options, key, ty, opt ) local value = options[key] local valueTy = type(value) - + if (value ~= nil or not opt) and valueTy ~= ty then error(("bad field '%s' (expected %s, got %s"):format(key, ty, valueTy), 4) end @@ -675,8 +675,8 @@ if http then local function checkOptions( options, body ) checkKey( options, "url", "string") - if body == false - then checkKey( options, "body", "nil" ) + if body == false + then checkKey( options, "body", "nil" ) else checkKey( options, "body", "string", not body ) end checkKey( options, "headers", "table", true ) checkKey( options, "method", "string", true ) @@ -701,7 +701,7 @@ if http then end return nil, err end - + http.get = function( _url, _headers, _binary) if type( _url ) == "table" then checkOptions( _url, false ) @@ -709,13 +709,13 @@ if http then end if type( _url ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 ) end if _headers ~= nil and type( _headers ) ~= "table" then - error( "bad argument #2 (expected table, got " .. type( _headers ) .. ")", 2 ) + error( "bad argument #2 (expected table, got " .. type( _headers ) .. ")", 2 ) end if _binary ~= nil and type( _binary ) ~= "boolean" then - error( "bad argument #3 (expected boolean, got " .. type( _binary ) .. ")", 2 ) + error( "bad argument #3 (expected boolean, got " .. type( _binary ) .. ")", 2 ) end return wrapRequest( _url, _url, nil, _headers, _binary ) end @@ -727,16 +727,16 @@ if http then end if type( _url ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 ) end if type( _post ) ~= "string" then - error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 ) + error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 ) end if _headers ~= nil and type( _headers ) ~= "table" then - error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 ) + error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 ) end if _binary ~= nil and type( _binary ) ~= "boolean" then - error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 ) + error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 ) end return wrapRequest( _url, _url, _post, _headers, _binary ) end @@ -748,16 +748,16 @@ if http then url = _url.url else if type( _url ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _url ) .. ")", 2 ) end if _post ~= nil and type( _post ) ~= "string" then - error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 ) + error( "bad argument #2 (expected string, got " .. type( _post ) .. ")", 2 ) end if _headers ~= nil and type( _headers ) ~= "table" then - error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 ) + error( "bad argument #3 (expected table, got " .. type( _headers ) .. ")", 2 ) end if _binary ~= nil and type( _binary ) ~= "boolean" then - error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 ) + error( "bad argument #4 (expected boolean, got " .. type( _binary ) .. ")", 2 ) end url = _url.url @@ -769,13 +769,13 @@ if http then end return ok, err end - + local nativeCheckURL = http.checkURL http.checkURLAsync = nativeCheckURL http.checkURL = function( _url ) local ok, err = nativeCheckURL( _url ) if not ok then return ok, err end - + while true do local event, url, ok, err = os.pullEvent( "http_check" ) if url == _url then return ok, err end @@ -809,16 +809,16 @@ end local tEmpty = {} function fs.complete( sPath, sLocation, bIncludeFiles, bIncludeDirs ) if type( sPath ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 ) end if type( sLocation ) ~= "string" then - error( "bad argument #2 (expected string, got " .. type( sLocation ) .. ")", 2 ) + error( "bad argument #2 (expected string, got " .. type( sLocation ) .. ")", 2 ) end if bIncludeFiles ~= nil and type( bIncludeFiles ) ~= "boolean" then - error( "bad argument #3 (expected boolean, got " .. type( bIncludeFiles ) .. ")", 2 ) + error( "bad argument #3 (expected boolean, got " .. type( bIncludeFiles ) .. ")", 2 ) end if bIncludeDirs ~= nil and type( bIncludeDirs ) ~= "boolean" then - error( "bad argument #4 (expected boolean, got " .. type( bIncludeDirs ) .. ")", 2 ) + error( "bad argument #4 (expected boolean, got " .. type( bIncludeDirs ) .. ")", 2 ) end bIncludeFiles = (bIncludeFiles ~= false) bIncludeDirs = (bIncludeDirs ~= false) @@ -960,7 +960,7 @@ end settings.set( "shell.allow_startup", true ) settings.set( "shell.allow_disk_startup", (commands == nil) ) settings.set( "shell.autocomplete", true ) -settings.set( "edit.autocomplete", true ) +settings.set( "edit.autocomplete", true ) settings.set( "edit.default_extension", "lua" ) settings.set( "paint.default_extension", "nfp" ) settings.set( "lua.autocomplete", true ) @@ -1000,7 +1000,7 @@ end -- Run the shell local ok, err = pcall( function() - parallel.waitForAny( + parallel.waitForAny( function() local sShell if term.isColour() and settings.get( "bios.use_multishell" ) then diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/colors.lua b/src/main/resources/assets/computercraft/lua/rom/apis/colors.lua index 30da8c8ea..4a2f31153 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/colors.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/colors.lua @@ -57,7 +57,7 @@ function rgb8( r, g, b ) elseif type(r) == "number" and g == nil and b == nil then return bit32.band( bit32.rshift( r, 16 ), 0xFF ) / 255, bit32.band( bit32.rshift( r, 8 ), 0xFF ) / 255, bit32.band( r, 0xFF ) / 255 elseif type(r) == "number" and type(g) == "number" and type(b) == "number" then - return + return bit32.lshift( bit32.band(r * 255, 0xFF), 16 ) + bit32.lshift( bit32.band(g * 255, 0xFF), 8 ) + bit32.band(b * 255, 0xFF) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/disk.lua b/src/main/resources/assets/computercraft/lua/rom/apis/disk.lua index b5ae615fd..637a48b07 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/disk.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/disk.lua @@ -1,87 +1,87 @@ local function isDrive( name ) if type( name ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( name ) .. ")", 3 ) + error( "bad argument #1 (expected string, got " .. type( name ) .. ")", 3 ) end - return peripheral.getType( name ) == "drive" + return peripheral.getType( name ) == "drive" end function isPresent( name ) - if isDrive( name ) then - return peripheral.call( name, "isDiskPresent" ) - end - return false + if isDrive( name ) then + return peripheral.call( name, "isDiskPresent" ) + end + return false end function getLabel( name ) - if isDrive( name ) then - return peripheral.call( name, "getDiskLabel" ) - end - return nil + if isDrive( name ) then + return peripheral.call( name, "getDiskLabel" ) + end + return nil end function setLabel( name, label ) - if isDrive( name ) then - peripheral.call( name, "setDiskLabel", label ) - end + if isDrive( name ) then + peripheral.call( name, "setDiskLabel", label ) + end end function hasData( name ) - if isDrive( name ) then - return peripheral.call( name, "hasData" ) - end - return false + if isDrive( name ) then + return peripheral.call( name, "hasData" ) + end + return false end function getMountPath( name ) - if isDrive( name ) then - return peripheral.call( name, "getMountPath" ) - end - return nil + if isDrive( name ) then + return peripheral.call( name, "getMountPath" ) + end + return nil end function hasAudio( name ) - if isDrive( name ) then - return peripheral.call( name, "hasAudio" ) - end - return false + if isDrive( name ) then + return peripheral.call( name, "hasAudio" ) + end + return false end function getAudioTitle( name ) - if isDrive( name ) then - return peripheral.call( name, "getAudioTitle" ) - end - return nil + if isDrive( name ) then + return peripheral.call( name, "getAudioTitle" ) + end + return nil end function playAudio( name ) - if isDrive( name ) then - peripheral.call( name, "playAudio" ) - end + if isDrive( name ) then + peripheral.call( name, "playAudio" ) + end end function stopAudio( name ) - if not name then - for n,sName in ipairs( peripheral.getNames() ) do - stopAudio( sName ) - end - else - if isDrive( name ) then - peripheral.call( name, "stopAudio" ) - end - end + if not name then + for n,sName in ipairs( peripheral.getNames() ) do + stopAudio( sName ) + end + else + if isDrive( name ) then + peripheral.call( name, "stopAudio" ) + end + end end function eject( name ) - if isDrive( name ) then - peripheral.call( name, "ejectDisk" ) - end + if isDrive( name ) then + peripheral.call( name, "ejectDisk" ) + end end function getID( name ) - if isDrive( name ) then - return peripheral.call( name, "getDiskID" ) - end - return nil + if isDrive( name ) then + return peripheral.call( name, "getDiskID" ) + end + return nil end diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua b/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua index 6a83bf972..9b4eb1765 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/gps.lua @@ -1,122 +1,121 @@ - CHANNEL_GPS = 65534 local function trilaterate( A, B, C ) - local a2b = B.vPosition - A.vPosition - local a2c = C.vPosition - A.vPosition - - if math.abs( a2b:normalize():dot( a2c:normalize() ) ) > 0.999 then - return nil - end - - local d = a2b:length() - local ex = a2b:normalize( ) - local i = ex:dot( a2c ) - local ey = (a2c - (ex * i)):normalize() - local j = ey:dot( a2c ) - local ez = ex:cross( ey ) + local a2b = B.vPosition - A.vPosition + local a2c = C.vPosition - A.vPosition - local r1 = A.nDistance - local r2 = B.nDistance - local r3 = C.nDistance - - local x = (r1*r1 - r2*r2 + d*d) / (2*d) - local y = (r1*r1 - r3*r3 - x*x + (x-i)*(x-i) + j*j) / (2*j) - - local result = A.vPosition + (ex * x) + (ey * y) + if math.abs( a2b:normalize():dot( a2c:normalize() ) ) > 0.999 then + return nil + end + + local d = a2b:length() + local ex = a2b:normalize( ) + local i = ex:dot( a2c ) + local ey = (a2c - (ex * i)):normalize() + local j = ey:dot( a2c ) + local ez = ex:cross( ey ) + + local r1 = A.nDistance + local r2 = B.nDistance + local r3 = C.nDistance + + local x = (r1*r1 - r2*r2 + d*d) / (2*d) + local y = (r1*r1 - r3*r3 - x*x + (x-i)*(x-i) + j*j) / (2*j) + + local result = A.vPosition + (ex * x) + (ey * y) + + local zSquared = r1*r1 - x*x - y*y + if zSquared > 0 then + local z = math.sqrt( zSquared ) + local result1 = result + (ez * z) + local result2 = result - (ez * z) + + local rounded1, rounded2 = result1:round( 0.01 ), result2:round( 0.01 ) + if rounded1.x ~= rounded2.x or rounded1.y ~= rounded2.y or rounded1.z ~= rounded2.z then + return rounded1, rounded2 + else + return rounded1 + end + end + return result:round( 0.01 ) - local zSquared = r1*r1 - x*x - y*y - if zSquared > 0 then - local z = math.sqrt( zSquared ) - local result1 = result + (ez * z) - local result2 = result - (ez * z) - - local rounded1, rounded2 = result1:round( 0.01 ), result2:round( 0.01 ) - if rounded1.x ~= rounded2.x or rounded1.y ~= rounded2.y or rounded1.z ~= rounded2.z then - return rounded1, rounded2 - else - return rounded1 - end - end - return result:round( 0.01 ) - end local function narrow( p1, p2, fix ) - local dist1 = math.abs( (p1 - fix.vPosition):length() - fix.nDistance ) - local dist2 = math.abs( (p2 - fix.vPosition):length() - fix.nDistance ) - - if math.abs(dist1 - dist2) < 0.01 then - return p1, p2 - elseif dist1 < dist2 then - return p1:round( 0.01 ) - else - return p2:round( 0.01 ) - end + local dist1 = math.abs( (p1 - fix.vPosition):length() - fix.nDistance ) + local dist2 = math.abs( (p2 - fix.vPosition):length() - fix.nDistance ) + + if math.abs(dist1 - dist2) < 0.01 then + return p1, p2 + elseif dist1 < dist2 then + return p1:round( 0.01 ) + else + return p2:round( 0.01 ) + end end function locate( _nTimeout, _bDebug ) if _nTimeout ~= nil and type( _nTimeout ) ~= "number" then - error( "bad argument #1 (expected number, got " .. type( _nTimeout ) .. ")", 2 ) + error( "bad argument #1 (expected number, got " .. type( _nTimeout ) .. ")", 2 ) end if _bDebug ~= nil and type( _bDebug ) ~= "boolean" then - error( "bad argument #2 (expected boolean, got " .. type( _bDebug) .. ")", 2 ) + error( "bad argument #2 (expected boolean, got " .. type( _bDebug) .. ")", 2 ) end -- Let command computers use their magic fourth-wall-breaking special abilities if commands then return commands.getBlockPosition() end - -- Find a modem - local sModemSide = nil - for n,sSide in ipairs( rs.getSides() ) do - if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then - sModemSide = sSide - break - end - end + -- Find a modem + local sModemSide = nil + for n,sSide in ipairs( rs.getSides() ) do + if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then + sModemSide = sSide + break + end + end - if sModemSide == nil then - if _bDebug then - print( "No wireless modem attached" ) - end - return nil - end - - if _bDebug then - print( "Finding position..." ) - end - - -- Open a channel - local modem = peripheral.wrap( sModemSide ) - local bCloseChannel = false - if not modem.isOpen( os.getComputerID() ) then - modem.open( os.getComputerID() ) - bCloseChannel = true - end - - -- Send a ping to listening GPS hosts - modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" ) - - -- Wait for the responses - local tFixes = {} - local pos1, pos2 = nil, nil - local timeout = os.startTimer( _nTimeout or 2 ) - while true do - local e, p1, p2, p3, p4, p5 = os.pullEvent() - if e == "modem_message" then - -- We received a reply from a modem - local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5 - if sSide == sModemSide and sChannel == os.getComputerID() and sReplyChannel == CHANNEL_GPS and nDistance then - -- Received the correct message from the correct modem: use it to determine position - if type(tMessage) == "table" and #tMessage == 3 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then - local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance } - if _bDebug then - print( tFix.nDistance.." metres from "..tostring( tFix.vPosition ) ) - end - if tFix.nDistance == 0 then - pos1, pos2 = tFix.vPosition, nil - else + if sModemSide == nil then + if _bDebug then + print( "No wireless modem attached" ) + end + return nil + end + + if _bDebug then + print( "Finding position..." ) + end + + -- Open a channel + local modem = peripheral.wrap( sModemSide ) + local bCloseChannel = false + if not modem.isOpen( os.getComputerID() ) then + modem.open( os.getComputerID() ) + bCloseChannel = true + end + + -- Send a ping to listening GPS hosts + modem.transmit( CHANNEL_GPS, os.getComputerID(), "PING" ) + + -- Wait for the responses + local tFixes = {} + local pos1, pos2 = nil, nil + local timeout = os.startTimer( _nTimeout or 2 ) + while true do + local e, p1, p2, p3, p4, p5 = os.pullEvent() + if e == "modem_message" then + -- We received a reply from a modem + local sSide, sChannel, sReplyChannel, tMessage, nDistance = p1, p2, p3, p4, p5 + if sSide == sModemSide and sChannel == os.getComputerID() and sReplyChannel == CHANNEL_GPS and nDistance then + -- Received the correct message from the correct modem: use it to determine position + if type(tMessage) == "table" and #tMessage == 3 and tonumber(tMessage[1]) and tonumber(tMessage[2]) and tonumber(tMessage[3]) then + local tFix = { vPosition = vector.new( tMessage[1], tMessage[2], tMessage[3] ), nDistance = nDistance } + if _bDebug then + print( tFix.nDistance.." metres from "..tostring( tFix.vPosition ) ) + end + if tFix.nDistance == 0 then + pos1, pos2 = tFix.vPosition, nil + else table.insert( tFixes, tFix ) if #tFixes >= 3 then if not pos1 then @@ -126,43 +125,43 @@ function locate( _nTimeout, _bDebug ) end end end - if pos1 and not pos2 then - break - end - end - end - - elseif e == "timer" then - -- We received a timeout - local timer = p1 - if timer == timeout then - break - end - - end - end - - -- Close the channel, if we opened one - if bCloseChannel then - modem.close( os.getComputerID() ) - end - - -- Return the response - if pos1 and pos2 then - if _bDebug then - print( "Ambiguous position" ) - print( "Could be "..pos1.x..","..pos1.y..","..pos1.z.." or "..pos2.x..","..pos2.y..","..pos2.z ) - end - return nil - elseif pos1 then - if _bDebug then - print( "Position is "..pos1.x..","..pos1.y..","..pos1.z ) - end - return pos1.x, pos1.y, pos1.z - else - if _bDebug then - print( "Could not determine position" ) - end - return nil - end + if pos1 and not pos2 then + break + end + end + end + + elseif e == "timer" then + -- We received a timeout + local timer = p1 + if timer == timeout then + break + end + + end + end + + -- Close the channel, if we opened one + if bCloseChannel then + modem.close( os.getComputerID() ) + end + + -- Return the response + if pos1 and pos2 then + if _bDebug then + print( "Ambiguous position" ) + print( "Could be "..pos1.x..","..pos1.y..","..pos1.z.." or "..pos2.x..","..pos2.y..","..pos2.z ) + end + return nil + elseif pos1 then + if _bDebug then + print( "Position is "..pos1.x..","..pos1.y..","..pos1.z ) + end + return pos1.x, pos1.y, pos1.z + else + if _bDebug then + print( "Could not determine position" ) + end + return nil + end end diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/help.lua b/src/main/resources/assets/computercraft/lua/rom/apis/help.lua index 5ce84081a..9776b0c03 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/help.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/help.lua @@ -2,69 +2,69 @@ local sPath = "/rom/help" function path() - return sPath + return sPath end function setPath( _sPath ) if type( _sPath ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 ) end - sPath = _sPath + sPath = _sPath end function lookup( _sTopic ) if type( _sTopic ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sTopic ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sTopic ) .. ")", 2 ) end - -- Look on the path variable + -- Look on the path variable for sPath in string.gmatch(sPath, "[^:]+") do - sPath = fs.combine( sPath, _sTopic ) - if fs.exists( sPath ) and not fs.isDir( sPath ) then - return sPath + sPath = fs.combine( sPath, _sTopic ) + if fs.exists( sPath ) and not fs.isDir( sPath ) then + return sPath elseif fs.exists( sPath..".txt" ) and not fs.isDir( sPath..".txt" ) then - return sPath..".txt" - end + return sPath..".txt" + end end - - -- Not found - return nil + + -- Not found + return nil end function topics() -- Add index - local tItems = { - [ "index" ] = true - } - - -- Add topics from the path + local tItems = { + [ "index" ] = true + } + + -- Add topics from the path for sPath in string.gmatch(sPath, "[^:]+") do - if fs.isDir( sPath ) then - local tList = fs.list( sPath ) - for n,sFile in pairs( tList ) do - if string.sub( sFile, 1, 1 ) ~= "." then - if not fs.isDir( fs.combine( sPath, sFile ) ) then + if fs.isDir( sPath ) then + local tList = fs.list( sPath ) + for n,sFile in pairs( tList ) do + if string.sub( sFile, 1, 1 ) ~= "." then + if not fs.isDir( fs.combine( sPath, sFile ) ) then if #sFile > 4 and sFile:sub(-4) == ".txt" then sFile = sFile:sub(1,-5) end - tItems[ sFile ] = true - end - end - end - end - end + tItems[ sFile ] = true + end + end + end + end + end - -- Sort and return - local tItemList = {} - for sItem, b in pairs( tItems ) do - table.insert( tItemList, sItem ) - end - table.sort( tItemList ) - return tItemList + -- Sort and return + local tItemList = {} + for sItem, b in pairs( tItems ) do + table.insert( tItemList, sItem ) + end + table.sort( tItemList ) + return tItemList end function completeTopic( sText ) if type( sText ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( sText ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( sText ) .. ")", 2 ) end local tTopics = topics() local tResults = {} @@ -74,7 +74,5 @@ function completeTopic( sText ) table.insert( tResults, string.sub( sTopic, #sText + 1 ) ) end end - return tResults + return tResults end - - diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/io.lua b/src/main/resources/assets/computercraft/lua/rom/apis/io.lua index 73e50da08..8bf12e5b5 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/io.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/io.lua @@ -191,7 +191,7 @@ function lines(_sFileName) local ok, err = open(_sFileName, "rb") if not ok then error(err, 2) end - -- We set this magic flag to mark this file as being opened by io.lines and so should be + -- We set this magic flag to mark this file as being opened by io.lines and so should be -- closed automatically ok._autoclose = true return ok:lines() diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/keys.lua b/src/main/resources/assets/computercraft/lua/rom/apis/keys.lua index c47ca8deb..87d428840 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/keys.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/keys.lua @@ -3,54 +3,54 @@ -- See http://www.minecraftwiki.net/wiki/Key_codes for more info local tKeys = { - nil, "one", "two", "three", "four", -- 1 - "five", "six", "seven", "eight", "nine", -- 6 - "zero", "minus", "equals", "backspace","tab", -- 11 - "q", "w", "e", "r", "t", -- 16 - "y", "u", "i", "o", "p", -- 21 - "leftBracket","rightBracket","enter","leftCtrl","a", -- 26 - "s", "d", "f", "g", "h", -- 31 - "j", "k", "l", "semiColon","apostrophe", -- 36 - "grave", "leftShift","backslash","z", "x", -- 41 - "c", "v", "b", "n", "m", -- 46 - "comma", "period", "slash", "rightShift","multiply", -- 51 - "leftAlt", "space", "capsLock", "f1", "f2", -- 56 - "f3", "f4", "f5", "f6", "f7", -- 61 - "f8", "f9", "f10", "numLock", "scrollLock", -- 66 - "numPad7", "numPad8", "numPad9", "numPadSubtract","numPad4", -- 71 - "numPad5", "numPad6", "numPadAdd","numPad1", "numPad2", -- 76 - "numPad3", "numPad0", "numPadDecimal",nil, nil, -- 81 - nil, "f11", "f12", nil, nil, -- 86 - nil, nil, nil, nil, nil, -- 91 - nil, nil, nil, nil, "f13", -- 96 - "f14", "f15", nil, nil, nil, -- 101 - nil, nil, nil, nil, nil, -- 106 - nil, "kana", nil, nil, nil, -- 111 - nil, nil, nil, nil, nil, -- 116 - "convert", nil, "noconvert",nil, "yen", -- 121 - nil, nil, nil, nil, nil, -- 126 - nil, nil, nil, nil, nil, -- 131 - nil, nil, nil, nil, nil, -- 136 - "numPadEquals",nil, nil, "circumflex","at", -- 141 - "colon", "underscore","kanji", "stop", "ax", -- 146 - nil, nil, nil, nil, nil, -- 151 - "numPadEnter","rightCtrl",nil, nil, nil, -- 156 - nil, nil, nil, nil, nil, -- 161 - nil, nil, nil, nil, nil, -- 166 - nil, nil, nil, nil, nil, -- 171 - nil, nil, nil, "numPadComma",nil, -- 176 - "numPadDivide",nil, nil, "rightAlt", nil, -- 181 - nil, nil, nil, nil, nil, -- 186 - nil, nil, nil, nil, nil, -- 191 - nil, "pause", nil, "home", "up", -- 196 - "pageUp", nil, "left", nil, "right", -- 201 - nil, "end", "down", "pageDown", "insert", -- 206 - "delete" -- 211 + nil, "one", "two", "three", "four", -- 1 + "five", "six", "seven", "eight", "nine", -- 6 + "zero", "minus", "equals", "backspace","tab", -- 11 + "q", "w", "e", "r", "t", -- 16 + "y", "u", "i", "o", "p", -- 21 + "leftBracket","rightBracket","enter","leftCtrl","a", -- 26 + "s", "d", "f", "g", "h", -- 31 + "j", "k", "l", "semiColon","apostrophe", -- 36 + "grave", "leftShift","backslash","z", "x", -- 41 + "c", "v", "b", "n", "m", -- 46 + "comma", "period", "slash", "rightShift","multiply", -- 51 + "leftAlt", "space", "capsLock", "f1", "f2", -- 56 + "f3", "f4", "f5", "f6", "f7", -- 61 + "f8", "f9", "f10", "numLock", "scrollLock", -- 66 + "numPad7", "numPad8", "numPad9", "numPadSubtract","numPad4", -- 71 + "numPad5", "numPad6", "numPadAdd","numPad1", "numPad2", -- 76 + "numPad3", "numPad0", "numPadDecimal",nil, nil, -- 81 + nil, "f11", "f12", nil, nil, -- 86 + nil, nil, nil, nil, nil, -- 91 + nil, nil, nil, nil, "f13", -- 96 + "f14", "f15", nil, nil, nil, -- 101 + nil, nil, nil, nil, nil, -- 106 + nil, "kana", nil, nil, nil, -- 111 + nil, nil, nil, nil, nil, -- 116 + "convert", nil, "noconvert",nil, "yen", -- 121 + nil, nil, nil, nil, nil, -- 126 + nil, nil, nil, nil, nil, -- 131 + nil, nil, nil, nil, nil, -- 136 + "numPadEquals",nil, nil, "circumflex","at", -- 141 + "colon", "underscore","kanji", "stop", "ax", -- 146 + nil, nil, nil, nil, nil, -- 151 + "numPadEnter","rightCtrl",nil, nil, nil, -- 156 + nil, nil, nil, nil, nil, -- 161 + nil, nil, nil, nil, nil, -- 166 + nil, nil, nil, nil, nil, -- 171 + nil, nil, nil, "numPadComma",nil, -- 176 + "numPadDivide",nil, nil, "rightAlt", nil, -- 181 + nil, nil, nil, nil, nil, -- 186 + nil, nil, nil, nil, nil, -- 191 + nil, "pause", nil, "home", "up", -- 196 + "pageUp", nil, "left", nil, "right", -- 201 + nil, "end", "down", "pageDown", "insert", -- 206 + "delete" -- 211 } local keys = _ENV for nKey, sKey in pairs( tKeys ) do - keys[sKey] = nKey + keys[sKey] = nKey end keys["return"] = keys.enter --backwards compatibility to earlier, typo prone, versions @@ -59,7 +59,7 @@ keys.cimcumflex = keys.circumflex function getName( _nKey ) if type( _nKey ) ~= "number" then - error( "bad argument #1 (expected number, got " .. type( _nKey ) .. ")", 2 ) + error( "bad argument #1 (expected number, got " .. type( _nKey ) .. ")", 2 ) end - return tKeys[ _nKey ] + return tKeys[ _nKey ] end diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/paintutils.lua b/src/main/resources/assets/computercraft/lua/rom/apis/paintutils.lua index c951a88c0..82db7003d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/paintutils.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/paintutils.lua @@ -58,7 +58,7 @@ function drawLine( startX, startY, endX, endY, nColour ) if type( endX ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( endX ) .. ")", 2 ) end if type( endY ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( endY ) .. ")", 2 ) end if nColour ~= nil and type( nColour ) ~= "number" then error( "bad argument #5 (expected number, got " .. type( nColour ) .. ")", 2 ) end - + startX = math.floor(startX) startY = math.floor(startY) endX = math.floor(endX) @@ -71,7 +71,7 @@ function drawLine( startX, startY, endX, endY, nColour ) drawPixelInternal( startX, startY ) return end - + local minX = math.min( startX, endX ) local maxX, minY, maxY if minX == startX then @@ -85,10 +85,10 @@ function drawLine( startX, startY, endX, endY, nColour ) end -- TODO: clip to screen rectangle? - + local xDiff = maxX - minX local yDiff = maxY - minY - + if xDiff > math.abs(yDiff) then local y = minY local dy = yDiff / xDiff @@ -134,7 +134,7 @@ function drawBox( startX, startY, endX, endY, nColour ) end local minX = math.min( startX, endX ) - local maxX, minY, maxY + local maxX, minY, maxY if minX == startX then minY = startY maxX = endX diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/parallel.lua b/src/main/resources/assets/computercraft/lua/rom/apis/parallel.lua index 3c3bbb489..7aad3519d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/parallel.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/parallel.lua @@ -4,54 +4,54 @@ local function create( ... ) local tCos = {} for i = 1, tFns.n, 1 do local fn = tFns[i] - if type( fn ) ~= "function" then - error( "bad argument #" .. i .. " (expected function, got " .. type( fn ) .. ")", 3 ) + if type( fn ) ~= "function" then + error( "bad argument #" .. i .. " (expected function, got " .. type( fn ) .. ")", 3 ) end - + tCos[i] = coroutine.create(fn) end - + return tCos end local function runUntilLimit( _routines, _limit ) local count = #_routines local living = count - + local tFilters = {} local eventData = { n = 0 } while true do - for n=1,count do - local r = _routines[n] - if r then - if tFilters[r] == nil or tFilters[r] == eventData[1] or eventData[1] == "terminate" then - local ok, param = coroutine.resume( r, table.unpack( eventData, 1, eventData.n ) ) - if not ok then - error( param, 0 ) - else - tFilters[r] = param - end - if coroutine.status( r ) == "dead" then - _routines[n] = nil - living = living - 1 - if living <= _limit then - return n - end - end - end - end - end - for n=1,count do - local r = _routines[n] - if r and coroutine.status( r ) == "dead" then - _routines[n] = nil - living = living - 1 - if living <= _limit then - return n - end - end - end - eventData = table.pack( os.pullEventRaw() ) + for n=1,count do + local r = _routines[n] + if r then + if tFilters[r] == nil or tFilters[r] == eventData[1] or eventData[1] == "terminate" then + local ok, param = coroutine.resume( r, table.unpack( eventData, 1, eventData.n ) ) + if not ok then + error( param, 0 ) + else + tFilters[r] = param + end + if coroutine.status( r ) == "dead" then + _routines[n] = nil + living = living - 1 + if living <= _limit then + return n + end + end + end + end + end + for n=1,count do + local r = _routines[n] + if r and coroutine.status( r ) == "dead" then + _routines[n] = nil + living = living - 1 + if living <= _limit then + return n + end + end + end + eventData = table.pack( os.pullEventRaw() ) end end @@ -62,5 +62,5 @@ end function waitForAll( ... ) local routines = create( ... ) - runUntilLimit( routines, 0 ) + runUntilLimit( routines, 0 ) end diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/peripheral.lua b/src/main/resources/assets/computercraft/lua/rom/apis/peripheral.lua index a9f675a23..661f5e0f3 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/peripheral.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/peripheral.lua @@ -1,70 +1,70 @@ local native = peripheral function getNames() - local tResults = {} - for n,sSide in ipairs( rs.getSides() ) do - if native.isPresent( sSide ) then - table.insert( tResults, sSide ) - if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then - local tRemote = native.call( sSide, "getNamesRemote" ) - for n,sName in ipairs( tRemote ) do - table.insert( tResults, sName ) - end - end - end - end - return tResults + local tResults = {} + for n,sSide in ipairs( rs.getSides() ) do + if native.isPresent( sSide ) then + table.insert( tResults, sSide ) + if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then + local tRemote = native.call( sSide, "getNamesRemote" ) + for n,sName in ipairs( tRemote ) do + table.insert( tResults, sName ) + end + end + end + end + return tResults end function isPresent( _sSide ) if type( _sSide ) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 ) end - if native.isPresent( _sSide ) then - return true - end - for n,sSide in ipairs( rs.getSides() ) do - if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then - if native.call( sSide, "isPresentRemote", _sSide ) then - return true - end - end - end - return false + if native.isPresent( _sSide ) then + return true + end + for n,sSide in ipairs( rs.getSides() ) do + if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then + if native.call( sSide, "isPresentRemote", _sSide ) then + return true + end + end + end + return false end function getType( _sSide ) if type( _sSide ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 ) end - if native.isPresent( _sSide ) then - return native.getType( _sSide ) - end - for n,sSide in ipairs( rs.getSides() ) do - if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then - if native.call( sSide, "isPresentRemote", _sSide ) then - return native.call( sSide, "getTypeRemote", _sSide ) - end - end - end - return nil + if native.isPresent( _sSide ) then + return native.getType( _sSide ) + end + for n,sSide in ipairs( rs.getSides() ) do + if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then + if native.call( sSide, "isPresentRemote", _sSide ) then + return native.call( sSide, "getTypeRemote", _sSide ) + end + end + end + return nil end function getMethods( _sSide ) if type( _sSide ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 ) end - if native.isPresent( _sSide ) then - return native.getMethods( _sSide ) - end - for n,sSide in ipairs( rs.getSides() ) do - if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then - if native.call( sSide, "isPresentRemote", _sSide ) then - return native.call( sSide, "getMethodsRemote", _sSide ) - end - end - end - return nil + if native.isPresent( _sSide ) then + return native.getMethods( _sSide ) + end + for n,sSide in ipairs( rs.getSides() ) do + if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then + if native.call( sSide, "isPresentRemote", _sSide ) then + return native.call( sSide, "getMethodsRemote", _sSide ) + end + end + end + return nil end function call( _sSide, _sMethod, ... ) @@ -74,34 +74,34 @@ function call( _sSide, _sMethod, ... ) if type( _sSide ) ~= "string" then error( "bad argument #2 (expected string, got " .. type( _sMethod ) .. ")", 2 ) end - if native.isPresent( _sSide ) then - return native.call( _sSide, _sMethod, ... ) - end - for n,sSide in ipairs( rs.getSides() ) do - if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then - if native.call( sSide, "isPresentRemote", _sSide ) then - return native.call( sSide, "callRemote", _sSide, _sMethod, ... ) - end - end - end - return nil + if native.isPresent( _sSide ) then + return native.call( _sSide, _sMethod, ... ) + end + for n,sSide in ipairs( rs.getSides() ) do + if native.getType( sSide ) == "modem" and not native.call( sSide, "isWireless" ) then + if native.call( sSide, "isPresentRemote", _sSide ) then + return native.call( sSide, "callRemote", _sSide, _sMethod, ... ) + end + end + end + return nil end function wrap( _sSide ) if type( _sSide ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( _sSide ) .. ")", 2 ) end - if peripheral.isPresent( _sSide ) then - local tMethods = peripheral.getMethods( _sSide ) - local tResult = {} - for n,sMethod in ipairs( tMethods ) do - tResult[sMethod] = function( ... ) - return peripheral.call( _sSide, sMethod, ... ) - end - end - return tResult - end - return nil + if peripheral.isPresent( _sSide ) then + local tMethods = peripheral.getMethods( _sSide ) + local tResult = {} + for n,sMethod in ipairs( tMethods ) do + tResult[sMethod] = function( ... ) + return peripheral.call( _sSide, sMethod, ... ) + end + end + return tResult + end + return nil end function find( sType, fnFilter ) @@ -111,14 +111,14 @@ function find( sType, fnFilter ) if fnFilter ~= nil and type( fnFilter ) ~= "function" then error( "bad argument #2 (expected function, got " .. type( fnFilter ) .. ")", 2 ) end - local tResults = {} - for n,sName in ipairs( peripheral.getNames() ) do - if peripheral.getType( sName ) == sType then - local wrapped = peripheral.wrap( sName ) - if fnFilter == nil or fnFilter( sName, wrapped ) then - table.insert( tResults, wrapped ) - end - end - end - return table.unpack( tResults ) + local tResults = {} + for n,sName in ipairs( peripheral.getNames() ) do + if peripheral.getType( sName ) == sType then + local wrapped = peripheral.wrap( sName ) + if fnFilter == nil or fnFilter( sName, wrapped ) then + table.insert( tResults, wrapped ) + end + end + end + return table.unpack( tResults ) end diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/rednet.lua b/src/main/resources/assets/computercraft/lua/rom/apis/rednet.lua index 03fc1853b..5c0df229c 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/rednet.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/rednet.lua @@ -10,7 +10,7 @@ function open( sModem ) if type( sModem ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( sModem ) .. ")", 2 ) end - if peripheral.getType( sModem ) ~= "modem" then + if peripheral.getType( sModem ) ~= "modem" then error( "No such modem: "..sModem, 2 ) end peripheral.call( sModem, "open", os.getComputerID() ) @@ -244,7 +244,7 @@ function run() error( "rednet is already running", 2 ) end bRunning = true - + while bRunning do local sEvent, p1, p2, p3, p4 = os.pullEventRaw() if sEvent == "modem_message" then diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/settings.lua b/src/main/resources/assets/computercraft/lua/rom/apis/settings.lua index 071cb294a..be8b5a156 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/settings.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/settings.lua @@ -3,10 +3,10 @@ local tSettings = {} function set( sName, value ) if type( sName ) ~= "string" then error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) end - + local sValueTy = type(value) - if sValueTy ~= "number" and sValueTy ~= "string" and sValueTy ~= "boolean" and sValueTy ~= "table" then - error( "bad argument #2 (expected value, got " .. sValueTy .. ")", 2 ) + if sValueTy ~= "number" and sValueTy ~= "string" and sValueTy ~= "boolean" and sValueTy ~= "table" then + error( "bad argument #2 (expected value, got " .. sValueTy .. ")", 2 ) end if sValueTy == "table" then -- Ensure value is serializeable @@ -30,7 +30,7 @@ end function get( sName, default ) if type(sName) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) end local result = tSettings[ sName ] if result ~= nil then @@ -42,7 +42,7 @@ end function unset( sName ) if type(sName) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( sName ) .. ")", 2 ) end tSettings[ sName ] = nil end @@ -62,7 +62,7 @@ end function load( sPath ) if type(sPath) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 ) end local file = fs.open( sPath, "r" ) if not file then @@ -89,7 +89,7 @@ end function save( sPath ) if type(sPath) ~= "string" then - error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 ) + error( "bad argument #1 (expected string, got " .. type( sPath ) .. ")", 2 ) end local file = fs.open( sPath, "w" ) if not file then diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/term.lua b/src/main/resources/assets/computercraft/lua/rom/apis/term.lua index b33a67da2..59f705e9d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/term.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/term.lua @@ -3,32 +3,32 @@ local native = (term.native and term.native()) or term local redirectTarget = native local function wrap( _sFunction ) - return function( ... ) - return redirectTarget[ _sFunction ]( ... ) - end + return function( ... ) + return redirectTarget[ _sFunction ]( ... ) + end end local term = {} term.redirect = function( target ) if type( target ) ~= "table" then - error( "bad argument #1 (expected table, got " .. type( target ) .. ")", 2 ) + error( "bad argument #1 (expected table, got " .. type( target ) .. ")", 2 ) end if target == term then error( "term is not a recommended redirect target, try term.current() instead", 2 ) end - for k,v in pairs( native ) do - if type( k ) == "string" and type( v ) == "function" then - if type( target[k] ) ~= "function" then - target[k] = function() - error( "Redirect object is missing method "..k..".", 2 ) - end - end - end - end - local oldRedirectTarget = redirectTarget - redirectTarget = target - return oldRedirectTarget + for k,v in pairs( native ) do + if type( k ) == "string" and type( v ) == "function" then + if type( target[k] ) ~= "function" then + target[k] = function() + error( "Redirect object is missing method "..k..".", 2 ) + end + end + end + end + local oldRedirectTarget = redirectTarget + redirectTarget = target + return oldRedirectTarget end term.current = function() @@ -43,14 +43,14 @@ term.native = function() end for k,v in pairs( native ) do - if type( k ) == "string" and type( v ) == "function" then - if term[k] == nil then - term[k] = wrap( k ) - end - end + if type( k ) == "string" and type( v ) == "function" then + if term[k] == nil then + term[k] = wrap( k ) + end + end end - + local env = _ENV for k,v in pairs( term ) do - env[k] = v + env[k] = v end diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua index 088bf82a2..7b0555b7d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/textutils.lua @@ -8,11 +8,11 @@ function slowWrite( sText, nRate ) error( "Rate must be positive", 2 ) end local nSleep = 1 / nRate - + sText = tostring( sText ) local x,y = term.getCursorPos() local len = string.len( sText ) - + for n=1,len do term.setCursorPos( x, y ) sleep( nSleep ) @@ -32,7 +32,7 @@ function formatTime( nTime, bTwentyFourHour ) error( "bad argument #1 (expected number, got " .. type( nTime ) .. ")", 2 ) end if bTwentyFourHour ~= nil and type( bTwentyFourHour ) ~= "boolean" then - error( "bad argument #2 (expected boolean, got " .. type( bTwentyFourHour ) .. ")", 2 ) + error( "bad argument #2 (expected boolean, got " .. type( bTwentyFourHour ) .. ")", 2 ) end local sTOD = nil if not bTwentyFourHour then @@ -61,7 +61,7 @@ local function makePagedScroll( _term, _nFreeLines ) return function( _n ) for n=1,_n do nativeScroll( 1 ) - + if nFreeLines <= 0 then local w,h = _term.getSize() _term.setCursorPos( 1, h ) @@ -78,7 +78,7 @@ end function pagedPrint( _sText, _nFreeLines ) if _nFreeLines ~= nil and type( _nFreeLines ) ~= "number" then - error( "bad argument #2 (expected number, got " .. type( _nFreeLines ) .. ")", 2 ) + error( "bad argument #2 (expected number, got " .. type( _nFreeLines ) .. ")", 2 ) end -- Setup a redirector local oldTerm = term.current() @@ -113,17 +113,17 @@ local function tabulateCommon( bPaged, ... ) local tAll = { ... } for k,v in ipairs( tAll ) do if type( v ) ~= "number" and type( v ) ~= "table" then - error( "bad argument #"..k.." (expected number or table, got " .. type( v ) .. ")", 3 ) + error( "bad argument #"..k.." (expected number or table, got " .. type( v ) .. ")", 3 ) end end - + local w,h = term.getSize() local nMaxLen = w / 8 for n, t in ipairs( tAll ) do if type(t) == "table" then for nu, sItem in pairs(t) do if type( sItem ) ~= "string" then - error( "bad argument #"..n.."."..nu.." (expected string, got " .. type( sItem ) .. ")", 3 ) + error( "bad argument #"..n.."."..nu.." (expected string, got " .. type( sItem ) .. ")", 3 ) end nMaxLen = math.max( string.len( sItem ) + 1, nMaxLen ) end @@ -139,7 +139,7 @@ local function tabulateCommon( bPaged, ... ) end nLines = nLines + 1 end - + local function drawCols( _t ) local nCol = 1 for n, s in ipairs( _t ) do @@ -153,7 +153,7 @@ local function tabulateCommon( bPaged, ... ) term.setCursorPos( cx, cy ) term.write( s ) - nCol = nCol + 1 + nCol = nCol + 1 end print() end @@ -165,7 +165,7 @@ local function tabulateCommon( bPaged, ... ) elseif type(t) == "number" then term.setTextColor( t ) end - end + end end function tabulate( ... ) @@ -234,16 +234,16 @@ local function serializeImpl( t, tTracking, sIndent ) sResult = sResult .. sIndent .. "}" return sResult end - + elseif sType == "string" then return string.format( "%q", t ) - + elseif sType == "number" or sType == "boolean" or sType == "nil" then return tostring(t) - + else error( "Cannot serialize type "..sType, 0 ) - + end end @@ -365,7 +365,7 @@ function urlEncode( str ) end ) str = string.gsub(str, " ", "+") end - return str + return str end local tEmpty = {} @@ -403,7 +403,7 @@ function complete( sSearchText, tSearchTable ) return tEmpty end end - + local sPart = string.sub( sSearchText, nStart ) local nPartLength = string.len( sPart ) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/turtle/turtle.lua b/src/main/resources/assets/computercraft/lua/rom/apis/turtle/turtle.lua index fab90d5af..069f73b8d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/turtle/turtle.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/turtle/turtle.lua @@ -1,6 +1,6 @@ if not turtle then - error( "Cannot load turtle API on computer", 2 ) + error( "Cannot load turtle API on computer", 2 ) end native = turtle.native or turtle @@ -28,7 +28,7 @@ for k,v in pairs( native ) do return result, err end else - env[k] = v + env[k] = v end end addCraftMethod( env ) diff --git a/src/main/resources/assets/computercraft/lua/rom/apis/window.lua b/src/main/resources/assets/computercraft/lua/rom/apis/window.lua index 7238fef0d..7f901cfd2 100644 --- a/src/main/resources/assets/computercraft/lua/rom/apis/window.lua +++ b/src/main/resources/assets/computercraft/lua/rom/apis/window.lua @@ -84,11 +84,11 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) parent.setCursorPos( 0, 0 ) end end - + local function updateCursorBlink() parent.setCursorBlink( bCursorBlink ) end - + local function updateCursorColor() parent.setTextColor( nTextColor ) end @@ -275,7 +275,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) end local function setTextColor( color ) - if type( color ) ~= "number" then + if type( color ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( color ) .. ")", 2 ) elseif tHex[color] == nil then error( "Invalid color (got " .. color .. ")" , 2 ) @@ -291,7 +291,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) function window.setPaletteColour( colour, r, g, b ) if type( colour ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( colour ) .. ")", 2 ) end - + if tHex[colour] == nil then error( "Invalid color (got " .. colour .. ")" , 2 ) end @@ -304,7 +304,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible ) if type( r ) ~= "number" then error( "bad argument #2 (expected number, got " .. type( r ) .. ")", 2 ) end if type( g ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( g ) .. ")", 2 ) end if type( b ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( b ) .. ")", 2 ) end - + tCol = tPalette[ colour ] tCol[1] = r tCol[2] = g diff --git a/src/main/resources/assets/computercraft/lua/rom/help/alias.txt b/src/main/resources/assets/computercraft/lua/rom/help/alias.txt index 0b1f04425..4d11d45ce 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/alias.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/alias.txt @@ -1,6 +1,6 @@ -alias assigns shell commands to run other programs. - -ex: -"alias dir ls" will make the "dir" command run the "ls" program +alias assigns shell commands to run other programs. + +ex: +"alias dir ls" will make the "dir" command run the "ls" program "alias dir" will remove the alias set on "dir" "alias" will list all current aliases. \ No newline at end of file diff --git a/src/main/resources/assets/computercraft/lua/rom/help/set.txt b/src/main/resources/assets/computercraft/lua/rom/help/set.txt index 7e1d93cf0..580d19164 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/set.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/set.txt @@ -1,6 +1,6 @@ -The set program can be used to inspect and change system settings. - -Usage: -"set" will print all the system settings and their values -"set foo" will print the value of the system setting "foo" -"set foo bar" will set the value of the system setting "foo" to "bar" +The set program can be used to inspect and change system settings. + +Usage: +"set" will print all the system settings and their values +"set foo" will print the value of the system setting "foo" +"set foo bar" will set the value of the system setting "foo" to "bar" diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/alias.lua b/src/main/resources/assets/computercraft/lua/rom/programs/alias.lua index 97b68658c..6d7c3ff99 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/alias.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/alias.lua @@ -24,4 +24,3 @@ else table.sort( tList ) textutils.pagedTabulate( tList ) end - diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/edit.lua b/src/main/resources/assets/computercraft/lua/rom/programs/edit.lua index ce57f015b..43910d56a 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/edit.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/edit.lua @@ -77,7 +77,7 @@ local function load( _sPath ) end file:close() end - + if #tLines == 0 then table.insert( tLines, "" ) end @@ -91,7 +91,7 @@ local function save( _sPath ) end -- Save - local file = nil + local file, fileerr local function innerSave() file, fileerr = fs.open( _sPath, "w" ) if file then @@ -102,9 +102,9 @@ local function save( _sPath ) error( "Failed to open ".._sPath ) end end - + local ok, err = pcall( innerSave ) - if file then + if file then file.close() end return ok, err, fileerr @@ -150,8 +150,8 @@ local function tryWrite( sLine, regex, colour ) end local function writeHighlighted( sLine ) - while string.len(sLine) > 0 do - sLine = + while string.len(sLine) > 0 do + sLine = tryWrite( sLine, "^%-%-%[%[.-%]%]", commentColour ) or tryWrite( sLine, "^%-%-.*", commentColour ) or tryWrite( sLine, "^\"\"", stringColour ) or @@ -282,7 +282,7 @@ local function redrawMenu() term.setCursorPos( x - scrollX, y - scrollY ) end -local tMenuFuncs = { +local tMenuFuncs = { Save = function() if bReadOnly then sStatus = "Access denied" @@ -326,9 +326,9 @@ local tMenuFuncs = { } printerTerminal.scroll = function() if nPage == 1 then - printer.setPageTitle( sName.." (page "..nPage..")" ) + printer.setPageTitle( sName.." (page "..nPage..")" ) end - + while not printer.newPage() do if printer.getInkLevel() < 1 then sStatus = "Printer out of ink, please refill" @@ -337,11 +337,11 @@ local tMenuFuncs = { else sStatus = "Printer output tray full, please empty" end - + term.redirect( screenTerminal ) redrawMenu() term.redirect( printerTerminal ) - + local timer = os.startTimer(0.5) sleep(0.5) end @@ -353,7 +353,7 @@ local tMenuFuncs = { printer.setPageTitle( sName.." (page "..nPage..")" ) end end - + bMenu = false term.redirect( printerTerminal ) local ok, error = pcall( function() @@ -366,14 +366,14 @@ local tMenuFuncs = { if not ok then print( error ) end - + while not printer.endPage() do sStatus = "Printer output tray full, please empty" redrawMenu() sleep( 0.5 ) end bMenu = true - + if nPage > 1 then sStatus = "Printed "..nPage.." Pages" else @@ -416,7 +416,7 @@ local function setCursor( newX, newY ) x, y = newX, newY local screenX = x - scrollX local screenY = y - scrollY - + local bRedraw = false if screenX < 1 then scrollX = x - 1 @@ -427,7 +427,7 @@ local function setCursor( newX, newY ) screenX = w bRedraw = true end - + if screenY < 1 then scrollY = y - 1 screenY = 1 @@ -694,7 +694,7 @@ while bRunning do redrawMenu() end - + elseif sEvent == "char" then if not bMenu and not bReadOnly then -- Input text @@ -725,7 +725,7 @@ while bRunning do tLines[y] = string.sub(sLine,1,x-1) .. param .. string.sub(sLine,x) setCursor( x + string.len( param ), y ) end - + elseif sEvent == "mouse_click" then if not bMenu then if param == 1 then @@ -738,7 +738,7 @@ while bRunning do end end end - + elseif sEvent == "mouse_scroll" then if not bMenu then if param == -1 then @@ -748,7 +748,7 @@ while bRunning do scrollY = scrollY - 1 redrawText() end - + elseif param == 1 then -- Scroll down local nMaxScroll = #tLines - (h-1) @@ -757,7 +757,7 @@ while bRunning do scrollY = scrollY + 1 redrawText() end - + end end @@ -774,4 +774,3 @@ end term.clear() term.setCursorBlink( false ) term.setCursorPos( 1, 1 ) - diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/paint.lua b/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/paint.lua index 465910a48..bd0bb12b4 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/paint.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/paint.lua @@ -78,7 +78,7 @@ local function getCharOf( colour ) end end return " " -end +end --[[ Converts a text character to colour value @@ -94,7 +94,7 @@ local function getColourOf( char ) return tColourLookup[char] end ---[[ +--[[ Loads the file into the canvas params: path = the path of the file to open returns: nil @@ -116,8 +116,8 @@ local function load(path) end end ---[[ - Saves the current canvas to file +--[[ + Saves the current canvas to file params: path = the path of the file to save returns: true if save was successful, false otherwise ]] @@ -161,7 +161,7 @@ local function save(path) return true end ---[[ +--[[ Draws colour picker sidebar, the pallette and the footer returns: nil ]] @@ -172,7 +172,7 @@ local function drawInterface() term.setTextColour(colours.yellow) term.clearLine() term.write(fMessage) - + -- Colour Picker for i=1,16 do term.setCursorPos(w-1, i) @@ -184,7 +184,7 @@ local function drawInterface() term.setBackgroundColour( canvasColour ) term.setTextColour( colours.grey ) term.write("\127\127") - + -- Left and Right Selected Colours for i=18,18 do term.setCursorPos(w-1, i) @@ -214,7 +214,7 @@ local function drawInterface() end end ---[[ +--[[ Converts a single pixel of a single line of the canvas and draws it returns: nil ]] @@ -232,7 +232,7 @@ local function drawCanvasPixel( x, y ) end end ---[[ +--[[ Converts each colour in a single line of the canvas and draws it returns: nil ]] @@ -242,7 +242,7 @@ local function drawCanvasLine( y ) end end ---[[ +--[[ Converts each colour in the canvas and draws it returns: nil ]] @@ -259,7 +259,7 @@ end local function accessMenu() -- Selected menu option local selection = 1 - + term.setBackgroundColour(colours.black) while true do -- Draw the menu @@ -267,7 +267,7 @@ local function accessMenu() term.clearLine() term.setTextColour(colours.white) for k,v in pairs(mChoices) do - if selection==k then + if selection==k then term.setTextColour(colours.yellow) local ox,_ = term.getCursorPos() term.write("["..string.rep(" ",#v).."]") @@ -279,7 +279,7 @@ local function accessMenu() term.write(" "..v.." ") end end - + -- Handle input in the menu local id,key = os.pullEvent("key") if id == "key" then @@ -291,25 +291,25 @@ local function accessMenu() selection = 2 key = keys.enter end - + if key == keys.right then -- Move right selection = selection + 1 if selection > #mChoices then selection = 1 end - + elseif key == keys.left and selection > 1 then -- Move left selection = selection - 1 if selection < 1 then selection = #mChoices end - + elseif key == keys.enter then -- Select an option - if mChoices[selection]=="Save" then - if bReadOnly then + if mChoices[selection]=="Save" then + if bReadOnly then fMessage = "Access denied" return false end @@ -324,18 +324,18 @@ local function accessMenu() end end return false - elseif mChoices[selection]=="Exit" then + elseif mChoices[selection]=="Exit" then return true end elseif key == keys.leftCtrl or keys == keys.rightCtrl then -- Cancel the menu - return false + return false end end end end ---[[ +--[[ Runs the main thread of execution. Draws the canvas and interface, and handles mouse and key events. returns: nil @@ -405,4 +405,3 @@ term.setBackgroundColour(colours.black) term.setTextColour(colours.white) term.clear() term.setCursorPos(1,1) - diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/redirection.lua b/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/redirection.lua index df6685ce0..d58bb0a4a 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/redirection.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/fun/advanced/redirection.lua @@ -266,7 +266,7 @@ end local function drawMap() for x=1,SizeW do for y=1,SizeH do - + local obj = tScreen[x][y] if obj.ground == true then paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cG) @@ -274,7 +274,7 @@ local function drawMap() if obj.wall == true then paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cW) end - + local ex = tostring(tScreen[x][y].exit) if not(ex == "zz" or ex == "nil") then if ex == "a" then @@ -293,7 +293,7 @@ local function drawMap() term.setCursorPos(XOrgin+x,YOrgin+y+1) print("X") end - + local st = tostring(tScreen[x][y].start) if not(st == "zz" or st == "nil") then local Cr = string.sub(st,2,2) @@ -308,11 +308,11 @@ local function drawMap() else return error("Start Color Out") end - + term.setTextColor(Cr) term.setBackgroundColor(cG) term.setCursorPos(XOrgin+x,YOrgin+y+1) - + local sSide = string.sub(st,1,1) if sSide == "a" then print("^") @@ -326,11 +326,11 @@ local function drawMap() print("@") end end - + if obj.space == true then paintutils.drawPixel(XOrgin+x,YOrgin+y+1,cS) end - + local rb = tostring(tScreen[x][y].robot) if not(rb == "zz" or rb == "nil") then local Cr = string.sub(rb,2,2) @@ -516,13 +516,13 @@ function InterFace.drawBar() term.setBackgroundColor( colors.black ) term.setTextColor( InterFace.cTitle ) printCentred( 1, " "..sLevelTitle.." " ) - + term.setCursorPos(1,1) term.setBackgroundColor( cW ) write( " " ) term.setBackgroundColor( colors.black ) write( " x "..tostring(Blocks).." " ) - + term.setCursorPos( TermW-8,TermH ) term.setBackgroundColor( colors.black ) term.setTextColour(InterFace.cSpeedD) @@ -601,12 +601,12 @@ local function startG(LevelN) InterFace.drawBar() gRender("start") drawMap() - + local NExit = true if aExits == 0 then NExit = false end - + while true do local isExit = InterFace.render() if isExit == "end" then diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/fun/adventure.lua b/src/main/resources/assets/computercraft/lua/rom/programs/fun/adventure.lua index f5c888ff1..61f373e8e 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/fun/adventure.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/fun/adventure.lua @@ -279,7 +279,7 @@ local tRecipes = { ["a crafting table"] = { "some planks" }, ["a furnace"] = { "some stone" }, ["some torches"] = { "some sticks", "some coal" }, - + ["a wooden pickaxe"] = { "some planks", "some sticks" }, ["a stone pickaxe"] = { "some stone", "some sticks" }, ["an iron pickaxe"] = { "some iron", "some sticks" }, @@ -355,14 +355,14 @@ local function getRoom( x, y, z, dontCreate ) nMonsters = 0, } tMap[x][y][z] = room - + if y == 0 then -- Room is above ground -- Pick biome room.nBiome = math.random( 1, #tBiomes ) room.trees = hasTrees( room.nBiome ) - + -- Add animals if math.random(1,3) == 1 then for n = 1,math.random(1,2) do @@ -370,7 +370,7 @@ local function getRoom( x, y, z, dontCreate ) room.items[ sAnimal ] = items[ sAnimal ] end end - + -- Add surface ore if math.random(1,5) == 1 or hasStone( room.nBiome ) then room.items[ "some stone" ] = items[ "some stone" ] @@ -393,7 +393,7 @@ local function getRoom( x, y, z, dontCreate ) room.exits["down"] = true room.items["a cave entrance"] = items["a cave entrance"] end - + else -- Room is underground -- Add exits @@ -409,7 +409,7 @@ local function getRoom( x, y, z, dontCreate ) end end end - + if y == -1 then local above = getRoom( x, y + 1, z ) if above.exits["down"] then @@ -419,16 +419,16 @@ local function getRoom( x, y, z, dontCreate ) else tryExit( "up", "down", x, y + 1, z ) end - + if y > -3 then tryExit( "down", "up", x, y - 1, z ) end - + tryExit( "east", "west", x - 1, y, z ) tryExit( "west", "east", x + 1, y, z ) tryExit( "north", "south", x, y, z + 1 ) - tryExit( "south", "north", x, y, z - 1 ) - + tryExit( "south", "north", x, y, z - 1 ) + -- Add ores room.items[ "some stone" ] = items[ "some stone" ] if math.random(1,3) == 1 then @@ -440,7 +440,7 @@ local function getRoom( x, y, z, dontCreate ) if y == -3 and math.random(1,15) == 1 then room.items[ "some diamond" ] = items[ "some diamond" ] end - + -- Turn out the lights room.dark = true end @@ -453,11 +453,11 @@ local function itemize( t ) if item == nil then return "nothing" end - + local text = "" while item do text = text .. item - + local nextItem = next( t, item ) if nextItem ~= nil then local nextNextItem = next( t, nextItem ) @@ -611,7 +611,7 @@ local function doCommand( text ) commands[ "noinput" ]() return end - + for sCommand, t in pairs( tMatches ) do for n, sMatch in pairs( t ) do local tCaptures = { string.match( text, "^" .. sMatch .. "$" ) } @@ -659,7 +659,7 @@ function commands.look( _sTarget ) if room.trees then print( "There are trees here." ) end - + else -- Look at stuff if room.trees and (_sTarget == "tree" or _sTarget == "trees") then @@ -677,7 +677,7 @@ function commands.look( _sTarget ) tItem = inventory[sItem] end end - + if tItem then print( tItem.desc or ("You see nothing special about "..sItem..".") ) else @@ -693,7 +693,7 @@ function commands.go( _sDir ) print( "Go where?" ) return end - + if nGoWest ~= nil then if _sDir == "west" then nGoWest = nGoWest + 1 @@ -707,12 +707,12 @@ function commands.go( _sDir ) end end end - + if room.exits[_sDir] == nil then print( "You can't go that way." ) return end - + if _sDir == "north" then z = z + 1 elseif _sDir == "south" then @@ -729,7 +729,7 @@ function commands.go( _sDir ) print( "I don't understand that direction." ) return end - + nTimeInRoom = 0 doCommand( "look" ) end @@ -740,7 +740,7 @@ function commands.dig( _sDir, _sTool ) print( "Dig where?" ) return end - + local sTool = nil local tTool = nil if _sTool ~= nil then @@ -751,7 +751,7 @@ function commands.dig( _sDir, _sTool ) end tTool = inventory[ sTool ] end - + local bActuallyDigging = (room.exits[ _sDir ] ~= true) if bActuallyDigging then if sTool == nil or tTool.toolType ~= "pick" then @@ -759,7 +759,7 @@ function commands.dig( _sDir, _sTool ) return end end - + if _sDir == "north" then room.exits["north"] = true z = z + 1 @@ -769,17 +769,17 @@ function commands.dig( _sDir, _sTool ) room.exits["south"] = true z = z - 1 getRoom( x, y, z ).exits["north"] = true - + elseif _sDir == "east" then room.exits["east"] = true x = x - 1 getRoom( x, y, z ).exits["west"] = true - + elseif _sDir == "west" then room.exits["west"] = true x = x + 1 getRoom( x, y, z ).exits["east"] = true - + elseif _sDir == "up" then if y == 0 then print( "You can't dig that way." ) @@ -791,13 +791,13 @@ function commands.dig( _sDir, _sTool ) room.items[ "an exit to the surface" ] = items[ "an exit to the surface" ] end y = y + 1 - + room = getRoom( x, y, z ) room.exits["down"] = true if y == 0 then room.items[ "a cave entrance" ] = items[ "a cave entrance" ] end - + elseif _sDir == "down" then if y <= -3 then print( "You hit bedrock." ) @@ -809,18 +809,18 @@ function commands.dig( _sDir, _sTool ) room.items[ "a cave entrance" ] = items[ "a cave entrance" ] end y = y - 1 - + room = getRoom( x, y, z ) room.exits["up"] = true if y == -1 then room.items[ "an exit to the surface" ] = items[ "an exit to the surface" ] end - + else print( "I don't understand that direction." ) return end - + -- if bActuallyDigging then if _sDir == "down" and y == -1 or @@ -833,7 +833,7 @@ function commands.dig( _sDir, _sTool ) print( "You dig ".._sDir.." using "..sTool.." and collect some stone." ) end end - + nTimeInRoom = 0 doCommand( "look" ) end @@ -847,7 +847,7 @@ function commands.drop( _sItem ) print( "Drop what?" ) return end - + local room = getRoom( x,y,z ) local sItem = findItem( inventory, _sItem ) if sItem then @@ -869,7 +869,7 @@ function commands.place( _sItem ) print( "Place what?" ) return end - + if _sItem == "torch" or _sItem == "a torch" then local room = getRoom( x,y,z ) if inventory["some torches"] or inventory["a torch"] then @@ -888,7 +888,7 @@ function commands.place( _sItem ) end return end - + commands.drop( _sItem ) end @@ -911,7 +911,7 @@ function commands.take( _sItem ) room.items[ sItem ] = nil end inventory[ sItem ] = tItem - + if inventory["some torches"] and inventory["a torch"] then inventory["a torch"] = nil end @@ -935,7 +935,7 @@ function commands.mine( _sItem, _sTool ) if _sTool == nil then print( "Mine ".._sItem.." with what?" ) return - end + end commands.cbreak( _sItem, _sTool ) end @@ -952,7 +952,7 @@ function commands.cbreak( _sItem, _sTool ) print( "Break what?" ) return end - + local sTool = nil if _sTool ~= nil then sTool = findItem( inventory, _sTool ) @@ -977,7 +977,7 @@ function commands.cbreak( _sItem, _sTool ) bRunning = false return end - + local sItem = findItem( room.items, _sItem ) if sItem then local tItem = room.items[ sItem ] @@ -1003,7 +1003,7 @@ function commands.cbreak( _sItem, _sTool ) else print( "You can't break "..sItem.." with "..sTool..".") end - + elseif tItem.creature == true then -- Fighting monsters (or pigs) local toolLevel = 0 @@ -1014,12 +1014,12 @@ function commands.cbreak( _sItem, _sTool ) toolLevel = tTool.toolLevel end end - + local tChances = { 0.2, 0.4, 0.55, 0.8, 1 } if math.random() <= tChances[ toolLevel + 1 ] then room.items[ sItem ] = nil print( "The "..tItem.aliases[1].." dies." ) - + if tItem.drops then for n, sDrop in pairs( tItem.drops ) do if not room.items[sDrop] then @@ -1028,14 +1028,14 @@ function commands.cbreak( _sItem, _sTool ) end end end - + if tItem.monster then room.nMonsters = room.nMonsters - 1 end else print( "The "..tItem.aliases[1].." is injured by your blow." ) end - + if tItem.hitDrops then for n, sDrop in pairs( tItem.hitDrops ) do if not room.items[sDrop] then @@ -1044,7 +1044,7 @@ function commands.cbreak( _sItem, _sTool ) end end end - + else print( "You can't break "..sItem.."." ) end @@ -1058,7 +1058,7 @@ function commands.craft( _sItem ) print( "Craft what?" ) return end - + if _sItem == "computer" or _sItem == "a computer" then print( "By creating a computer in a computer in a computer, you tear a hole in the spacetime continuum from which no mortal being can escape." ) if term.isColour() then @@ -1070,7 +1070,7 @@ function commands.craft( _sItem ) bRunning = false return end - + local room = getRoom( x,y,z ) local sItem = findItem( items, _sItem ) local tRecipe = (sItem and tRecipes[ sItem ]) or nil @@ -1081,7 +1081,7 @@ function commands.craft( _sItem ) return end end - + for n,sReq in ipairs( tRecipe ) do inventory[sReq] = nil end @@ -1092,7 +1092,7 @@ function commands.craft( _sItem ) print( "Crafted." ) else print( "You don't know how to make "..(sItem or _sItem).."." ) - end + end end function commands.build( _sThing, _sMaterial ) @@ -1100,7 +1100,7 @@ function commands.build( _sThing, _sMaterial ) print( "Build what?" ) return end - + local sMaterial = nil if _sMaterial == nil then for sItem, tItem in pairs( inventory ) do @@ -1119,18 +1119,18 @@ function commands.build( _sThing, _sMaterial ) print( "You don't have any ".._sMaterial ) return end - + if inventory[sMaterial].material ~= true then print( sMaterial.." is not a good building material." ) return end end - + local alias = nil if string.sub(_sThing, 1, 1) == "a" then alias = string.match( _sThing, "a ([%a ]+)" ) end - + local room = getRoom( x,y,z ) inventory[sMaterial] = nil room.items[ _sThing ] = { @@ -1143,7 +1143,7 @@ function commands.build( _sThing, _sMaterial ) end function commands.help() - local sText = + local sText = "Welcome to adventure, the greatest text adventure game on CraftOS. " .. "To get around the world, type actions, and the adventure will " .. "be read back to you. The actions availiable to you are go, look, inspect, inventory, " .. @@ -1162,12 +1162,12 @@ function commands.eat( _sItem ) print( "You don't have any ".._sItem.."." ) return end - + local tItem = inventory[sItem] if tItem.food then print( "That was delicious!" ) inventory[sItem] = nil - + if bInjured then print( "You are no longer injured." ) bInjured = false @@ -1212,7 +1212,7 @@ end local function simulate() local bNewMonstersThisRoom = false - + -- Spawn monsters in nearby rooms for sx = -2,2 do for sy = -1,1 do @@ -1220,24 +1220,24 @@ local function simulate() local h = y + sy if h >= -3 and h <= 0 then local room = getRoom( x + sx, h, z + sz ) - + -- Spawn monsters if room.nMonsters < 2 and ((h == 0 and not isSunny() and not room.items["a torch"]) or room.dark) and math.random(1,6) == 1 then - + local sMonster = tMonsters[ math.random(1,#tMonsters) ] if room.items[ sMonster ] == nil then room.items[ sMonster ] = items[ sMonster ] room.nMonsters = room.nMonsters + 1 - + if sx == 0 and sy == 0 and sz == 0 and not room.dark then print( "From the shadows, "..sMonster.." appears." ) bNewMonstersThisRoom = true end - end + end end - + -- Burn monsters if h == 0 and isSunny() then for n,sMonster in ipairs( tMonsters ) do @@ -1249,7 +1249,7 @@ local function simulate() room.nMonsters = room.nMonsters - 1 end end - end + end end end end @@ -1277,7 +1277,7 @@ local function simulate() print( "The "..items[sMonster].aliases[1].." attacks you." ) end end - + if bInjured then if term.isColour() then term.setTextColour( colours.red ) @@ -1290,13 +1290,13 @@ local function simulate() else bInjured = true end - + break end end end end - + -- Always print this if bInjured then if term.isColour() then @@ -1305,7 +1305,7 @@ local function simulate() print( "You are injured." ) term.setTextColour( colours.white ) end - + -- Advance time nTurn = nTurn + 1 nTimeInRoom = nTimeInRoom + 1 @@ -1321,10 +1321,10 @@ while bRunning do end write( "? " ) term.setTextColour( colours.white ) - + local sRawLine = read( nil, tCommandHistory ) table.insert( tCommandHistory, sRawLine ) - + local sLine = nil for match in string.gmatch(sRawLine, "%a+") do if sLine then @@ -1333,7 +1333,7 @@ while bRunning do sLine = string.lower(match) end end - + doCommand( sLine or "" ) if bRunning then simulate() diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/fun/dj.lua b/src/main/resources/assets/computercraft/lua/rom/programs/fun/dj.lua index 43ec23a4c..4cc98a3ef 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/fun/dj.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/fun/dj.lua @@ -43,8 +43,8 @@ elseif sCommand == "play" or sCommand == nil then print( "No Music Disc in disk drive: "..sName ) return end - + else printUsage() - + end diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/fun/worm.lua b/src/main/resources/assets/computercraft/lua/rom/programs/fun/worm.lua index ef0925965..33c7eed8f 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/fun/worm.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/fun/worm.lua @@ -75,7 +75,7 @@ local function addFruit() break end end - + nFruit = nFruit + 1 if nFruit > #tFruits then nFruit = 1 @@ -86,7 +86,7 @@ local function drawMenu() term.setTextColour( headingColour ) term.setCursorPos(1,1) term.write( "SCORE " ) - + term.setTextColour( textColour ) term.setCursorPos(7,1) term.write( tostring(nScore) ) @@ -97,7 +97,7 @@ local function drawMenu() term.setTextColour( textColour ) term.setCursorPos(w,1) - term.write( tostring(nDifficulty or "?") ) + term.write( tostring(nDifficulty or "?") ) term.setTextColour( colours.white ) end @@ -120,7 +120,7 @@ local function update( ) else nExtraLength = nExtraLength - 1 end - + -- Update the head local head = screen[xPos][yPos] local newXPos = xPos + xVel @@ -135,11 +135,11 @@ local function update( ) elseif newYPos > h then newYPos = 2 end - + local newHead = screen[newXPos][newYPos] if newHead.snake == true or newHead.wall == true then bRunning = false - + else if newHead.fruit == true then nScore = nScore + 10 @@ -151,9 +151,9 @@ local function update( ) head.nextX = newXPos head.nextY = newYPos screen[newXPos][newYPos] = { snake = true } - + end - + term.setCursorPos(xPos,yPos) term.setBackgroundColour( wormColour ) term.write(" ") @@ -172,7 +172,7 @@ local function drawFrontend() printCentred( math.floor(h/2) - 3, "" ) printCentred( math.floor(h/2) - 2, " SELECT DIFFICULTY " ) printCentred( math.floor(h/2) - 1, "" ) - + printCentred( math.floor(h/2) + 0, " " ) printCentred( math.floor(h/2) + 1, " " ) printCentred( math.floor(h/2) + 2, " " ) @@ -232,7 +232,7 @@ while bRunning do if event == "timer" and p1 == timer then timer = os.startTimer(nInterval) update( false ) - + elseif event == "key" then local key = p1 if key == keys.up or key == keys.w then @@ -250,14 +250,14 @@ while bRunning do if xVel == 0 then pxVel,pyVel = -1,0 end - + elseif key == keys.right or key == keys.d then -- Right if xVel == 0 then pxVel,pyVel = 1,0 end - - end + + end end end @@ -285,5 +285,3 @@ until e == "char" term.clear() term.setCursorPos(1,1) - - diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/gps.lua b/src/main/resources/assets/computercraft/lua/rom/programs/gps.lua index 49dfe01bf..fc1ae7614 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/gps.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/gps.lua @@ -11,13 +11,13 @@ if #tArgs < 1 then printUsage() return end - + local sCommand = tArgs[1] if sCommand == "locate" then -- "gps locate" -- Just locate this computer (this will print the results) gps.locate( 2, true ) - + elseif sCommand == "host" then -- "gps host" -- Act as a GPS host @@ -29,7 +29,7 @@ elseif sCommand == "host" then -- Find a modem local sModemSide = nil for n,sSide in ipairs( rs.getSides() ) do - if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then + if peripheral.getType( sSide ) == "modem" and peripheral.call( sSide, "isWireless" ) then sModemSide = sSide break end @@ -53,14 +53,14 @@ elseif sCommand == "host" then end print( "Position is "..x..","..y..","..z ) else - -- Position is to be determined using locate + -- Position is to be determined using locate x,y,z = gps.locate( 2, true ) if x == nil then print( "Run \"gps host \" to set position manually" ) return end end - + -- Open a channel local modem = peripheral.wrap( sModemSide ) print( "Opening channel on modem "..sModemSide ) @@ -76,7 +76,7 @@ elseif sCommand == "host" then if sSide == sModemSide and sChannel == gps.CHANNEL_GPS and sMessage == "PING" and nDistance then -- We received a ping message on the GPS channel, send a response modem.transmit( sReplyChannel, gps.CHANNEL_GPS, { x, y, z } ) - + -- Print the number of requests handled nServed = nServed + 1 if nServed > 1 then @@ -91,5 +91,4 @@ else -- "gps somethingelse" -- Error printUsage() - end diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/help.lua b/src/main/resources/assets/computercraft/lua/rom/programs/help.lua index e01f03297..5dc7f09d9 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/help.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/help.lua @@ -12,7 +12,7 @@ if sTopic == "index" then textutils.pagedTabulate( tTopics ) return end - + local sFile = help.lookup( sTopic ) local file = ((sFile ~= nil) and io.open( sFile )) or nil if file then diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/http/pastebin.lua b/src/main/resources/assets/computercraft/lua/rom/programs/http/pastebin.lua index 6ed1de298..fd31bd33a 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/http/pastebin.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/http/pastebin.lua @@ -5,28 +5,28 @@ local function printUsage() print( "pastebin get " ) print( "pastebin run " ) end - + local tArgs = { ... } if #tArgs < 2 then printUsage() return end - + if not http then printError( "Pastebin requires http API" ) printError( "Set http_enable to true in ComputerCraft.cfg" ) return end - + local function get(paste) write( "Connecting to pastebin.com... " ) local response = http.get( "https://pastebin.com/raw/"..textutils.urlEncode( paste ) ) - + if response then print( "Success." ) - + local sResponse = response.readAll() response.close() return sResponse @@ -34,7 +34,7 @@ local function get(paste) print( "Failed." ) end end - + local sCommand = tArgs[1] if sCommand == "put" then -- Upload a file to pastebin.com @@ -45,46 +45,46 @@ if sCommand == "put" then print( "No such file" ) return end - + -- Read in the file local sName = fs.getName( sPath ) local file = fs.open( sPath, "r" ) local sText = file.readAll() file.close() - + -- POST the contents to pastebin write( "Connecting to pastebin.com... " ) local key = "0ec2eb25b6166c0c27a394ae118ad829" local response = http.post( - "https://pastebin.com/api/api_post.php", + "https://pastebin.com/api/api_post.php", "api_option=paste&".. "api_dev_key="..key.."&".. "api_paste_format=lua&".. "api_paste_name="..textutils.urlEncode(sName).."&".. "api_paste_code="..textutils.urlEncode(sText) ) - + if response then print( "Success." ) - + local sResponse = response.readAll() response.close() - + local sCode = string.match( sResponse, "[^/]+$" ) print( "Uploaded as "..sResponse ) print( "Run \"pastebin get "..sCode.."\" to download anywhere" ) - + else print( "Failed." ) end - + elseif sCommand == "get" then -- Download a file from pastebin.com if #tArgs < 3 then printUsage() return end - + -- Determine file to download local sCode = tArgs[2] local sFile = tArgs[3] @@ -93,19 +93,19 @@ elseif sCommand == "get" then print( "File already exists" ) return end - + -- GET the contents from pastebin local res = get(sCode) - if res then + if res then local file = fs.open( sPath, "w" ) file.write( res ) file.close() - + print( "Downloaded as "..sFile ) - end + end elseif sCommand == "run" then local sCode = tArgs[2] - + local res = get(sCode) if res then local func, err = load(res, sCode, "t", _ENV) diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/http/wget.lua b/src/main/resources/assets/computercraft/lua/rom/programs/http/wget.lua index 2cacd6c54..08063c640 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/http/wget.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/http/wget.lua @@ -3,13 +3,13 @@ local function printUsage() print( "Usage:" ) print( "wget [filename]" ) end - + local tArgs = { ... } if #tArgs < 1 then printUsage() return end - + if not http then printError( "wget requires http API" ) printError( "Set http_enable to true in ComputerCraft.cfg" ) diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/id.lua b/src/main/resources/assets/computercraft/lua/rom/programs/id.lua index b9211963d..bacf2851e 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/id.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/id.lua @@ -7,7 +7,7 @@ end if sDrive == nil then print( "This is computer #"..os.getComputerID() ) - + local label = os.getComputerLabel() if label then print( "This computer is labelled \""..label.."\"" ) @@ -19,7 +19,7 @@ else print( "No disk in drive "..sDrive ) return end - + print( "The disk is #"..disk.getID( sDrive ) ) local label = disk.getLabel( sDrive ) @@ -27,4 +27,3 @@ else print( "The disk is labelled \""..label.."\"" ) end end - diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/lua.lua b/src/main/resources/assets/computercraft/lua/rom/programs/lua.lua index 2bef9bf2d..758ca74ef 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/lua.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/lua.lua @@ -47,7 +47,7 @@ while bRunning do if s:match("%S") and tCommandHistory[#tCommandHistory] ~= s then table.insert( tCommandHistory, s ) end - + local nForcePrint = 0 local func, e = load( s, "lua", "t", tEnv ) local func2, e2 = load( "return _echo("..s..");", "lua", "t", tEnv ) @@ -62,7 +62,7 @@ while bRunning do func = func2 end end - + if func then local tResults = table.pack( pcall( func ) ) if tResults[1] then @@ -92,5 +92,5 @@ while bRunning do else printError( e ) end - + end diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua b/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua index a24e4e0c8..985cc0246 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/monitor.lua @@ -1,4 +1,3 @@ - local function printUsage() print( "Usage: monitor " ) return @@ -64,4 +63,3 @@ term.redirect( previousTerm ) if not ok then printError( param ) end - diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/pocket/unequip.lua b/src/main/resources/assets/computercraft/lua/rom/programs/pocket/unequip.lua index c6639d9ea..22174deba 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/pocket/unequip.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/pocket/unequip.lua @@ -3,4 +3,4 @@ if not ok then printError( "Nothing to unequip" ) else print( "Item unequipped" ) -end \ No newline at end of file +end diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/rednet/repeat.lua b/src/main/resources/assets/computercraft/lua/rom/programs/rednet/repeat.lua index 74585f0f3..c8fdc89b8 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/rednet/repeat.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/rednet/repeat.lua @@ -15,14 +15,14 @@ else print( #tModems .. " modems found." ) end -function open( nChannel ) +local function open( nChannel ) for n=1,#tModems do local sModem = tModems[n] peripheral.call( sModem, "open", nChannel ) end end -function close( nChannel ) +local function close( nChannel ) for n=1,#tModems do local sModem = tModems[n] peripheral.call( sModem, "close", nChannel ) diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/shell.lua b/src/main/resources/assets/computercraft/lua/rom/programs/shell.lua index e91a9c38e..94fa6a23e 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/shell.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/shell.lua @@ -254,7 +254,7 @@ function shell.resolveProgram( _sCommand ) end return nil end - + -- Otherwise, look on the path variable for sPath in string.gmatch(sPath, "[^:]+") do sPath = fs.combine( shell.resolve( sPath ), _sCommand ) @@ -267,14 +267,14 @@ function shell.resolveProgram( _sCommand ) end end end - + -- Not found return nil end function shell.programs( _bIncludeHidden ) local tItems = {} - + -- Add programs from the path for sPath in string.gmatch(sPath, "[^:]+") do sPath = shell.resolve( sPath ) @@ -291,7 +291,7 @@ function shell.programs( _bIncludeHidden ) end end end - end + end -- Sort and return local tItemList = {} diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/dance.lua b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/dance.lua index 1b07b9019..dc3c7d083 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/dance.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/dance.lua @@ -96,7 +96,7 @@ parallel.waitForAny( if key ~= keys.escape then return end - end + end end, function() while true do diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/excavate.lua b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/excavate.lua index b6380e96f..2c47f2986 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/excavate.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/excavate.lua @@ -11,7 +11,7 @@ if size < 1 then print( "Excavate diameter must be positive" ) return end - + local depth = 0 local unloaded = 0 local collected = 0 @@ -21,18 +21,18 @@ local xDir,zDir = 0,1 local goTo -- Filled in further down local refuel -- Filled in further down - + local function unload( _bKeepOneFuelStack ) print( "Unloading items..." ) for n=1,16 do local nCount = turtle.getItemCount(n) if nCount > 0 then - turtle.select(n) + turtle.select(n) local bDrop = true if _bKeepOneFuelStack and turtle.refuel(0) then bDrop = false _bKeepOneFuelStack = false - end + end if bDrop then turtle.drop() unloaded = unloaded + nCount @@ -47,7 +47,7 @@ local function returnSupplies() local x,y,z,xd,zd = xPos,depth,zPos,xDir,zDir print( "Returning to surface..." ) goTo( 0,0,0,0,-1 ) - + local fuelNeeded = 2*(x+y+z) + 1 if not refuel( fuelNeeded ) then unload( true ) @@ -56,14 +56,14 @@ local function returnSupplies() os.pullEvent( "turtle_inventory" ) end else - unload( true ) + unload( true ) end - + print( "Resuming mining..." ) goTo( x,y,z,xd,zd ) end -local function collect() +local function collect() local bFull = true local nTotalItems = 0 for n=1,16 do @@ -73,14 +73,14 @@ local function collect() end nTotalItems = nTotalItems + nCount end - + if nTotalItems > collected then collected = nTotalItems if math.fmod(collected + unloaded, 50) == 0 then print( "Mined "..(collected + unloaded).." items." ) end end - + if bFull then print( "No empty slots left." ) return false @@ -93,7 +93,7 @@ function refuel( ammount ) if fuelLevel == "unlimited" then return true end - + local needed = ammount or (xPos + zPos + depth + 2) if turtle.getFuelLevel() < needed then local fueled = false @@ -114,7 +114,7 @@ function refuel( ammount ) turtle.select(1) return false end - + return true end @@ -123,7 +123,7 @@ local function tryForwards() print( "Not enough Fuel" ) returnSupplies() end - + while not turtle.forward() do if turtle.detect() then if turtle.dig() then @@ -141,7 +141,7 @@ local function tryForwards() sleep( 0.5 ) end end - + xPos = xPos + xDir zPos = zPos + zDir return true @@ -152,7 +152,7 @@ local function tryDown() print( "Not enough Fuel" ) returnSupplies() end - + while not turtle.down() do if turtle.detectDown() then if turtle.digDown() then @@ -227,7 +227,7 @@ function goTo( x, y, z, xd, zd ) end end end - + if zPos > z then while zDir ~= -1 do turnLeft() @@ -253,9 +253,9 @@ function goTo( x, y, z, xd, zd ) else sleep( 0.5 ) end - end + end end - + while depth < y do if turtle.down() then depth = depth + 1 @@ -265,7 +265,7 @@ function goTo( x, y, z, xd, zd ) sleep( 0.5 ) end end - + while zDir ~= zd or xDir ~= xd do turnLeft() end @@ -318,7 +318,7 @@ while not done do if done then break end - + if size > 1 then if math.fmod(size,2) == 0 then turnRight() @@ -331,7 +331,7 @@ while not done do alternate = 1 - alternate end end - + if not tryDown() then done = true break diff --git a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/tunnel.lua b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/tunnel.lua index da286c8a4..4ee78ecde 100644 --- a/src/main/resources/assets/computercraft/lua/rom/programs/turtle/tunnel.lua +++ b/src/main/resources/assets/computercraft/lua/rom/programs/turtle/tunnel.lua @@ -11,7 +11,7 @@ if length < 1 then print( "Tunnel length must be positive" ) return end - + local depth = 0 local collected = 0 @@ -63,7 +63,7 @@ local function refuel() if fuelLevel == "unlimited" or fuelLevel > 0 then return end - + local function tryRefuel() for n=1,16 do if turtle.getItemCount(n) > 0 then @@ -77,7 +77,7 @@ local function refuel() turtle.select(1) return false end - + if not tryRefuel() then print( "Add more fuel to continue." ) while not tryRefuel() do @@ -150,7 +150,7 @@ for n=1,length do tryDown() tryDig() turtle.turnLeft() - + if n battleship host\nHosts a game, waits for another computer to join\n> battleship join\nLooks for another game to join") - quit() -end - ---get player name -while true do - doColor(colors.cyan,colors.black) - write("player name: ") - doColor(colors.gray,colors.black) - myName=read() - if myName=="" then - doColor(colors.red,colors.black) - print("You have to give a name!") - elseif #myName>11 then - doColor(colors.red,colors.black) - print("Max name is 11 characters!") - else - break - end -end - -if action=="join" then - print("Attempting to join a game...\n(press q to cancel)") - while true do - local retryTimer=os.startTimer(1); - rednet.broadcast("bs join "..myName); - - while true do - local event,p1,p2,p3=os.pullEvent(); - if event=="rednet_message" then - opponent=string.match(p2,"bs accept %s*(.+)%s*") - if opponent then - opponentID=p1 - break - end - elseif event=="timer" and p1==retryTimer then - break - elseif event=="char" and (p1=="q" or p1=="Q") then - print("Couldn't find an opponent; quitting") - quit() - end - end - local joined=false - - if opponentID then - print("Joining game!") - rednet.send(opponentID,"bs start") - break - end - end -elseif action=="host" then - print("Waiting for challenger...\n(Press q to cancel)") - while true do - while true do - local event,p1,p2=os.pullEvent() - if event=="rednet_message" then - opponent=string.match(p2,"bs join %s*(.+)%s*") if opponent then - print("found player, inviting..") - opponentID=p1 - break - end - elseif event=="char" and (p1=="q" or p1=="Q") then - print("Couldn't find opponent, quitting") - quit() - end - end - - if opponentID then - rednet.send(opponentID,"bs accept "..myName) - local timeout=os.startTimer(1) - while true do - local event,p1,p2=os.pullEvent() - if event=="rednet_message" and p2=="bs start" then - print("player joined!") - break - elseif event=="timer" and p1==timeout then - print("player joined another game. Waiting for another...") - opponentID=nil - break - end - end - - if opponentID then - break - end - end - end -end - -local ships={ - {pos=nil,dir="h",size=5,name="carrier",hits=0}, - {pos=nil,dir="h",size=4,name="battleship",hits=0}, - {pos=nil,dir="h",size=3,name="cruiser",hits=0}, - {pos=nil,dir="h",size=3,name="submarine",hits=0}, - {pos=nil,dir="h",size=2,name="destroyer",hits=0}, -} - -local myShotTable={ {1,1,true},{5,5,false} } -local oppShotTable={ } - -local myGrid,oppGrid={title=myName},{title=opponent} - ---setup grids -for i=1,10 do - myGrid[i]={} - oppGrid[i]={} - for j=1,10 do - myGrid[i][j]={hit=false,ship=false} - oppGrid[i][j]={hit=false,ship=false} - end -end - -local function drawShipsToGrid(ships,grid) - for i=1,#ships do - local x,y=table.unpack(ships[i].pos) - local stepX=ships[i].dir=="h" and 1 or 0 - local stepY=stepX==1 and 0 or 1 - for j=1,ships[i].size do - grid[x][y].ship=i - x,y=x+stepX,y+stepY - end - end -end - -local function drawShotToGrid(shot,grid) - grid[shot[1]][shot[2]].shot=true - grid[shot[1]][shot[2]].hit=shot[3] -end - -local function makeShot(x,y,grid) - local tile=grid[x][y] - if tile.shot==true then - return nil --already shot here! - end - - local shot={x,y,tile.ship} - drawShotToGrid(shot,grid) - if tile.ship then - ships[tile.ship].hits=ships[tile.ship].hits+1 - if ships[tile.ship].hits==ships[tile.ship].size then - os.queueEvent("shipsunk",tile.ship) - end - end - return shot -end - - -local function drawTile(scrX,scrY,tile) - term.setCursorPos(scrX,scrY) - - if tile.ship then - if tile.shot then - doColor(colors.red,colors.gray) - term.write("@") - else - doColor(colors.white,colors.gray) - term.write("O") - end - else - if tile.hit then - doColor(colors.red,colors.gray) - term.write("x") - elseif tile.shot then - doColor(colors.white,colors.lightBlue) - term.write(".") - else - doColor(colors.white,colors.lightBlue) - term.write(" ") - end - end -end - -local function drawGrid(scrX,scrY,grid) - doColor(colors.white,colors.black) - term.setCursorPos(scrX,scrY+1) - term.write(" ") - doColor(colors.white,colors.gray) - term.setCursorPos(scrX,scrY) - local pad=11-#grid.title - term.write(string.rep(" ",math.ceil(pad/2))..grid.title..string.rep(" ",math.floor(pad/2))) - - for gx=1,10 do - term.setTextColor(colors.white) - term.setBackgroundColor(colors.black) - term.setCursorPos(scrX+gx,scrY+1) - term.write(gx==10 and "0" or string.char(string.byte("0")+gx)) - - term.setCursorPos(scrX,scrY+gx+1) - term.write(string.char(string.byte("A")+gx-1)) - for gy=1,10 do - drawTile(scrX+gx,scrY+gy+1,grid[gx][gy]) - end - end - doColor(colors.white,colors.black) -end - -function moveTargetIndicator(newX,newY) - --if x has changed... - if targetX and targetY then - drawTile(targetX+targetGridBounds.minX-1,targetY+targetGridBounds.minY-1,oppGrid[targetX][targetY]) - end - doColor(colors.yellow,colors.lightGray) - if newX~=targetX then - --space over old - if targetX then - term.setCursorPos(targetGridBounds.minX+targetX-1,targetGridBounds.maxY+1) - term.write(" ") - term.setCursorPos(targetGridBounds.minX+targetX-1,targetGridBounds.minY-3) - term.write(" ") - end - --draw new - term.setCursorPos(targetGridBounds.minX+newX-1,targetGridBounds.maxY+1) - term.write("^") - term.setCursorPos(targetGridBounds.minX+newX-1,targetGridBounds.minY-3) - term.write("v") - - targetX=newX - end - if newY~=targetY then - --space over old - if targetY then - term.setCursorPos(targetGridBounds.maxX+1,targetGridBounds.minY+targetY-1) - term.write(" ") - term.setCursorPos(targetGridBounds.minX-2,targetGridBounds.minY+targetY-1) - term.write(" ") - end - --draw new - term.setCursorPos(targetGridBounds.maxX+1,targetGridBounds.minY+newY-1) - term.write("<") - term.setCursorPos(targetGridBounds.minX-2,targetGridBounds.minY+newY-1) - term.write(">") - - targetY=newY - end - term.setCursorPos(15,15) - term.write("Target : "..toGridRef(targetX,targetY)) - --if the target tile is a valid target, draw a "+" - if not oppGrid[targetX][targetY].shot then - term.setCursorPos(targetX+targetGridBounds.minX-1,targetY+targetGridBounds.minY-1) - doColor(colors.yellow,colors.lightBlue) - term.write("+") - end -end - -local log={} - -local termWidth,termHeight=term.getSize() - -local logHeight=termHeight-3 -local logWidth=termWidth-28 - -for i=1,logHeight do - log[i]="" -end - -local function printLog() - doColor(colors.white,colors.black) - for i=1,logHeight do - term.setCursorPos(28,1+i) - local name,line=string.match(log[i],"(<[^>]+> )(.*)") - if name then - doColor(colors.lightBlue,colors.black) - write(name) - doColor(colors.white,colors.black) - write(line..string.rep(" ",logWidth-#log[i])) - else - write(log[i]..string.rep(" ",logWidth-#log[i])) - end - end -end - - - ---shipX/Y are the position of ship on grid; gridX/Y are the offset of the top-left of grid -local function drawShip(size,align,x,y,char) - local stepX=align=="h" and 1 or 0 - local stepY=stepX==1 and 0 or 1 - for j=1,size do - term.setCursorPos(x,y) - term.write(char) - x,y=x+stepX,y+stepY - end -end - -local function setStatusLine(lineNum,text) - doScreenColor() - local pad=math.floor((termWidth-#text)/2) - term.setCursorPos(1,16+lineNum) - term.write((" "):rep(pad)..text..(" "):rep(termWidth-#text-pad)) -end - - -doScreenColor() -term.clear() - -drawGrid(2,2,myGrid) - -setStatusLine(1,"Started game with "..opponent.." at computer #"..(opponentID or "nil")) - -local function getShipBounds(ship) - return { - minX=ship.pos[1], - minY=ship.pos[2], - maxX=ship.pos[1]+(ship.dir=="h" and ship.size-1 or 0), - maxY=ship.pos[2]+(ship.dir=="v" and ship.size-1 or 0) - } -end - -local function getPointBounds(x,y) - return { - minX=x, - minY=y, - maxX=x, - maxY=y, - } -end - -local function boundsIntersect(boundsA,boundsB) - return not ( - boundsA.minX>boundsB.maxX or - boundsA.maxXboundsB.maxY or - boundsA.maxY="a" and p1<="j" then - --row selected - moveTargetIndicator(targetX,string.byte(p1)-string.byte("a")+1) - elseif p1>="0" and p1<="9" then - local t=string.byte(p1)-string.byte("0") - if t==0 then t=10 end - moveTargetIndicator(t,targetY) - end - elseif e=="key" then - if p1==keys.enter or p1==keys.space and targetX and targetY then - local shot=makeShot(targetX,targetY,oppGrid) - if shot then - rednet.send(opponentID,"bs shot "..targetX.." "..targetY) - break - end - elseif p1==keys.up then - moveTargetIndicator(targetX,math.max(targetY-1,1)) - elseif p1==keys.down then - moveTargetIndicator(targetX,math.min(targetY+1,10)) - elseif p1==keys.left then - moveTargetIndicator(math.max(targetX-1,1),targetY) - elseif p1==keys.right then - moveTargetIndicator(math.min(targetX+1,10),targetY) - end - end - end - --shot sent, wait for my turn to resolve (top coroutine will switch turns and draw the hit to the grid) - setStatusLine(2,"Waiting for opponent...") - while myTurn do - os.pullEvent() - end - end -end - -local gameRoutine=coroutine.create(runGame) ---if advanced terminal, default focus to chat, can play with mouse -local inChat=term.isColor() -local savedCursorPos={7,19} - ---redirect just to block scroll -local redir={} -for k,v in pairs(originalTerm) do - if k~="scroll" then - redir[k]=v - else - redir[k]=function() end - end -end -originalTerm = term.redirect(redir) - ---run the game routine once -coroutine.resume(gameRoutine) ---hide cursor -term.setCursorBlink(false) - -while true do - local e,p1,p2,p3,p4,p5=os.pullEventRaw() - if e=="terminate" then - quit() - elseif e=="shipsunk" then - setStatusLine(1,opponent.." sank your "..ships[p1].name.."!") - rednet.send(opponentID,"bs sink") - shipsLeft=shipsLeft-1 - if shipsLeft==1 then - setStatusLine(3,"You only have 1 ship left!") - elseif shipsLeft>1 then - setStatusLine(3,"You have "..shipsLeft.." ships left!") - else - rednet.send(opponentID,"bs win") - setStatusLine(3,"You lost the game!") - break - end - elseif e=="rednet_message" then - local cmd,args=string.match(p2,"^bs (%S+)%s?(.*)") - if cmd=="ready" then - opponentReady=true - os.queueEvent("kickcoroutine") - elseif cmd=="cointoss" then - myTurn=args=="true" - if myTurn then - setStatusLine(2,"Your turn, take your shot!") - else - setStatusLine(2,"Opponent's turn, waiting...") - end - os.queueEvent("kickcoroutine") - elseif cmd=="shot" then - if myTurn then - setStatusLine(3,"What the?! Got a shot but not their turn! Ignoring") - else - local tx, ty=string.match(args,"(%d+) (%d+)") - tx,ty=tonumber(tx),tonumber(ty) - local tile=myGrid[tx][ty] - local shot=makeShot(tx,ty,myGrid) - rednet.send(opponentID,"bs result "..(shot[3] and "hit" or "miss")) - drawTile(2+tx,3+ty,tile) - myTurn=true - os.queueEvent("kickcoroutine") - displayGameHelp() - setStatusLine(1,opponent.." fired at "..toGridRef(tx,ty).." and "..(shot[3] and "hit" or "missed")) - setStatusLine(2,"Your turn, take your shot!") - end - elseif cmd=="sink" then - setStatusLine(1,"You sank one of "..opponent.."'s ships!") - oppShipsLeft=oppShipsLeft-1 - if oppShipsLeft==0 then - setStatusLine(2,opponent.." has no ships left!") - elseif oppShipsLeft==1 then - setStatusLine(2,"Sink 1 more to win!") - else - setStatusLine(2,"They have "..oppShipsLeft.." ships left.") - end - elseif cmd=="result" then - if not myTurn then - setStatusLine(3,"What the?! Got a shot result but not my turn! Ignoring") - else - local tile=oppGrid[targetX][targetY] - tile.hit=args=="hit" - drawTile(targetX+15,targetY+3,tile) - myTurn=false - doColor(tile.hit and colors.red or colors.white,colors.lightGray) - term.setCursorPos(17,16) - term.write(tile.hit and "HIT!" or "MISS") - setStatusLine(2,"Waiting for opponent...") - os.queueEvent("kickcoroutine") - end - - elseif cmd=="win" then - --we won! - setStatusLine(3,"You won the game! Congratulations!") - break - end - --everything else goes to gameRoutine - else - --all other events go to this routine - local succ,err=coroutine.resume(gameRoutine,e,p1,p2,p3,p4,p5) - if not succ then - print("game coroutine crashed with the following error: "..err) - quit() - end - - if coroutine.status(gameRoutine)=="dead" then - --game over - break - end - end - -end - -term.setCursorPos(1,19) -term.clearLine() -term.write(" Press any key to continue...") -os.pullEvent("key") ---if a char event was queued following the key event, this will eat it -os.sleep(0) - -term.setTextColor(colors.white) -term.setBackgroundColor(colors.black) -term.clear() -quit() +--[[ +battleship, + +by GopherAtl, 2013 + +Do whatever you want, just don't judge me by +what a mess this code is. +--]] +local args={...} +local action=args[1] +local opponentID=nil +local openedSide=nil +local opponent=nil +local myName="" +local opponentReady=false +local myTurn +local targetX,targetY +local shipsLeft=5 +local oppShipsLeft=5 + +local originalTerm = term.current() + +--bounding box of the target grid +local targetGridBounds={ + minX=16, maxX=25, + minY=4, maxY=13 + } + + +local function doColor(text,background) + term.setTextColor(text) + term.setBackgroundColor(background) +end + +local function doColor_mono(text,background) + if text==colors.blue or text==colors.red or text==colors.black or text==colors.lime or background==colors.lightGray then + term.setTextColor(colors.black) + term.setBackgroundColor(colors.white) + else + term.setTextColor(colors.white) + term.setBackgroundColor(colors.black) + end +end + +local function doScreenColor() + if term.isColor() then + doColor(colors.white,colors.lightGray) + else + doColor(colors.black,colors.white) + end +end + +local function toGridRef(x,y) + return string.sub("ABCDEFGHIJ",x,x)..string.sub("1234567890",y,y) +end + + +if not term.isColor() then + doColor=doColor_mono +end + +local function quit() + if openedSide then + rednet.close(openedSide) + end + term.redirect( originalTerm ) + term.setCursorPos(term.getSize()) + print() + error() +end + +local foundModem=false +--find modem +for k,v in pairs(redstone.getSides()) do + if peripheral.getType(v)=="modem" then + foundModem=true + if not rednet.isOpen(v) then + rednet.open(v) + openedSide=v + end + break + end +end + +if not foundModem then + print("You must have a modem to play!") + return +end + +if action==nil or (action~="join" and action~="host") then + print("Invalid parameters. Usage:\n> battleship host\nHosts a game, waits for another computer to join\n> battleship join\nLooks for another game to join") + quit() +end + +--get player name +while true do + doColor(colors.cyan,colors.black) + write("player name: ") + doColor(colors.gray,colors.black) + myName=read() + if myName=="" then + doColor(colors.red,colors.black) + print("You have to give a name!") + elseif #myName>11 then + doColor(colors.red,colors.black) + print("Max name is 11 characters!") + else + break + end +end + +if action=="join" then + print("Attempting to join a game...\n(press q to cancel)") + while true do + local retryTimer=os.startTimer(1); + rednet.broadcast("bs join "..myName); + + while true do + local event,p1,p2,p3=os.pullEvent(); + if event=="rednet_message" then + opponent=string.match(p2,"bs accept %s*(.+)%s*") + if opponent then + opponentID=p1 + break + end + elseif event=="timer" and p1==retryTimer then + break + elseif event=="char" and (p1=="q" or p1=="Q") then + print("Couldn't find an opponent; quitting") + quit() + end + end + local joined=false + + if opponentID then + print("Joining game!") + rednet.send(opponentID,"bs start") + break + end + end +elseif action=="host" then + print("Waiting for challenger...\n(Press q to cancel)") + while true do + while true do + local event,p1,p2=os.pullEvent() + if event=="rednet_message" then + opponent=string.match(p2,"bs join %s*(.+)%s*") if opponent then + print("found player, inviting..") + opponentID=p1 + break + end + elseif event=="char" and (p1=="q" or p1=="Q") then + print("Couldn't find opponent, quitting") + quit() + end + end + + if opponentID then + rednet.send(opponentID,"bs accept "..myName) + local timeout=os.startTimer(1) + while true do + local event,p1,p2=os.pullEvent() + if event=="rednet_message" and p2=="bs start" then + print("player joined!") + break + elseif event=="timer" and p1==timeout then + print("player joined another game. Waiting for another...") + opponentID=nil + break + end + end + + if opponentID then + break + end + end + end +end + +local ships={ + {pos=nil,dir="h",size=5,name="carrier",hits=0}, + {pos=nil,dir="h",size=4,name="battleship",hits=0}, + {pos=nil,dir="h",size=3,name="cruiser",hits=0}, + {pos=nil,dir="h",size=3,name="submarine",hits=0}, + {pos=nil,dir="h",size=2,name="destroyer",hits=0}, +} + +local myShotTable={ {1,1,true},{5,5,false} } +local oppShotTable={ } + +local myGrid,oppGrid={title=myName},{title=opponent} + +--setup grids +for i=1,10 do + myGrid[i]={} + oppGrid[i]={} + for j=1,10 do + myGrid[i][j]={hit=false,ship=false} + oppGrid[i][j]={hit=false,ship=false} + end +end + +local function drawShipsToGrid(ships,grid) + for i=1,#ships do + local x,y=table.unpack(ships[i].pos) + local stepX=ships[i].dir=="h" and 1 or 0 + local stepY=stepX==1 and 0 or 1 + for j=1,ships[i].size do + grid[x][y].ship=i + x,y=x+stepX,y+stepY + end + end +end + +local function drawShotToGrid(shot,grid) + grid[shot[1]][shot[2]].shot=true + grid[shot[1]][shot[2]].hit=shot[3] +end + +local function makeShot(x,y,grid) + local tile=grid[x][y] + if tile.shot==true then + return nil --already shot here! + end + + local shot={x,y,tile.ship} + drawShotToGrid(shot,grid) + if tile.ship then + ships[tile.ship].hits=ships[tile.ship].hits+1 + if ships[tile.ship].hits==ships[tile.ship].size then + os.queueEvent("shipsunk",tile.ship) + end + end + return shot +end + + +local function drawTile(scrX,scrY,tile) + term.setCursorPos(scrX,scrY) + + if tile.ship then + if tile.shot then + doColor(colors.red,colors.gray) + term.write("@") + else + doColor(colors.white,colors.gray) + term.write("O") + end + else + if tile.hit then + doColor(colors.red,colors.gray) + term.write("x") + elseif tile.shot then + doColor(colors.white,colors.lightBlue) + term.write(".") + else + doColor(colors.white,colors.lightBlue) + term.write(" ") + end + end +end + +local function drawGrid(scrX,scrY,grid) + doColor(colors.white,colors.black) + term.setCursorPos(scrX,scrY+1) + term.write(" ") + doColor(colors.white,colors.gray) + term.setCursorPos(scrX,scrY) + local pad=11-#grid.title + term.write(string.rep(" ",math.ceil(pad/2))..grid.title..string.rep(" ",math.floor(pad/2))) + + for gx=1,10 do + term.setTextColor(colors.white) + term.setBackgroundColor(colors.black) + term.setCursorPos(scrX+gx,scrY+1) + term.write(gx==10 and "0" or string.char(string.byte("0")+gx)) + + term.setCursorPos(scrX,scrY+gx+1) + term.write(string.char(string.byte("A")+gx-1)) + for gy=1,10 do + drawTile(scrX+gx,scrY+gy+1,grid[gx][gy]) + end + end + doColor(colors.white,colors.black) +end + +function moveTargetIndicator(newX,newY) + --if x has changed... + if targetX and targetY then + drawTile(targetX+targetGridBounds.minX-1,targetY+targetGridBounds.minY-1,oppGrid[targetX][targetY]) + end + doColor(colors.yellow,colors.lightGray) + if newX~=targetX then + --space over old + if targetX then + term.setCursorPos(targetGridBounds.minX+targetX-1,targetGridBounds.maxY+1) + term.write(" ") + term.setCursorPos(targetGridBounds.minX+targetX-1,targetGridBounds.minY-3) + term.write(" ") + end + --draw new + term.setCursorPos(targetGridBounds.minX+newX-1,targetGridBounds.maxY+1) + term.write("^") + term.setCursorPos(targetGridBounds.minX+newX-1,targetGridBounds.minY-3) + term.write("v") + + targetX=newX + end + if newY~=targetY then + --space over old + if targetY then + term.setCursorPos(targetGridBounds.maxX+1,targetGridBounds.minY+targetY-1) + term.write(" ") + term.setCursorPos(targetGridBounds.minX-2,targetGridBounds.minY+targetY-1) + term.write(" ") + end + --draw new + term.setCursorPos(targetGridBounds.maxX+1,targetGridBounds.minY+newY-1) + term.write("<") + term.setCursorPos(targetGridBounds.minX-2,targetGridBounds.minY+newY-1) + term.write(">") + + targetY=newY + end + term.setCursorPos(15,15) + term.write("Target : "..toGridRef(targetX,targetY)) + --if the target tile is a valid target, draw a "+" + if not oppGrid[targetX][targetY].shot then + term.setCursorPos(targetX+targetGridBounds.minX-1,targetY+targetGridBounds.minY-1) + doColor(colors.yellow,colors.lightBlue) + term.write("+") + end +end + +local log={} + +local termWidth,termHeight=term.getSize() + +local logHeight=termHeight-3 +local logWidth=termWidth-28 + +for i=1,logHeight do + log[i]="" +end + +local function printLog() + doColor(colors.white,colors.black) + for i=1,logHeight do + term.setCursorPos(28,1+i) + local name,line=string.match(log[i],"(<[^>]+> )(.*)") + if name then + doColor(colors.lightBlue,colors.black) + write(name) + doColor(colors.white,colors.black) + write(line..string.rep(" ",logWidth-#log[i])) + else + write(log[i]..string.rep(" ",logWidth-#log[i])) + end + end +end + + + +--shipX/Y are the position of ship on grid; gridX/Y are the offset of the top-left of grid +local function drawShip(size,align,x,y,char) + local stepX=align=="h" and 1 or 0 + local stepY=stepX==1 and 0 or 1 + for j=1,size do + term.setCursorPos(x,y) + term.write(char) + x,y=x+stepX,y+stepY + end +end + +local function setStatusLine(lineNum,text) + doScreenColor() + local pad=math.floor((termWidth-#text)/2) + term.setCursorPos(1,16+lineNum) + term.write((" "):rep(pad)..text..(" "):rep(termWidth-#text-pad)) +end + + +doScreenColor() +term.clear() + +drawGrid(2,2,myGrid) + +setStatusLine(1,"Started game with "..opponent.." at computer #"..(opponentID or "nil")) + +local function getShipBounds(ship) + return { + minX=ship.pos[1], + minY=ship.pos[2], + maxX=ship.pos[1]+(ship.dir=="h" and ship.size-1 or 0), + maxY=ship.pos[2]+(ship.dir=="v" and ship.size-1 or 0) + } +end + +local function getPointBounds(x,y) + return { + minX=x, + minY=y, + maxX=x, + maxY=y, + } +end + +local function boundsIntersect(boundsA,boundsB) + return not ( + boundsA.minX>boundsB.maxX or + boundsA.maxXboundsB.maxY or + boundsA.maxY="a" and p1<="j" then + --row selected + moveTargetIndicator(targetX,string.byte(p1)-string.byte("a")+1) + elseif p1>="0" and p1<="9" then + local t=string.byte(p1)-string.byte("0") + if t==0 then t=10 end + moveTargetIndicator(t,targetY) + end + elseif e=="key" then + if p1==keys.enter or p1==keys.space and targetX and targetY then + local shot=makeShot(targetX,targetY,oppGrid) + if shot then + rednet.send(opponentID,"bs shot "..targetX.." "..targetY) + break + end + elseif p1==keys.up then + moveTargetIndicator(targetX,math.max(targetY-1,1)) + elseif p1==keys.down then + moveTargetIndicator(targetX,math.min(targetY+1,10)) + elseif p1==keys.left then + moveTargetIndicator(math.max(targetX-1,1),targetY) + elseif p1==keys.right then + moveTargetIndicator(math.min(targetX+1,10),targetY) + end + end + end + --shot sent, wait for my turn to resolve (top coroutine will switch turns and draw the hit to the grid) + setStatusLine(2,"Waiting for opponent...") + while myTurn do + os.pullEvent() + end + end +end + +local gameRoutine=coroutine.create(runGame) +--if advanced terminal, default focus to chat, can play with mouse +local inChat=term.isColor() +local savedCursorPos={7,19} + +--redirect just to block scroll +local redir={} +for k,v in pairs(originalTerm) do + if k~="scroll" then + redir[k]=v + else + redir[k]=function() end + end +end +originalTerm = term.redirect(redir) + +--run the game routine once +coroutine.resume(gameRoutine) +--hide cursor +term.setCursorBlink(false) + +while true do + local e,p1,p2,p3,p4,p5=os.pullEventRaw() + if e=="terminate" then + quit() + elseif e=="shipsunk" then + setStatusLine(1,opponent.." sank your "..ships[p1].name.."!") + rednet.send(opponentID,"bs sink") + shipsLeft=shipsLeft-1 + if shipsLeft==1 then + setStatusLine(3,"You only have 1 ship left!") + elseif shipsLeft>1 then + setStatusLine(3,"You have "..shipsLeft.." ships left!") + else + rednet.send(opponentID,"bs win") + setStatusLine(3,"You lost the game!") + break + end + elseif e=="rednet_message" then + local cmd,args=string.match(p2,"^bs (%S+)%s?(.*)") + if cmd=="ready" then + opponentReady=true + os.queueEvent("kickcoroutine") + elseif cmd=="cointoss" then + myTurn=args=="true" + if myTurn then + setStatusLine(2,"Your turn, take your shot!") + else + setStatusLine(2,"Opponent's turn, waiting...") + end + os.queueEvent("kickcoroutine") + elseif cmd=="shot" then + if myTurn then + setStatusLine(3,"What the?! Got a shot but not their turn! Ignoring") + else + local tx, ty=string.match(args,"(%d+) (%d+)") + tx,ty=tonumber(tx),tonumber(ty) + local tile=myGrid[tx][ty] + local shot=makeShot(tx,ty,myGrid) + rednet.send(opponentID,"bs result "..(shot[3] and "hit" or "miss")) + drawTile(2+tx,3+ty,tile) + myTurn=true + os.queueEvent("kickcoroutine") + displayGameHelp() + setStatusLine(1,opponent.." fired at "..toGridRef(tx,ty).." and "..(shot[3] and "hit" or "missed")) + setStatusLine(2,"Your turn, take your shot!") + end + elseif cmd=="sink" then + setStatusLine(1,"You sank one of "..opponent.."'s ships!") + oppShipsLeft=oppShipsLeft-1 + if oppShipsLeft==0 then + setStatusLine(2,opponent.." has no ships left!") + elseif oppShipsLeft==1 then + setStatusLine(2,"Sink 1 more to win!") + else + setStatusLine(2,"They have "..oppShipsLeft.." ships left.") + end + elseif cmd=="result" then + if not myTurn then + setStatusLine(3,"What the?! Got a shot result but not my turn! Ignoring") + else + local tile=oppGrid[targetX][targetY] + tile.hit=args=="hit" + drawTile(targetX+15,targetY+3,tile) + myTurn=false + doColor(tile.hit and colors.red or colors.white,colors.lightGray) + term.setCursorPos(17,16) + term.write(tile.hit and "HIT!" or "MISS") + setStatusLine(2,"Waiting for opponent...") + os.queueEvent("kickcoroutine") + end + + elseif cmd=="win" then + --we won! + setStatusLine(3,"You won the game! Congratulations!") + break + end + --everything else goes to gameRoutine + else + --all other events go to this routine + local succ,err=coroutine.resume(gameRoutine,e,p1,p2,p3,p4,p5) + if not succ then + print("game coroutine crashed with the following error: "..err) + quit() + end + + if coroutine.status(gameRoutine)=="dead" then + --game over + break + end + end + +end + +term.setCursorPos(1,19) +term.clearLine() +term.write(" Press any key to continue...") +os.pullEvent("key") +--if a char event was queued following the key event, this will eat it +os.sleep(0) + +term.setTextColor(colors.white) +term.setBackgroundColor(colors.black) +term.clear() +quit() -- \ No newline at end of file diff --git a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/framebuffer.lua b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/framebuffer.lua index 11f13acac..0d8ac2ae7 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/framebuffer.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/framebuffer.lua @@ -1,159 +1,159 @@ -function new(_sizeX, _sizeY, _color) - local redirect = {buffer = {text = {}, textColor = {}, backColor = {}, cursorX = 1, cursorY = 1, cursorBlink = false, curTextColor = "0", curBackColor = "f", sizeX = _sizeX or 51, sizeY = _sizeY or 19, color = _color}} - redirect.write = function(text) - text = tostring(text) - local pos = redirect.buffer.cursorX - if redirect.buffer.cursorY > redirect.buffer.sizeY or redirect.buffer.cursorY < 1 then - redirect.buffer.cursorX = pos + #text - return - end - local writeText - if pos + #text <= 1 then - --skip entirely. - redirect.buffer.cursorX = pos + #text - return - elseif pos < 1 then - --adjust text to fit on screen starting at one. - writeText = string.sub(text, math.abs(redirect.buffer.cursorX) + 2) - redirect.buffer.cursorX = 1 - elseif pos > redirect.buffer.sizeX then - --if we're off the edge to the right, skip entirely. - redirect.buffer.cursorX = pos + #text - return - else - writeText = text - end - local lineText = redirect.buffer.text[redirect.buffer.cursorY] - local lineColor = redirect.buffer.textColor[redirect.buffer.cursorY] - local lineBack = redirect.buffer.backColor[redirect.buffer.cursorY] - local preStop = redirect.buffer.cursorX - 1 - local preStart = math.min(1, preStop) - local postStart = redirect.buffer.cursorX + string.len(writeText) - local postStop = redirect.buffer.sizeX - redirect.buffer.text[redirect.buffer.cursorY] = string.sub(lineText, preStart, preStop)..writeText..string.sub(lineText, postStart, postStop) - redirect.buffer.textColor[redirect.buffer.cursorY] = string.sub(lineColor, preStart, preStop)..string.rep(redirect.buffer.curTextColor, #writeText)..string.sub(lineColor, postStart, postStop) - redirect.buffer.backColor[redirect.buffer.cursorY] = string.sub(lineBack, preStart, preStop)..string.rep(redirect.buffer.curBackColor, #writeText)..string.sub(lineBack, postStart, postStop) - redirect.buffer.cursorX = pos + string.len(text) - end - redirect.clear = function() - for i=1, redirect.buffer.sizeY do - redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX) - redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) - redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) - end - end - redirect.clearLine = function() - redirect.buffer.text[redirect.buffer.cursorY] = string.rep(" ", redirect.buffer.sizeX) - redirect.buffer.textColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) - redirect.buffer.backColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) - end - redirect.getCursorPos = function() - return redirect.buffer.cursorX, redirect.buffer.cursorY - end - redirect.setCursorPos = function(x, y) - redirect.buffer.cursorX = math.floor(tonumber(x)) or redirect.buffer.cursorX - redirect.buffer.cursorY = math.floor(tonumber(y)) or redirect.buffer.cursorY - end - redirect.setCursorBlink = function(b) - redirect.buffer.cursorBlink = b - end - redirect.getSize = function() - return redirect.buffer.sizeX, redirect.buffer.sizeY - end - redirect.scroll = function(n) - n = tonumber(n) or 1 - if n > 0 then - for i = 1, redirect.buffer.sizeY - n do - if redirect.buffer.text[i + n] then - redirect.buffer.text[i] = redirect.buffer.text[i + n] - redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n] - redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n] - end - end - for i = redirect.buffer.sizeY, redirect.buffer.sizeY - n + 1, -1 do - redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX) - redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) - redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) - end - elseif n < 0 then - for i = redirect.buffer.sizeY, math.abs(n) + 1, -1 do - if redirect.buffer.text[i + n] then - redirect.buffer.text[i] = redirect.buffer.text[i + n] - redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n] - redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n] - end - end - for i = 1, math.abs(n) do - redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX) - redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) - redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) - end - end - end - redirect.setTextColor = function(clr) - if clr and clr <= 32768 and clr >= 1 then - if redirect.buffer.color then - redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) - elseif clr == 1 or clr == 32768 then - redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) - else - return nil, "Colour not supported" - end - end - end - redirect.setTextColour = redirect.setTextColor - redirect.setBackgroundColor = function(clr) - if clr and clr <= 32768 and clr >= 1 then - if redirect.buffer.color then - redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) - elseif clr == 32768 or clr == 1 then - redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) - else - return nil, "Colour not supported" - end - end - end - redirect.setBackgroundColour = redirect.setBackgroundColor - redirect.isColor = function() - return redirect.buffer.color == true - end - redirect.isColour = redirect.isColor - redirect.render = function(inputBuffer) - for i = 1, redirect.buffer.sizeY do - redirect.buffer.text[i] = inputBuffer.text[i] - redirect.buffer.textColor[i] = inputBuffer.textColor[i] - redirect.buffer.backColor[i] = inputBuffer.backColor[i] - end - end - redirect.clear() - return redirect -end - -function draw(buffer, current) - for i=1, buffer.sizeY do - term.setCursorPos(1,i) - if (current and (buffer.text[i] ~= current.text[i] or buffer.textColor[i] ~= current.textColor[i] or buffer.backColor[i] ~= current.backColor[i])) or not current then - local lineEnd = false - local offset = 1 - while not lineEnd do - local textColorString = string.match(string.sub(buffer.textColor[i], offset), string.sub(buffer.textColor[i], offset, offset).."*") - local backColorString = string.match(string.sub(buffer.backColor[i], offset), string.sub(buffer.backColor[i], offset, offset).."*") - term.setTextColor(2 ^ tonumber(string.sub(textColorString, 1, 1), 16)) - term.setBackgroundColor(2 ^ tonumber(string.sub(backColorString, 1, 1), 16)) - term.write(string.sub(buffer.text[i], offset, offset + math.min(#textColorString, #backColorString) - 1)) - offset = offset + math.min(#textColorString, #backColorString) - if offset > buffer.sizeX then lineEnd = true end - end - if current then - current.text[i] = buffer.text[i] - current.textColor[i] = buffer.textColor[i] - current.backColor[i] = buffer.backColor[i] - end - end - end - term.setCursorPos(buffer.cursorX, buffer.cursorY) - term.setTextColor(2 ^ tonumber(buffer.curTextColor, 16)) - term.setBackgroundColor(2 ^ tonumber(buffer.curBackColor, 16)) - term.setCursorBlink(buffer.cursorBlink) - return current -end +function new(_sizeX, _sizeY, _color) + local redirect = {buffer = {text = {}, textColor = {}, backColor = {}, cursorX = 1, cursorY = 1, cursorBlink = false, curTextColor = "0", curBackColor = "f", sizeX = _sizeX or 51, sizeY = _sizeY or 19, color = _color}} + redirect.write = function(text) + text = tostring(text) + local pos = redirect.buffer.cursorX + if redirect.buffer.cursorY > redirect.buffer.sizeY or redirect.buffer.cursorY < 1 then + redirect.buffer.cursorX = pos + #text + return + end + local writeText + if pos + #text <= 1 then + --skip entirely. + redirect.buffer.cursorX = pos + #text + return + elseif pos < 1 then + --adjust text to fit on screen starting at one. + writeText = string.sub(text, math.abs(redirect.buffer.cursorX) + 2) + redirect.buffer.cursorX = 1 + elseif pos > redirect.buffer.sizeX then + --if we're off the edge to the right, skip entirely. + redirect.buffer.cursorX = pos + #text + return + else + writeText = text + end + local lineText = redirect.buffer.text[redirect.buffer.cursorY] + local lineColor = redirect.buffer.textColor[redirect.buffer.cursorY] + local lineBack = redirect.buffer.backColor[redirect.buffer.cursorY] + local preStop = redirect.buffer.cursorX - 1 + local preStart = math.min(1, preStop) + local postStart = redirect.buffer.cursorX + string.len(writeText) + local postStop = redirect.buffer.sizeX + redirect.buffer.text[redirect.buffer.cursorY] = string.sub(lineText, preStart, preStop)..writeText..string.sub(lineText, postStart, postStop) + redirect.buffer.textColor[redirect.buffer.cursorY] = string.sub(lineColor, preStart, preStop)..string.rep(redirect.buffer.curTextColor, #writeText)..string.sub(lineColor, postStart, postStop) + redirect.buffer.backColor[redirect.buffer.cursorY] = string.sub(lineBack, preStart, preStop)..string.rep(redirect.buffer.curBackColor, #writeText)..string.sub(lineBack, postStart, postStop) + redirect.buffer.cursorX = pos + string.len(text) + end + redirect.clear = function() + for i=1, redirect.buffer.sizeY do + redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX) + redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) + redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) + end + end + redirect.clearLine = function() + redirect.buffer.text[redirect.buffer.cursorY] = string.rep(" ", redirect.buffer.sizeX) + redirect.buffer.textColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) + redirect.buffer.backColor[redirect.buffer.cursorY] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) + end + redirect.getCursorPos = function() + return redirect.buffer.cursorX, redirect.buffer.cursorY + end + redirect.setCursorPos = function(x, y) + redirect.buffer.cursorX = math.floor(tonumber(x)) or redirect.buffer.cursorX + redirect.buffer.cursorY = math.floor(tonumber(y)) or redirect.buffer.cursorY + end + redirect.setCursorBlink = function(b) + redirect.buffer.cursorBlink = b + end + redirect.getSize = function() + return redirect.buffer.sizeX, redirect.buffer.sizeY + end + redirect.scroll = function(n) + n = tonumber(n) or 1 + if n > 0 then + for i = 1, redirect.buffer.sizeY - n do + if redirect.buffer.text[i + n] then + redirect.buffer.text[i] = redirect.buffer.text[i + n] + redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n] + redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n] + end + end + for i = redirect.buffer.sizeY, redirect.buffer.sizeY - n + 1, -1 do + redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX) + redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) + redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) + end + elseif n < 0 then + for i = redirect.buffer.sizeY, math.abs(n) + 1, -1 do + if redirect.buffer.text[i + n] then + redirect.buffer.text[i] = redirect.buffer.text[i + n] + redirect.buffer.textColor[i] = redirect.buffer.textColor[i + n] + redirect.buffer.backColor[i] = redirect.buffer.backColor[i + n] + end + end + for i = 1, math.abs(n) do + redirect.buffer.text[i] = string.rep(" ", redirect.buffer.sizeX) + redirect.buffer.textColor[i] = string.rep(redirect.buffer.curTextColor, redirect.buffer.sizeX) + redirect.buffer.backColor[i] = string.rep(redirect.buffer.curBackColor, redirect.buffer.sizeX) + end + end + end + redirect.setTextColor = function(clr) + if clr and clr <= 32768 and clr >= 1 then + if redirect.buffer.color then + redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) + elseif clr == 1 or clr == 32768 then + redirect.buffer.curTextColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) + else + return nil, "Colour not supported" + end + end + end + redirect.setTextColour = redirect.setTextColor + redirect.setBackgroundColor = function(clr) + if clr and clr <= 32768 and clr >= 1 then + if redirect.buffer.color then + redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) + elseif clr == 32768 or clr == 1 then + redirect.buffer.curBackColor = string.format("%x", math.floor(math.log(clr) / math.log(2))) + else + return nil, "Colour not supported" + end + end + end + redirect.setBackgroundColour = redirect.setBackgroundColor + redirect.isColor = function() + return redirect.buffer.color == true + end + redirect.isColour = redirect.isColor + redirect.render = function(inputBuffer) + for i = 1, redirect.buffer.sizeY do + redirect.buffer.text[i] = inputBuffer.text[i] + redirect.buffer.textColor[i] = inputBuffer.textColor[i] + redirect.buffer.backColor[i] = inputBuffer.backColor[i] + end + end + redirect.clear() + return redirect +end + +function draw(buffer, current) + for i=1, buffer.sizeY do + term.setCursorPos(1,i) + if (current and (buffer.text[i] ~= current.text[i] or buffer.textColor[i] ~= current.textColor[i] or buffer.backColor[i] ~= current.backColor[i])) or not current then + local lineEnd = false + local offset = 1 + while not lineEnd do + local textColorString = string.match(string.sub(buffer.textColor[i], offset), string.sub(buffer.textColor[i], offset, offset).."*") + local backColorString = string.match(string.sub(buffer.backColor[i], offset), string.sub(buffer.backColor[i], offset, offset).."*") + term.setTextColor(2 ^ tonumber(string.sub(textColorString, 1, 1), 16)) + term.setBackgroundColor(2 ^ tonumber(string.sub(backColorString, 1, 1), 16)) + term.write(string.sub(buffer.text[i], offset, offset + math.min(#textColorString, #backColorString) - 1)) + offset = offset + math.min(#textColorString, #backColorString) + if offset > buffer.sizeX then lineEnd = true end + end + if current then + current.text[i] = buffer.text[i] + current.textColor[i] = buffer.textColor[i] + current.backColor[i] = buffer.backColor[i] + end + end + end + term.setCursorPos(buffer.cursorX, buffer.cursorY) + term.setTextColor(2 ^ tonumber(buffer.curTextColor, 16)) + term.setBackgroundColor(2 ^ tonumber(buffer.curBackColor, 16)) + term.setCursorBlink(buffer.cursorBlink) + return current +end diff --git a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/get.lua b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/get.lua index 5db52061f..6c95fbd6d 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/get.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/get.lua @@ -1,26 +1,26 @@ -if not nsh then print("No nsh session!") return end - -local args = {...} - -if #args < 2 then - print("Usage: get ") - print(": any file on the server") - print(": any non-existant file on the client") - return -end - -if fs.exists(args[1]) then - nsh.send("FS:;t="..args[2]) - local message = nsh.receive() - if message == "FR:;ok" then - nsh.send("FH:;"..args[1]) - local handle = io.open(args[1], "r") - if handle then - nsh.send("FD:;t="..handle:read("*a")) - handle:close() - end - nsh.send("FE:;end") - else - print("Client rejected file!") - end +if not nsh then print("No nsh session!") return end + +local args = {...} + +if #args < 2 then + print("Usage: get ") + print(": any file on the server") + print(": any non-existant file on the client") + return +end + +if fs.exists(args[1]) then + nsh.send("FS:;t="..args[2]) + local message = nsh.receive() + if message == "FR:;ok" then + nsh.send("FH:;"..args[1]) + local handle = io.open(args[1], "r") + if handle then + nsh.send("FD:;t="..handle:read("*a")) + handle:close() + end + nsh.send("FE:;end") + else + print("Client rejected file!") + end end \ No newline at end of file diff --git a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/nsh.lua b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/nsh.lua index 8d1bc35f3..a76aba8d6 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/nsh.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/nsh.lua @@ -1,721 +1,721 @@ -local args = { ... } - -local connections = {} - -local nshAPI = { - connList = connections -} - -if not framebuffer then if not ((fs.exists("framebuffer") and os.loadAPI("framebuffer")) or (fs.exists("LyqydOS/framebuffer") and os.loadAPI("LyqydOS/framebuffer"))) then print("Couldn't find framebuffer API, using fallback") end end - -local function rawSend(id, msg) - if term.current then - return rednet.send(id, msg, "tror") - else - return rednet.send(id, msg) - end -end - -local function rawRecv(id, timeout) - if type(timeout) == "number" then timeout = os.startTimer(timeout) end - while true do - event = {os.pullEvent()} - if event[1] == "rednet_message" and (id == nil and true or event[2] == id) and (not term.current and true or event[4] == "tror") then - return event[3] - elseif event[1] == "timer" and event[2] == timeout then - return nil - end - end -end - - -nshAPI.getRemoteID = function() - --check for connected clients with matching threads. - for cNum, cInfo in pairs(nshAPI.connList) do - if cInfo.thread == coroutine.running() then - if cNum == "localShell" then - --if we are a client running on the server, return the remote server ID. - if nshAPI.serverNum then - return nshAPI.serverNum - else - return nil - end - end - return cNum - end - end - --client running without local server, return remote server ID. - if nshAPI.serverNum then return nshAPI.serverNum end - return nil -end - -nshAPI.send = function(msg) - local id = nshAPI.getRemoteID() - if id then - return rawSend(id, msg) - end - return nil -end - -nshAPI.receive = function(timeout) - return rawRecv(nshAPI.getRemoteID(), timeout) -end - -nshAPI.getClientCapabilities = function() - if nshAPI.clientCapabilities then return nshAPI.clientCapabilities end - nshAPI.send("SP:;clientCapabilities") - return nshAPI.receive(1) -end - -nshAPI.getRemoteConnections = function() - local remotes = {} - for cNum, cInfo in pairs(nshAPI.connList) do - table.insert(remotes, cNum) - if cInfo.outbound then - table.insert(remotes, cInfo.outbound) - end - end - return remotes -end - -nshAPI.packFile = function(path) - local data = {} - local count = 0 - local handle = io.open(path, "rb") - if handle then - local byte = handle:read() - repeat - data[#data + 1] = byte - count = count + 1 - if count % 1000 == 0 then - os.queueEvent("yield") - os.pullEvent("yield") - end - byte = handle:read() - until not byte - handle:close() - else - return false - end - local outputTable = {} - for i = 1, #data, 3 do - local num1, num2, num3 = data[i], data[i + 1] or 0, data[i + 2] or 0 - table.insert(outputTable, string.char(bit32.band(bit32.arshift(num1, 2), 63))) - table.insert(outputTable, string.char(bit32.bor(bit32.band(bit32.lshift(num1, 4), 48), bit32.band(bit32.arshift(num2, 4), 15)))) - table.insert(outputTable, string.char(bit32.bor(bit32.band(bit32.lshift(num2, 2), 60), bit32.band(bit32.arshift(num3, 6), 3)))) - table.insert(outputTable, string.char(bit32.band(num3, 63))) - end - --mark non-data (invalid) bytes - if #data % 3 == 1 then - outputTable[#outputTable] = "=" - outputTable[#outputTable - 1] = "=" - elseif #data % 3 == 2 then - outputTable[#outputTable] = "=" - end - return table.concat(outputTable, "") -end - -nshAPI.unpackAndSaveFile = function(path, data) - local outputTable = {} - for i=1, #data, 4 do - local char1, char2, char3, char4 = string.byte(string.sub(data, i, i)), string.byte(string.sub(data, i + 1, i + 1)), string.byte(string.sub(data, i + 2, i + 2)), string.byte(string.sub(data, i + 3, i + 3)) - table.insert(outputTable, bit32.band(bit32.bor(bit32.lshift(char1, 2), bit32.arshift(char2, 4)), 255)) - table.insert(outputTable, bit32.band(bit32.bor(bit32.lshift(char2, 4), bit32.arshift(char3, 2)), 255)) - table.insert(outputTable, bit32.band(bit32.bor(bit32.lshift(char3, 6), char4), 255)) - end - --clean invalid bytes if marked - if string.sub(data, #data, #data) == "=" then - table.remove(outputTable) - if string.sub(data, #data - 1, #data - 1) == "=" then - table.remove(outputTable) - end - end - local handle = io.open(path, "wb") - if handle then - for i = 1, #outputTable do - handle:write(outputTable[i]) - if i % 10 == 0 then - os.startTimer(0.1) - os.pullEvent("timer") - end - end - handle:close() - end -end - -local packetConversion = { - query = "SQ", - response = "SR", - data = "SP", - close = "SC", - fileQuery = "FQ", - fileSend = "FS", - fileResponse = "FR", - fileHeader = "FH", - fileData = "FD", - fileEnd = "FE", - textWrite = "TW", - textCursorPos = "TC", - textGetCursorPos = "TG", - textGetSize = "TD", - textInfo = "TI", - textClear = "TE", - textClearLine = "TL", - textScroll = "TS", - textBlink = "TB", - textColor = "TF", - textBackground = "TK", - textIsColor = "TA", - textTable = "TT", - event = "EV", - SQ = "query", - SR = "response", - SP = "data", - SC = "close", - FQ = "fileQuery", - FS = "fileSend", - FR = "fileResponse", - FH = "fileHeader", - FD = "fileData", - FE = "fileEnd", - TW = "textWrite", - TC = "textCursorPos", - TG = "textGetCursorPos", - TD = "textGetSize", - TI = "textInfo", - TE = "textClear", - TL = "textClearLine", - TS = "textScroll", - TB = "textBlink", - TF = "textColor", - TK = "textBackground", - TA = "textIsColor", - TT = "textTable", - EV = "event", -} - -local function openModem() - local modemFound = false - for _, side in ipairs(rs.getSides()) do - if peripheral.getType(side) == "modem" then - if not rednet.isOpen(side) then rednet.open(side) end - modemFound = true - break - end - end - return modemFound -end - -local function send(id, pType, message) - if pType and message then - return rawSend(id, packetConversion[pType]..":;"..message) - end -end - -local function awaitResponse(id, time) - id = tonumber(id) - local listenTimeOut = nil - local messRecv = false - if time then listenTimeOut = os.startTimer(time) end - while not messRecv do - local event, p1, p2 = os.pullEvent() - if event == "timer" and p1 == listenTimeOut then - return false - elseif event == "rednet_message" then - sender, message = p1, p2 - if id == sender and message then - if packetConversion[string.sub(message, 1, 2)] then packetType = packetConversion[string.sub(message, 1, 2)] end - message = string.match(message, ";(.*)") - messRecv = true - end - end - end - return packetType, message -end - -local function processText(conn, pType, value) - if not pType then return false end - if pType == "textWrite" and value then - term.write(value) - elseif pType == "textClear" then - term.clear() - elseif pType == "textClearLine" then - term.clearLine() - elseif pType == "textGetCursorPos" then - local x, y = term.getCursorPos() - send(conn, "textInfo", math.floor(x)..","..math.floor(y)) - elseif pType == "textCursorPos" then - local x, y = string.match(value, "(%-?%d+),(%-?%d+)") - term.setCursorPos(tonumber(x), tonumber(y)) - elseif pType == "textBlink" then - if value == "true" then - term.setCursorBlink(true) - else - term.setCursorBlink(false) - end - elseif pType == "textGetSize" then - x, y = term.getSize() - send(conn, "textInfo", x..","..y) - elseif pType == "textScroll" and value then - term.scroll(tonumber(value)) - elseif pType == "textIsColor" then - send(conn, "textInfo", tostring(term.isColor())) - elseif pType == "textColor" and value then - value = tonumber(value) - if (value == 1 or value == 32768) or term.isColor() then - term.setTextColor(value) - end - elseif pType == "textBackground" and value then - value = tonumber(value) - if (value == 1 or value == 32768) or term.isColor() then - term.setBackgroundColor(value) - end - elseif pType == "textTable" then - local linesTable = textutils.unserialize(value) - for i=1, linesTable.sizeY do - term.setCursorPos(1,i) - local lineEnd = false - local offset = 1 - while not lineEnd do - local textColorString = string.match(string.sub(linesTable.textColor[i], offset), string.sub(linesTable.textColor[i], offset, offset).."*") - local backColorString = string.match(string.sub(linesTable.backColor[i], offset), string.sub(linesTable.backColor[i], offset, offset).."*") - term.setTextColor(2 ^ tonumber(string.sub(textColorString, 1, 1), 16)) - term.setBackgroundColor(2 ^ tonumber(string.sub(backColorString, 1, 1), 16)) - term.write(string.sub(linesTable.text[i], offset, offset + math.min(#textColorString, #backColorString) - 1)) - offset = offset + math.min(#textColorString, #backColorString) - if offset > linesTable.sizeX then lineEnd = true end - end - end - term.setCursorPos(linesTable.cursorX, linesTable.cursorY) - term.setCursorBlink(linesTable.cursorBlink) - end - return -end - -local function textRedirect(id) - local textTable = {} - textTable.id = id - textTable.write = function(text) - return send(textTable.id, "textWrite", text) - end - textTable.clear = function() - return send(textTable.id, "textClear", "nil") - end - textTable.clearLine = function() - return send(textTable.id, "textClearLine", "nil") - end - textTable.getCursorPos = function() - send(textTable.id, "textGetCursorPos", "nil") - local pType, message = awaitResponse(textTable.id, 2) - if pType and pType == "textInfo" then - local x, y = string.match(message, "(%-?%d+),(%-?%d+)") - return tonumber(x), tonumber(y) - end - end - textTable.setCursorPos = function(x, y) - return send(textTable.id, "textCursorPos", math.floor(x)..","..math.floor(y)) - end - textTable.setCursorBlink = function(b) - if b then - return send(textTable.id, "textBlink", "true") - else - return send(textTable.id, "textBlink", "false") - end - end - textTable.getSize = function() - send(textTable.id, "textGetSize", "nil") - local pType, message = awaitResponse(textTable.id, 2) - if pType and pType == "textInfo" then - local x, y = string.match(message, "(%d+),(%d+)") - return tonumber(x), tonumber(y) - end - end - textTable.scroll = function(lines) - return send(textTable.id, "textScroll", lines) - end - textTable.isColor = function() - send(textTable.id, "textIsColor", "nil") - local pType, message = awaitResponse(textTable.id, 2) - if pType and pType == "textInfo" then - if message == "true" then - return true - end - end - return false - end - textTable.isColour = textTable.isColor - textTable.setTextColor = function(color) - return send(textTable.id, "textColor", tostring(color)) - end - textTable.setTextColour = textTable.setTextColor - textTable.setBackgroundColor = function(color) - return send(textTable.id, "textBackground", tostring(color)) - end - textTable.setBackgroundColour = textTable.setBackgroundColor - return textTable -end - -local function getServerID(server) - if tonumber(server) then - return tonumber(server) - elseif term.current then - return rednet.lookup("tror", args[1]) - end -end - -local function resumeThread(conn, event) - local cInfo = connections[conn] - if not connections[conn].filter or event[1] == connections[conn].filter then - connections[conn].filter = nil - local _oldTerm = term.redirect(connections[conn].target) - local passback = {coroutine.resume(connections[conn].thread, table.unpack(event))} - if passback[1] and passback[2] then - connections[conn].filter = passback[2] - end - if coroutine.status(connections[conn].thread) == "dead" then - send(conn, "close", "disconnect") - connections[conn] = nil - end - if _oldTerm then - term.redirect(_oldTerm) - else - term.restore() - end - if connections[conn] and conn ~= "localShell" and framebuffer then - send(conn, "textTable", textutils.serialize(connections[conn].target.buffer)) - end - end -end - -local eventFilter = { - key = true, - char = true, - mouse_click = true, - mouse_drag = true, - mouse_scroll = true, -} - -local function newSession(conn, x, y, color) - local session = {} - local path = "/rom/programs/shell" - if #args >= 2 and shell.resolveProgram(args[2]) then path = shell.resolveProgram(args[2]) end - session.thread = coroutine.create(function() shell.run(path) end) - if framebuffer then - session.target = framebuffer.new(x, y, color) - else - session.target = textRedirect(conn) - end - session.status = "open" - _oldTerm = term.redirect(session.target) - coroutine.resume(session.thread) - if _oldTerm then - term.redirect(_oldTerm) - else - term.restore() - end - if framebuffer then - send(conn, "textTable", textutils.serialize(session.target.buffer)) - end - return session -end - -if #args >= 1 and args[1] == "host" then - _G.nsh = nshAPI - if not openModem() then return end - if term.current then - if args[4] then - rednet.host("tror", args[4]) - elseif os.getComputerLabel() then - rednet.host("tror", os.getComputerLabel()) - else - print("No label or hostname provided!") - return - end - end - local connInfo = {} - connInfo.target = term.current and term.current() or term.native - local path = "/rom/programs/shell" - if #args >= 3 and shell.resolveProgram(args[3]) then path = shell.resolveProgram(args[3]) end - connInfo.thread = coroutine.create(function() shell.run(path) end) - connections.localShell = connInfo - term.clear() - term.setCursorPos(1,1) - coroutine.resume(connections.localShell.thread) - - while true do - event = {os.pullEventRaw()} - if event[1] == "rednet_message" then - if type(event[3]) == "string" and packetConversion[string.sub(event[3], 1, 2)] then - --this is a packet meant for us. - conn = event[2] - packetType = packetConversion[string.sub(event[3], 1, 2)] - message = string.match(event[3], ";(.*)") - if connections[conn] and connections[conn].status == "open" then - if packetType == "event" or string.sub(packetType, 1, 4) == "text" then - local eventTable = {} - if packetType == "event" then - eventTable = textutils.unserialize(message) - else - --we can pass the packet in raw, since this is not an event packet. - eventTable = event - end - resumeThread(conn, eventTable) - elseif packetType == "query" then - local connType, color, x, y = string.match(message, "(%a+):(%a+);(%d+),(%d+)") - if connType == "connect" or (connType == "resume" and (not framebuffer)) then - --reset connection - send(conn, "response", "OK") - connections[conn] = newSession(conn, tonumber(x), tonumber(y), color == "true") - elseif connType == "resume" then - --restore connection - send(conn, "response", "OK") - send(conn, "textTable", textutils.serialize(connections[conn].target.buffer)) - end - elseif packetType == "close" then - connections[conn] = nil - send(conn, "close", "disconnect") - --close connection - else - --we got a packet, have an open connection, but despite it being in the conversion table, don't handle it ourselves. Send it onward. - resumeThread(conn, event) - end - elseif packetType ~= "query" then - --usually, we would send a disconnect here, but this prevents one from hosting nsh and connecting to other computers. Pass these to all shells as well. - for cNum, cInfo in pairs(connections) do - resumeThread(cNum, event) - end - else - --open new connection - send(conn, "response", "OK") - local color, x, y = string.match(message, "connect:(%a+);(%d+),(%d+)") - local connInfo = newSession(conn, tonumber(x), tonumber(y), color == "true") - connections[conn] = connInfo - end - else - --rednet message, but not in the correct format, so pass to all shells. - for cNum, cInfo in pairs(connections) do - resumeThread(cNum, event) - end - end - elseif eventFilter[event[1]] then - --user interaction. - coroutine.resume(connections.localShell.thread, table.unpack(event)) - if coroutine.status(connections.localShell.thread) == "dead" then - for cNum, cInfo in pairs(connections) do - if cNum ~= "localShell" then - send(cNum, "close", "disconnect") - end - end - return - end - else - --dispatch all other events to all shells - for cNum, cInfo in pairs(connections) do - resumeThread(cNum, event) - end - end - end - -elseif #args <= 2 and nsh and nsh.getRemoteID() then - print(nsh.getRemoteID()) - --forwarding mode - local conns = nsh.getRemoteConnections() - for i = 1, #conns do - if conns[i] == serverNum then - print("Cyclic connection refused.") - return - end - end - local fileTransferState = nil - local fileData = nil - local serverNum = getServerID(args[1]) - if not serverNum then - print("Server Not Found") - return - end - send(serverNum, "query", "connect") - local pType, message = awaitResponse(serverNum, 2) - if pType ~= "response" then - print("Connection Failed") - return - else - nsh.connList[nsh.getRemoteID()].outbound = serverNum - term.clear() - term.setCursorPos(1,1) - end - local clientID = nsh.getRemoteID() - local serverID = tonumber(args[1]) - while true do - event = {os.pullEvent()} - if event[1] == "rednet_message" then - if event[2] == clientID or event[2] == serverID then - if event[2] == serverID and string.sub(event[3], 1, 2) == "SC" then break end - rednet.send((event[2] == clientID and serverID or clientID), event[3]) - end - elseif eventFilter[event[1]] then - rednet.send(serverID, "EV:;"..textutils.serialize(event)) - end - end - nsh.connList[nsh.getRemoteID()].outbound = nil - term.clear() - term.setCursorPos(1, 1) - print("Connection closed by server") - -elseif #args >= 1 then --either no server running or we are the local shell on the server. - if not openModem() then return end - local serverNum = getServerID(args[1]) - if not serverNum then - print("Server Not Found") - return - end - if nsh then - local conns = nsh.getRemoteConnections() - for i = 1, #conns do - if conns[i] == serverNum then - print("Connection refused.") - return - end - end - end - local fileTransferState = nil - local fileData = nil - local fileBinaryData = nil - local unpackCo = {} - local color = term.isColor() - local x, y = term.getSize() - if args[2] == "resume" then - send(serverNum, "query", "resume:"..tostring(color)..";"..tostring(x)..","..tostring(y)) - else - send(serverNum, "query", "connect:"..tostring(color)..";"..tostring(x)..","..tostring(y)) - end - local timeout = os.startTimer(2) - while true do - local event = {os.pullEvent()} - if event[1] == "timer" and event[2] == timeout then - print("Connection failed.") - return - elseif event[1] == "rednet_message" and event[2] == serverNum and string.sub(event[3], 1, 2) == "SR" then - if nsh then nshAPI = nsh end - if nshAPI.connList and nshAPI.connList.localShell then nshAPI.connList.localShell.outbound = serverNum end - nshAPI.serverNum = serverNum - nshAPI.clientCapabilities = "-fileTransfer-extensions-" - term.clear() - term.setCursorPos(1,1) - break - end - end - - while true do - event = {os.pullEventRaw()} - if #unpackCo > 0 then - for i = #unpackCo, 1, -1 do - if coroutine.status(unpackCo[i]) ~= "dead" then - coroutine.resume(unpackCo[i], table.unpack(event)) - else - table.remove(unpackCo, i) - end - end - end - if event[1] == "rednet_message" and event[2] == serverNum then - if packetConversion[string.sub(event[3], 1, 2)] then - packetType = packetConversion[string.sub(event[3], 1, 2)] - message = string.match(event[3], ";(.*)") - if string.sub(packetType, 1, 4) == "text" then - processText(serverNum, packetType, message) - elseif packetType == "data" then - if message == "clientCapabilities" then - rednet.send(serverNum, nshAPI.clientCapabilities) - end - elseif packetType == "fileQuery" then - --send a file to the server - local mode, file = string.match(message, "^(%a)=(.*)") - if fs.exists(file) then - send(serverNum, "fileHeader", file) - if mode == "b" then - local fileString = nshAPI.packFile(file) - send(serverNum, "fileData", "b="..fileString) - else - local handle = io.open(file, "r") - if handle then - send(serverNum, "fileData", "t="..handle:read("*a")) - handle:close() - end - end - else - send(serverNum, "fileHeader", "fileNotFound") - end - send(serverNum, "fileEnd", "end") - elseif packetType == "fileSend" then - --receive a file from the server, but don't overwrite existing files. - local mode, file = string.match(message, "^(%a)=(.*)") - if not fs.exists(file) then - fileTransferState = "receive_wait:"..file - send(serverNum, "fileResponse", "ok") - if mode == "b" then - fileBinaryData = "" - fileData = nil - else - fileData = "" - fileBinaryData = nil - end - else - send(serverNum, "fileResponse", "reject") - end - elseif packetType == "fileHeader" then - if message == "fileNotFound" then - fileTransferState = nil - end - elseif packetType == "fileData" then - if fileTransferState and string.match(fileTransferState, "(.-):") == "receive_wait" then - if string.match(message, "^(%a)=") == "b" then - fileBinaryData = fileBinaryData..string.match(message, "^b=(.*)") - else - fileData = fileData..string.match(message, "^t=(.*)") - end - end - elseif packetType == "fileEnd" then - if fileTransferState and string.match(fileTransferState, "(.-):") == "receive_wait" then - if fileBinaryData then - local co = coroutine.create(nshAPI.unpackAndSaveFile) - coroutine.resume(co, string.match(fileTransferState, ":(.*)"), fileBinaryData) - if coroutine.status(co) ~= "dead" then - table.insert(unpackCo, co) - end - elseif fileData then - local handle = io.open(string.match(fileTransferState, ":(.*)"), "w") - if handle then - handle:write(fileData) - handle:close() - end - end - fileTransferState = nil - end - elseif packetType == "close" then - if term.isColor() then - term.setBackgroundColor(colors.black) - term.setTextColor(colors.white) - end - term.clear() - term.setCursorPos(1, 1) - print("Connection closed by server.") - nshAPI.serverNum = nil - if nshAPI.connList and nshAPI.connList.localShell then nshAPI.connList.localShell.outbound = nil end - return - end - end - elseif event[1] == "mouse_click" or event[1] == "mouse_drag" or event[1] == "mouse_scroll" or event[1] == "key" or event[1] == "char" then - --pack up event - send(serverNum, "event", textutils.serialize(event)) - elseif event[1] == "terminate" then - nshAPI.serverNum = nil - if nshAPI.localShell then nshAPI.localShell.outbound = nil end - term.clear() - term.setCursorPos(1, 1) - print("Connection closed locally.") - return - end - end -else - print("Usage: nsh [resume]") - print(" nsh host [remote [local [name]]]") +local args = { ... } + +local connections = {} + +local nshAPI = { + connList = connections +} + +if not framebuffer then if not ((fs.exists("framebuffer") and os.loadAPI("framebuffer")) or (fs.exists("LyqydOS/framebuffer") and os.loadAPI("LyqydOS/framebuffer"))) then print("Couldn't find framebuffer API, using fallback") end end + +local function rawSend(id, msg) + if term.current then + return rednet.send(id, msg, "tror") + else + return rednet.send(id, msg) + end +end + +local function rawRecv(id, timeout) + if type(timeout) == "number" then timeout = os.startTimer(timeout) end + while true do + event = {os.pullEvent()} + if event[1] == "rednet_message" and (id == nil and true or event[2] == id) and (not term.current and true or event[4] == "tror") then + return event[3] + elseif event[1] == "timer" and event[2] == timeout then + return nil + end + end +end + + +nshAPI.getRemoteID = function() + --check for connected clients with matching threads. + for cNum, cInfo in pairs(nshAPI.connList) do + if cInfo.thread == coroutine.running() then + if cNum == "localShell" then + --if we are a client running on the server, return the remote server ID. + if nshAPI.serverNum then + return nshAPI.serverNum + else + return nil + end + end + return cNum + end + end + --client running without local server, return remote server ID. + if nshAPI.serverNum then return nshAPI.serverNum end + return nil +end + +nshAPI.send = function(msg) + local id = nshAPI.getRemoteID() + if id then + return rawSend(id, msg) + end + return nil +end + +nshAPI.receive = function(timeout) + return rawRecv(nshAPI.getRemoteID(), timeout) +end + +nshAPI.getClientCapabilities = function() + if nshAPI.clientCapabilities then return nshAPI.clientCapabilities end + nshAPI.send("SP:;clientCapabilities") + return nshAPI.receive(1) +end + +nshAPI.getRemoteConnections = function() + local remotes = {} + for cNum, cInfo in pairs(nshAPI.connList) do + table.insert(remotes, cNum) + if cInfo.outbound then + table.insert(remotes, cInfo.outbound) + end + end + return remotes +end + +nshAPI.packFile = function(path) + local data = {} + local count = 0 + local handle = io.open(path, "rb") + if handle then + local byte = handle:read() + repeat + data[#data + 1] = byte + count = count + 1 + if count % 1000 == 0 then + os.queueEvent("yield") + os.pullEvent("yield") + end + byte = handle:read() + until not byte + handle:close() + else + return false + end + local outputTable = {} + for i = 1, #data, 3 do + local num1, num2, num3 = data[i], data[i + 1] or 0, data[i + 2] or 0 + table.insert(outputTable, string.char(bit32.band(bit32.arshift(num1, 2), 63))) + table.insert(outputTable, string.char(bit32.bor(bit32.band(bit32.lshift(num1, 4), 48), bit32.band(bit32.arshift(num2, 4), 15)))) + table.insert(outputTable, string.char(bit32.bor(bit32.band(bit32.lshift(num2, 2), 60), bit32.band(bit32.arshift(num3, 6), 3)))) + table.insert(outputTable, string.char(bit32.band(num3, 63))) + end + --mark non-data (invalid) bytes + if #data % 3 == 1 then + outputTable[#outputTable] = "=" + outputTable[#outputTable - 1] = "=" + elseif #data % 3 == 2 then + outputTable[#outputTable] = "=" + end + return table.concat(outputTable, "") +end + +nshAPI.unpackAndSaveFile = function(path, data) + local outputTable = {} + for i=1, #data, 4 do + local char1, char2, char3, char4 = string.byte(string.sub(data, i, i)), string.byte(string.sub(data, i + 1, i + 1)), string.byte(string.sub(data, i + 2, i + 2)), string.byte(string.sub(data, i + 3, i + 3)) + table.insert(outputTable, bit32.band(bit32.bor(bit32.lshift(char1, 2), bit32.arshift(char2, 4)), 255)) + table.insert(outputTable, bit32.band(bit32.bor(bit32.lshift(char2, 4), bit32.arshift(char3, 2)), 255)) + table.insert(outputTable, bit32.band(bit32.bor(bit32.lshift(char3, 6), char4), 255)) + end + --clean invalid bytes if marked + if string.sub(data, #data, #data) == "=" then + table.remove(outputTable) + if string.sub(data, #data - 1, #data - 1) == "=" then + table.remove(outputTable) + end + end + local handle = io.open(path, "wb") + if handle then + for i = 1, #outputTable do + handle:write(outputTable[i]) + if i % 10 == 0 then + os.startTimer(0.1) + os.pullEvent("timer") + end + end + handle:close() + end +end + +local packetConversion = { + query = "SQ", + response = "SR", + data = "SP", + close = "SC", + fileQuery = "FQ", + fileSend = "FS", + fileResponse = "FR", + fileHeader = "FH", + fileData = "FD", + fileEnd = "FE", + textWrite = "TW", + textCursorPos = "TC", + textGetCursorPos = "TG", + textGetSize = "TD", + textInfo = "TI", + textClear = "TE", + textClearLine = "TL", + textScroll = "TS", + textBlink = "TB", + textColor = "TF", + textBackground = "TK", + textIsColor = "TA", + textTable = "TT", + event = "EV", + SQ = "query", + SR = "response", + SP = "data", + SC = "close", + FQ = "fileQuery", + FS = "fileSend", + FR = "fileResponse", + FH = "fileHeader", + FD = "fileData", + FE = "fileEnd", + TW = "textWrite", + TC = "textCursorPos", + TG = "textGetCursorPos", + TD = "textGetSize", + TI = "textInfo", + TE = "textClear", + TL = "textClearLine", + TS = "textScroll", + TB = "textBlink", + TF = "textColor", + TK = "textBackground", + TA = "textIsColor", + TT = "textTable", + EV = "event", +} + +local function openModem() + local modemFound = false + for _, side in ipairs(rs.getSides()) do + if peripheral.getType(side) == "modem" then + if not rednet.isOpen(side) then rednet.open(side) end + modemFound = true + break + end + end + return modemFound +end + +local function send(id, pType, message) + if pType and message then + return rawSend(id, packetConversion[pType]..":;"..message) + end +end + +local function awaitResponse(id, time) + id = tonumber(id) + local listenTimeOut = nil + local messRecv = false + if time then listenTimeOut = os.startTimer(time) end + while not messRecv do + local event, p1, p2 = os.pullEvent() + if event == "timer" and p1 == listenTimeOut then + return false + elseif event == "rednet_message" then + sender, message = p1, p2 + if id == sender and message then + if packetConversion[string.sub(message, 1, 2)] then packetType = packetConversion[string.sub(message, 1, 2)] end + message = string.match(message, ";(.*)") + messRecv = true + end + end + end + return packetType, message +end + +local function processText(conn, pType, value) + if not pType then return false end + if pType == "textWrite" and value then + term.write(value) + elseif pType == "textClear" then + term.clear() + elseif pType == "textClearLine" then + term.clearLine() + elseif pType == "textGetCursorPos" then + local x, y = term.getCursorPos() + send(conn, "textInfo", math.floor(x)..","..math.floor(y)) + elseif pType == "textCursorPos" then + local x, y = string.match(value, "(%-?%d+),(%-?%d+)") + term.setCursorPos(tonumber(x), tonumber(y)) + elseif pType == "textBlink" then + if value == "true" then + term.setCursorBlink(true) + else + term.setCursorBlink(false) + end + elseif pType == "textGetSize" then + x, y = term.getSize() + send(conn, "textInfo", x..","..y) + elseif pType == "textScroll" and value then + term.scroll(tonumber(value)) + elseif pType == "textIsColor" then + send(conn, "textInfo", tostring(term.isColor())) + elseif pType == "textColor" and value then + value = tonumber(value) + if (value == 1 or value == 32768) or term.isColor() then + term.setTextColor(value) + end + elseif pType == "textBackground" and value then + value = tonumber(value) + if (value == 1 or value == 32768) or term.isColor() then + term.setBackgroundColor(value) + end + elseif pType == "textTable" then + local linesTable = textutils.unserialize(value) + for i=1, linesTable.sizeY do + term.setCursorPos(1,i) + local lineEnd = false + local offset = 1 + while not lineEnd do + local textColorString = string.match(string.sub(linesTable.textColor[i], offset), string.sub(linesTable.textColor[i], offset, offset).."*") + local backColorString = string.match(string.sub(linesTable.backColor[i], offset), string.sub(linesTable.backColor[i], offset, offset).."*") + term.setTextColor(2 ^ tonumber(string.sub(textColorString, 1, 1), 16)) + term.setBackgroundColor(2 ^ tonumber(string.sub(backColorString, 1, 1), 16)) + term.write(string.sub(linesTable.text[i], offset, offset + math.min(#textColorString, #backColorString) - 1)) + offset = offset + math.min(#textColorString, #backColorString) + if offset > linesTable.sizeX then lineEnd = true end + end + end + term.setCursorPos(linesTable.cursorX, linesTable.cursorY) + term.setCursorBlink(linesTable.cursorBlink) + end + return +end + +local function textRedirect(id) + local textTable = {} + textTable.id = id + textTable.write = function(text) + return send(textTable.id, "textWrite", text) + end + textTable.clear = function() + return send(textTable.id, "textClear", "nil") + end + textTable.clearLine = function() + return send(textTable.id, "textClearLine", "nil") + end + textTable.getCursorPos = function() + send(textTable.id, "textGetCursorPos", "nil") + local pType, message = awaitResponse(textTable.id, 2) + if pType and pType == "textInfo" then + local x, y = string.match(message, "(%-?%d+),(%-?%d+)") + return tonumber(x), tonumber(y) + end + end + textTable.setCursorPos = function(x, y) + return send(textTable.id, "textCursorPos", math.floor(x)..","..math.floor(y)) + end + textTable.setCursorBlink = function(b) + if b then + return send(textTable.id, "textBlink", "true") + else + return send(textTable.id, "textBlink", "false") + end + end + textTable.getSize = function() + send(textTable.id, "textGetSize", "nil") + local pType, message = awaitResponse(textTable.id, 2) + if pType and pType == "textInfo" then + local x, y = string.match(message, "(%d+),(%d+)") + return tonumber(x), tonumber(y) + end + end + textTable.scroll = function(lines) + return send(textTable.id, "textScroll", lines) + end + textTable.isColor = function() + send(textTable.id, "textIsColor", "nil") + local pType, message = awaitResponse(textTable.id, 2) + if pType and pType == "textInfo" then + if message == "true" then + return true + end + end + return false + end + textTable.isColour = textTable.isColor + textTable.setTextColor = function(color) + return send(textTable.id, "textColor", tostring(color)) + end + textTable.setTextColour = textTable.setTextColor + textTable.setBackgroundColor = function(color) + return send(textTable.id, "textBackground", tostring(color)) + end + textTable.setBackgroundColour = textTable.setBackgroundColor + return textTable +end + +local function getServerID(server) + if tonumber(server) then + return tonumber(server) + elseif term.current then + return rednet.lookup("tror", args[1]) + end +end + +local function resumeThread(conn, event) + local cInfo = connections[conn] + if not connections[conn].filter or event[1] == connections[conn].filter then + connections[conn].filter = nil + local _oldTerm = term.redirect(connections[conn].target) + local passback = {coroutine.resume(connections[conn].thread, table.unpack(event))} + if passback[1] and passback[2] then + connections[conn].filter = passback[2] + end + if coroutine.status(connections[conn].thread) == "dead" then + send(conn, "close", "disconnect") + connections[conn] = nil + end + if _oldTerm then + term.redirect(_oldTerm) + else + term.restore() + end + if connections[conn] and conn ~= "localShell" and framebuffer then + send(conn, "textTable", textutils.serialize(connections[conn].target.buffer)) + end + end +end + +local eventFilter = { + key = true, + char = true, + mouse_click = true, + mouse_drag = true, + mouse_scroll = true, +} + +local function newSession(conn, x, y, color) + local session = {} + local path = "/rom/programs/shell" + if #args >= 2 and shell.resolveProgram(args[2]) then path = shell.resolveProgram(args[2]) end + session.thread = coroutine.create(function() shell.run(path) end) + if framebuffer then + session.target = framebuffer.new(x, y, color) + else + session.target = textRedirect(conn) + end + session.status = "open" + _oldTerm = term.redirect(session.target) + coroutine.resume(session.thread) + if _oldTerm then + term.redirect(_oldTerm) + else + term.restore() + end + if framebuffer then + send(conn, "textTable", textutils.serialize(session.target.buffer)) + end + return session +end + +if #args >= 1 and args[1] == "host" then + _G.nsh = nshAPI + if not openModem() then return end + if term.current then + if args[4] then + rednet.host("tror", args[4]) + elseif os.getComputerLabel() then + rednet.host("tror", os.getComputerLabel()) + else + print("No label or hostname provided!") + return + end + end + local connInfo = {} + connInfo.target = term.current and term.current() or term.native + local path = "/rom/programs/shell" + if #args >= 3 and shell.resolveProgram(args[3]) then path = shell.resolveProgram(args[3]) end + connInfo.thread = coroutine.create(function() shell.run(path) end) + connections.localShell = connInfo + term.clear() + term.setCursorPos(1,1) + coroutine.resume(connections.localShell.thread) + + while true do + event = {os.pullEventRaw()} + if event[1] == "rednet_message" then + if type(event[3]) == "string" and packetConversion[string.sub(event[3], 1, 2)] then + --this is a packet meant for us. + conn = event[2] + packetType = packetConversion[string.sub(event[3], 1, 2)] + message = string.match(event[3], ";(.*)") + if connections[conn] and connections[conn].status == "open" then + if packetType == "event" or string.sub(packetType, 1, 4) == "text" then + local eventTable = {} + if packetType == "event" then + eventTable = textutils.unserialize(message) + else + --we can pass the packet in raw, since this is not an event packet. + eventTable = event + end + resumeThread(conn, eventTable) + elseif packetType == "query" then + local connType, color, x, y = string.match(message, "(%a+):(%a+);(%d+),(%d+)") + if connType == "connect" or (connType == "resume" and (not framebuffer)) then + --reset connection + send(conn, "response", "OK") + connections[conn] = newSession(conn, tonumber(x), tonumber(y), color == "true") + elseif connType == "resume" then + --restore connection + send(conn, "response", "OK") + send(conn, "textTable", textutils.serialize(connections[conn].target.buffer)) + end + elseif packetType == "close" then + connections[conn] = nil + send(conn, "close", "disconnect") + --close connection + else + --we got a packet, have an open connection, but despite it being in the conversion table, don't handle it ourselves. Send it onward. + resumeThread(conn, event) + end + elseif packetType ~= "query" then + --usually, we would send a disconnect here, but this prevents one from hosting nsh and connecting to other computers. Pass these to all shells as well. + for cNum, cInfo in pairs(connections) do + resumeThread(cNum, event) + end + else + --open new connection + send(conn, "response", "OK") + local color, x, y = string.match(message, "connect:(%a+);(%d+),(%d+)") + local connInfo = newSession(conn, tonumber(x), tonumber(y), color == "true") + connections[conn] = connInfo + end + else + --rednet message, but not in the correct format, so pass to all shells. + for cNum, cInfo in pairs(connections) do + resumeThread(cNum, event) + end + end + elseif eventFilter[event[1]] then + --user interaction. + coroutine.resume(connections.localShell.thread, table.unpack(event)) + if coroutine.status(connections.localShell.thread) == "dead" then + for cNum, cInfo in pairs(connections) do + if cNum ~= "localShell" then + send(cNum, "close", "disconnect") + end + end + return + end + else + --dispatch all other events to all shells + for cNum, cInfo in pairs(connections) do + resumeThread(cNum, event) + end + end + end + +elseif #args <= 2 and nsh and nsh.getRemoteID() then + print(nsh.getRemoteID()) + --forwarding mode + local conns = nsh.getRemoteConnections() + for i = 1, #conns do + if conns[i] == serverNum then + print("Cyclic connection refused.") + return + end + end + local fileTransferState = nil + local fileData = nil + local serverNum = getServerID(args[1]) + if not serverNum then + print("Server Not Found") + return + end + send(serverNum, "query", "connect") + local pType, message = awaitResponse(serverNum, 2) + if pType ~= "response" then + print("Connection Failed") + return + else + nsh.connList[nsh.getRemoteID()].outbound = serverNum + term.clear() + term.setCursorPos(1,1) + end + local clientID = nsh.getRemoteID() + local serverID = tonumber(args[1]) + while true do + event = {os.pullEvent()} + if event[1] == "rednet_message" then + if event[2] == clientID or event[2] == serverID then + if event[2] == serverID and string.sub(event[3], 1, 2) == "SC" then break end + rednet.send((event[2] == clientID and serverID or clientID), event[3]) + end + elseif eventFilter[event[1]] then + rednet.send(serverID, "EV:;"..textutils.serialize(event)) + end + end + nsh.connList[nsh.getRemoteID()].outbound = nil + term.clear() + term.setCursorPos(1, 1) + print("Connection closed by server") + +elseif #args >= 1 then --either no server running or we are the local shell on the server. + if not openModem() then return end + local serverNum = getServerID(args[1]) + if not serverNum then + print("Server Not Found") + return + end + if nsh then + local conns = nsh.getRemoteConnections() + for i = 1, #conns do + if conns[i] == serverNum then + print("Connection refused.") + return + end + end + end + local fileTransferState = nil + local fileData = nil + local fileBinaryData = nil + local unpackCo = {} + local color = term.isColor() + local x, y = term.getSize() + if args[2] == "resume" then + send(serverNum, "query", "resume:"..tostring(color)..";"..tostring(x)..","..tostring(y)) + else + send(serverNum, "query", "connect:"..tostring(color)..";"..tostring(x)..","..tostring(y)) + end + local timeout = os.startTimer(2) + while true do + local event = {os.pullEvent()} + if event[1] == "timer" and event[2] == timeout then + print("Connection failed.") + return + elseif event[1] == "rednet_message" and event[2] == serverNum and string.sub(event[3], 1, 2) == "SR" then + if nsh then nshAPI = nsh end + if nshAPI.connList and nshAPI.connList.localShell then nshAPI.connList.localShell.outbound = serverNum end + nshAPI.serverNum = serverNum + nshAPI.clientCapabilities = "-fileTransfer-extensions-" + term.clear() + term.setCursorPos(1,1) + break + end + end + + while true do + event = {os.pullEventRaw()} + if #unpackCo > 0 then + for i = #unpackCo, 1, -1 do + if coroutine.status(unpackCo[i]) ~= "dead" then + coroutine.resume(unpackCo[i], table.unpack(event)) + else + table.remove(unpackCo, i) + end + end + end + if event[1] == "rednet_message" and event[2] == serverNum then + if packetConversion[string.sub(event[3], 1, 2)] then + packetType = packetConversion[string.sub(event[3], 1, 2)] + message = string.match(event[3], ";(.*)") + if string.sub(packetType, 1, 4) == "text" then + processText(serverNum, packetType, message) + elseif packetType == "data" then + if message == "clientCapabilities" then + rednet.send(serverNum, nshAPI.clientCapabilities) + end + elseif packetType == "fileQuery" then + --send a file to the server + local mode, file = string.match(message, "^(%a)=(.*)") + if fs.exists(file) then + send(serverNum, "fileHeader", file) + if mode == "b" then + local fileString = nshAPI.packFile(file) + send(serverNum, "fileData", "b="..fileString) + else + local handle = io.open(file, "r") + if handle then + send(serverNum, "fileData", "t="..handle:read("*a")) + handle:close() + end + end + else + send(serverNum, "fileHeader", "fileNotFound") + end + send(serverNum, "fileEnd", "end") + elseif packetType == "fileSend" then + --receive a file from the server, but don't overwrite existing files. + local mode, file = string.match(message, "^(%a)=(.*)") + if not fs.exists(file) then + fileTransferState = "receive_wait:"..file + send(serverNum, "fileResponse", "ok") + if mode == "b" then + fileBinaryData = "" + fileData = nil + else + fileData = "" + fileBinaryData = nil + end + else + send(serverNum, "fileResponse", "reject") + end + elseif packetType == "fileHeader" then + if message == "fileNotFound" then + fileTransferState = nil + end + elseif packetType == "fileData" then + if fileTransferState and string.match(fileTransferState, "(.-):") == "receive_wait" then + if string.match(message, "^(%a)=") == "b" then + fileBinaryData = fileBinaryData..string.match(message, "^b=(.*)") + else + fileData = fileData..string.match(message, "^t=(.*)") + end + end + elseif packetType == "fileEnd" then + if fileTransferState and string.match(fileTransferState, "(.-):") == "receive_wait" then + if fileBinaryData then + local co = coroutine.create(nshAPI.unpackAndSaveFile) + coroutine.resume(co, string.match(fileTransferState, ":(.*)"), fileBinaryData) + if coroutine.status(co) ~= "dead" then + table.insert(unpackCo, co) + end + elseif fileData then + local handle = io.open(string.match(fileTransferState, ":(.*)"), "w") + if handle then + handle:write(fileData) + handle:close() + end + end + fileTransferState = nil + end + elseif packetType == "close" then + if term.isColor() then + term.setBackgroundColor(colors.black) + term.setTextColor(colors.white) + end + term.clear() + term.setCursorPos(1, 1) + print("Connection closed by server.") + nshAPI.serverNum = nil + if nshAPI.connList and nshAPI.connList.localShell then nshAPI.connList.localShell.outbound = nil end + return + end + end + elseif event[1] == "mouse_click" or event[1] == "mouse_drag" or event[1] == "mouse_scroll" or event[1] == "key" or event[1] == "char" then + --pack up event + send(serverNum, "event", textutils.serialize(event)) + elseif event[1] == "terminate" then + nshAPI.serverNum = nil + if nshAPI.localShell then nshAPI.localShell.outbound = nil end + term.clear() + term.setCursorPos(1, 1) + print("Connection closed locally.") + return + end + end +else + print("Usage: nsh [resume]") + print(" nsh host [remote [local [name]]]") end \ No newline at end of file diff --git a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/put.lua b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/put.lua index aed5ad0e3..23e6a2e3c 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/put.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/Lyqyd/nsh/put.lua @@ -1,35 +1,35 @@ -if not nsh then print("No nsh session!") return end - -local args = {...} - -if #args < 2 then - print("Usage: put ") - print(": any file on the client") - print(": any file on the server") - return -end - -local fileData = "" - -nsh.send("FQ:;t="..args[1]) -local message = nsh.receive() -if message ~= "fileNotFound" then - while true do - message = nsh.receive() - pType = string.sub(message, 1, 2) - if pType == "FD" then - fileData = fileData..string.match(message, "^FD:;t=(.*)") - elseif pType == "FE" then - break - end - end - if #fileData > 0 then - local handle = io.open(args[2], "w") - if handle then - handle:write(fileData) - handle:close() - end - else - print("Empty file not written!") - end +if not nsh then print("No nsh session!") return end + +local args = {...} + +if #args < 2 then + print("Usage: put ") + print(": any file on the client") + print(": any file on the server") + return +end + +local fileData = "" + +nsh.send("FQ:;t="..args[1]) +local message = nsh.receive() +if message ~= "fileNotFound" then + while true do + message = nsh.receive() + pType = string.sub(message, 1, 2) + if pType == "FD" then + fileData = fileData..string.match(message, "^FD:;t=(.*)") + elseif pType == "FE" then + break + end + end + if #fileData > 0 then + local handle = io.open(args[2], "w") + if handle then + handle:write(fileData) + handle:close() + end + else + print("Empty file not written!") + end end \ No newline at end of file diff --git a/src/main/resources/assets/computercraft/lua/treasure/vilsol/gameoflife/gameoflife.lua b/src/main/resources/assets/computercraft/lua/treasure/vilsol/gameoflife/gameoflife.lua index 09c0cb40e..bcd57c718 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/vilsol/gameoflife/gameoflife.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/vilsol/gameoflife/gameoflife.lua @@ -1,178 +1,178 @@ -board = {} -tArgs = { ... } -generation = 0 -sleeptime = 0.5 - -if(tArgs[1] == "left" or tArgs[1] == "right" or tArgs[1] == "top" or tArgs[1] == "bottom" or tArgs[1] == "front" or tArgs[1] == "back")then - mon = peripheral.wrap(tArgs[1]) -else - mon = term -end - -if(mon.isColor() or mon.isColor)then - colored = true -else - colored = false -end - -w, h = mon.getSize() -for x = 1, w do - board[x] = {} - for y = 1, h do - board[x][y] = 0 - end -end - -function drawScreen() - w, h = mon.getSize() - for x = 1, w do - for y = 1, h do - nei = getNeighbours(x, y) - if(board[x][y] == 1)then - if colored then - if(nei < 2 or nei > 3)then - mon.setBackgroundColor(colors.red) - else - mon.setBackgroundColor(colors.green) - end - else - mon.setBackgroundColor(colors.white) - end - else - if colored then - if(nei == 3)then - mon.setBackgroundColor(colors.yellow) - else - mon.setBackgroundColor(colors.black) - end - else - mon.setBackgroundColor(colors.black) - end - end - mon.setCursorPos(x, y) - mon.write(" ") - end - end - mon.setCursorPos(1,1) - if colored then - mon.setTextColor(colors.blue) - end - mon.write(generation) -end - -function getNeighbours(x, y) - w, h = mon.getSize() - total = 0 - if(x > 1 and y > 1)then if(board[x-1][y-1] == 1)then total = total + 1 end end - if(y > 1)then if(board[x][y-1] == 1)then total = total + 1 end end - if(x < w and y > 1)then if(board[x+1][y-1] == 1)then total = total + 1 end end - if(x > 1)then if(board[x-1][y] == 1)then total = total + 1 end end - if(x < w)then if(board[x+1][y] == 1)then total = total + 1 end end - if(x > 1 and y < h)then if(board[x-1][y+1] == 1)then total = total + 1 end end - if(y < h)then if(board[x][y+1] == 1)then total = total + 1 end end - if(x < w and y < h)then if(board[x+1][y+1] == 1)then total = total + 1 end end - return total -end - -function compute() - w, h = mon.getSize() - while true do - newBoard = {} - for x = 1, w do - newBoard[x] = {} - for y = 1, h do - nei = getNeighbours(x, y) - if(board[x][y] == 1)then - if(nei < 2)then - newBoard[x][y] = 0 - elseif(nei > 3)then - newBoard[x][y] = 0 - else - newBoard[x][y] = 1 - end - else - if(nei == 3)then - newBoard[x][y] = 1 - end - end - end - end - board = newBoard - generation = generation + 1 - sleep(sleeptime) - end -end - -function loop() - while true do - event, variable, xPos, yPos = os.pullEvent() - if event == "mouse_click" or event == "monitor_touch" or event == "mouse_drag" then - if variable == 1 then - board[xPos][yPos] = 1 - else - board[xPos][yPos] = 0 - end - end - if event == "key" then - if tostring(variable) == "28" then - return true - elseif tostring(variable) == "57" then - if(mon.isColor() or mon.isColor)then - colored = not colored - end - elseif tostring(variable) == "200" then - if sleeptime > 0.1 then - sleeptime = sleeptime - 0.1 - end - elseif tostring(variable) == "208" then - if sleeptime < 1 then - sleeptime = sleeptime + 0.1 - end - end - end - drawScreen() - end -end - -function intro() - mon.setBackgroundColor(colors.black) - mon.clear() - mon.setCursorPos(1,1) - mon.write("Conway's Game Of Life") - mon.setCursorPos(1,2) - mon.write("It is a game which represents life.") - mon.setCursorPos(1,3) - mon.write("The game runs by 4 basic rules:") - mon.setCursorPos(1,4) - mon.write("1. If a cell has less than 2 neighbours, it dies.") - mon.setCursorPos(1,5) - mon.write("2. If a cell has 2 or 3 neightbours, it lives.") - mon.setCursorPos(1,6) - mon.write("3. If a cell has more than 3 neighbours, it dies.") - mon.setCursorPos(1,7) - mon.write("4. If a cell has exactly 3 neighbours it is born.") - mon.setCursorPos(1,9) - mon.write("At the top left is the generation count.") - mon.setCursorPos(1,10) - mon.write("Press spacebar to switch between color modes") - mon.setCursorPos(1,11) - mon.write("Press enter to start the game") - mon.setCursorPos(1,13) - mon.write("Colors:") - mon.setCursorPos(1,14) - mon.write("Red - Cell will die in next generation") - mon.setCursorPos(1,15) - mon.write("Green - Cell will live in next generation") - mon.setCursorPos(1,16) - mon.write("Yellow - Cell will be born in next generation") - mon.setCursorPos(1,18) - mon.write("Press any key to continue!") - event, variable, xPos, yPos = os.pullEvent("key") -end - -intro() -drawScreen() -while true do - loop() - parallel.waitForAny(loop, compute) +board = {} +tArgs = { ... } +generation = 0 +sleeptime = 0.5 + +if(tArgs[1] == "left" or tArgs[1] == "right" or tArgs[1] == "top" or tArgs[1] == "bottom" or tArgs[1] == "front" or tArgs[1] == "back")then + mon = peripheral.wrap(tArgs[1]) +else + mon = term +end + +if(mon.isColor() or mon.isColor)then + colored = true +else + colored = false +end + +w, h = mon.getSize() +for x = 1, w do + board[x] = {} + for y = 1, h do + board[x][y] = 0 + end +end + +function drawScreen() + w, h = mon.getSize() + for x = 1, w do + for y = 1, h do + nei = getNeighbours(x, y) + if(board[x][y] == 1)then + if colored then + if(nei < 2 or nei > 3)then + mon.setBackgroundColor(colors.red) + else + mon.setBackgroundColor(colors.green) + end + else + mon.setBackgroundColor(colors.white) + end + else + if colored then + if(nei == 3)then + mon.setBackgroundColor(colors.yellow) + else + mon.setBackgroundColor(colors.black) + end + else + mon.setBackgroundColor(colors.black) + end + end + mon.setCursorPos(x, y) + mon.write(" ") + end + end + mon.setCursorPos(1,1) + if colored then + mon.setTextColor(colors.blue) + end + mon.write(generation) +end + +function getNeighbours(x, y) + w, h = mon.getSize() + total = 0 + if(x > 1 and y > 1)then if(board[x-1][y-1] == 1)then total = total + 1 end end + if(y > 1)then if(board[x][y-1] == 1)then total = total + 1 end end + if(x < w and y > 1)then if(board[x+1][y-1] == 1)then total = total + 1 end end + if(x > 1)then if(board[x-1][y] == 1)then total = total + 1 end end + if(x < w)then if(board[x+1][y] == 1)then total = total + 1 end end + if(x > 1 and y < h)then if(board[x-1][y+1] == 1)then total = total + 1 end end + if(y < h)then if(board[x][y+1] == 1)then total = total + 1 end end + if(x < w and y < h)then if(board[x+1][y+1] == 1)then total = total + 1 end end + return total +end + +function compute() + w, h = mon.getSize() + while true do + newBoard = {} + for x = 1, w do + newBoard[x] = {} + for y = 1, h do + nei = getNeighbours(x, y) + if(board[x][y] == 1)then + if(nei < 2)then + newBoard[x][y] = 0 + elseif(nei > 3)then + newBoard[x][y] = 0 + else + newBoard[x][y] = 1 + end + else + if(nei == 3)then + newBoard[x][y] = 1 + end + end + end + end + board = newBoard + generation = generation + 1 + sleep(sleeptime) + end +end + +function loop() + while true do + event, variable, xPos, yPos = os.pullEvent() + if event == "mouse_click" or event == "monitor_touch" or event == "mouse_drag" then + if variable == 1 then + board[xPos][yPos] = 1 + else + board[xPos][yPos] = 0 + end + end + if event == "key" then + if tostring(variable) == "28" then + return true + elseif tostring(variable) == "57" then + if(mon.isColor() or mon.isColor)then + colored = not colored + end + elseif tostring(variable) == "200" then + if sleeptime > 0.1 then + sleeptime = sleeptime - 0.1 + end + elseif tostring(variable) == "208" then + if sleeptime < 1 then + sleeptime = sleeptime + 0.1 + end + end + end + drawScreen() + end +end + +function intro() + mon.setBackgroundColor(colors.black) + mon.clear() + mon.setCursorPos(1,1) + mon.write("Conway's Game Of Life") + mon.setCursorPos(1,2) + mon.write("It is a game which represents life.") + mon.setCursorPos(1,3) + mon.write("The game runs by 4 basic rules:") + mon.setCursorPos(1,4) + mon.write("1. If a cell has less than 2 neighbours, it dies.") + mon.setCursorPos(1,5) + mon.write("2. If a cell has 2 or 3 neightbours, it lives.") + mon.setCursorPos(1,6) + mon.write("3. If a cell has more than 3 neighbours, it dies.") + mon.setCursorPos(1,7) + mon.write("4. If a cell has exactly 3 neighbours it is born.") + mon.setCursorPos(1,9) + mon.write("At the top left is the generation count.") + mon.setCursorPos(1,10) + mon.write("Press spacebar to switch between color modes") + mon.setCursorPos(1,11) + mon.write("Press enter to start the game") + mon.setCursorPos(1,13) + mon.write("Colors:") + mon.setCursorPos(1,14) + mon.write("Red - Cell will die in next generation") + mon.setCursorPos(1,15) + mon.write("Green - Cell will live in next generation") + mon.setCursorPos(1,16) + mon.write("Yellow - Cell will be born in next generation") + mon.setCursorPos(1,18) + mon.write("Press any key to continue!") + event, variable, xPos, yPos = os.pullEvent("key") +end + +intro() +drawScreen() +while true do + loop() + parallel.waitForAny(loop, compute) end \ No newline at end of file diff --git a/src/main/resources/assets/computercraft/models/block/advanced_computer_blinking.json b/src/main/resources/assets/computercraft/models/block/advanced_computer_blinking.json index 63a4ff7e4..886f9fccb 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_computer_blinking.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_computer_blinking.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/computer_front_blink_advanced", - "side": "computercraft:blocks/computer_side_advanced", - "top": "computercraft:blocks/computer_top_advanced" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/computer_front_blink_advanced", + "side": "computercraft:blocks/computer_side_advanced", + "top": "computercraft:blocks/computer_top_advanced" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_computer_off.json b/src/main/resources/assets/computercraft/models/block/advanced_computer_off.json index 52f3f3f05..b08ab9555 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_computer_off.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_computer_off.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/computer_front_advanced", - "side": "computercraft:blocks/computer_side_advanced", - "top": "computercraft:blocks/computer_top_advanced" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/computer_front_advanced", + "side": "computercraft:blocks/computer_side_advanced", + "top": "computercraft:blocks/computer_top_advanced" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_computer_on.json b/src/main/resources/assets/computercraft/models/block/advanced_computer_on.json index db03027a7..4e6636639 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_computer_on.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_computer_on.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/computer_front_on_advanced", - "side": "computercraft:blocks/computer_side_advanced", - "top": "computercraft:blocks/computer_top_advanced" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/computer_front_on_advanced", + "side": "computercraft:blocks/computer_side_advanced", + "top": "computercraft:blocks/computer_top_advanced" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_modem_off.json b/src/main/resources/assets/computercraft/models/block/advanced_modem_off.json index 7575b874f..6a9557d97 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_modem_off.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_modem_off.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/adv_modem_face", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/adv_modem_face", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_modem_on.json b/src/main/resources/assets/computercraft/models/block/advanced_modem_on.json index 8ab3df5df..062a35a1a 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_modem_on.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_modem_on.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/adv_modem_face_on", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/adv_modem_face_on", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor.json index ee2edcfd3..deac4229a 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor16", - "side": "computercraft:blocks/adv_monitor4", - "top": "computercraft:blocks/adv_monitor0", - "back": "computercraft:blocks/adv_monitor4" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor16", + "side": "computercraft:blocks/adv_monitor4", + "top": "computercraft:blocks/adv_monitor0", + "back": "computercraft:blocks/adv_monitor4" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_d.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_d.json index 008b714c7..f836bd93b 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_d.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_d.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor20", - "side": "computercraft:blocks/adv_monitor36", - "top": "computercraft:blocks/adv_monitor0", - "back": "computercraft:blocks/adv_monitor36" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor20", + "side": "computercraft:blocks/adv_monitor36", + "top": "computercraft:blocks/adv_monitor0", + "back": "computercraft:blocks/adv_monitor36" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_item.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_item.json index 313a6594b..0f5e9f860 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_item.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_item.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/adv_monitor15", - "side": "computercraft:blocks/adv_monitor4", - "top": "computercraft:blocks/adv_monitor0" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/adv_monitor15", + "side": "computercraft:blocks/adv_monitor4", + "top": "computercraft:blocks/adv_monitor0" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_l.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_l.json index bf6c270b3..8a2e9131a 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_l.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_l.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor19", - "side": "computercraft:blocks/adv_monitor4", - "top": "computercraft:blocks/adv_monitor1", - "back": "computercraft:blocks/adv_monitor33" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor19", + "side": "computercraft:blocks/adv_monitor4", + "top": "computercraft:blocks/adv_monitor1", + "back": "computercraft:blocks/adv_monitor33" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_ld.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_ld.json index 237f1764c..b8484e597 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_ld.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_ld.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor31", - "side": "computercraft:blocks/adv_monitor7", - "top": "computercraft:blocks/adv_monitor1", - "back": "computercraft:blocks/adv_monitor45" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor31", + "side": "computercraft:blocks/adv_monitor7", + "top": "computercraft:blocks/adv_monitor1", + "back": "computercraft:blocks/adv_monitor45" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lr.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lr.json index 5a2faba87..a948efe91 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lr.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lr.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor18", - "side": "computercraft:blocks/adv_monitor4", - "top": "computercraft:blocks/adv_monitor2", - "back": "computercraft:blocks/adv_monitor34" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor18", + "side": "computercraft:blocks/adv_monitor4", + "top": "computercraft:blocks/adv_monitor2", + "back": "computercraft:blocks/adv_monitor34" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrd.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrd.json index 0ab283070..9fab25ab3 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrd.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrd.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor30", - "side": "computercraft:blocks/adv_monitor7", - "top": "computercraft:blocks/adv_monitor2", - "back": "computercraft:blocks/adv_monitor46" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor30", + "side": "computercraft:blocks/adv_monitor7", + "top": "computercraft:blocks/adv_monitor2", + "back": "computercraft:blocks/adv_monitor46" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lru.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lru.json index 3dd3dfdcc..f79f82964 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lru.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lru.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor24", - "side": "computercraft:blocks/adv_monitor38", - "top": "computercraft:blocks/adv_monitor2", - "back": "computercraft:blocks/adv_monitor40" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor24", + "side": "computercraft:blocks/adv_monitor38", + "top": "computercraft:blocks/adv_monitor2", + "back": "computercraft:blocks/adv_monitor40" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrud.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrud.json index 29825462a..c0ca8fcac 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrud.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lrud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor27", - "side": "computercraft:blocks/adv_monitor37", - "top": "computercraft:blocks/adv_monitor2", - "back": "computercraft:blocks/adv_monitor43" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor27", + "side": "computercraft:blocks/adv_monitor37", + "top": "computercraft:blocks/adv_monitor2", + "back": "computercraft:blocks/adv_monitor43" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lu.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lu.json index 2c3850284..6e0afca5d 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lu.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lu.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor25", - "side": "computercraft:blocks/adv_monitor38", - "top": "computercraft:blocks/adv_monitor1", - "back": "computercraft:blocks/adv_monitor39" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor25", + "side": "computercraft:blocks/adv_monitor38", + "top": "computercraft:blocks/adv_monitor1", + "back": "computercraft:blocks/adv_monitor39" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lud.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lud.json index b5649e66b..0a7bd2901 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_lud.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_lud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor28", - "side": "computercraft:blocks/adv_monitor37", - "top": "computercraft:blocks/adv_monitor1", - "back": "computercraft:blocks/adv_monitor42" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor28", + "side": "computercraft:blocks/adv_monitor37", + "top": "computercraft:blocks/adv_monitor1", + "back": "computercraft:blocks/adv_monitor42" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_r.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_r.json index c91b1aba1..5e1c3a1d8 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_r.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_r.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor17", - "side": "computercraft:blocks/adv_monitor4", - "top": "computercraft:blocks/adv_monitor3", - "back": "computercraft:blocks/adv_monitor35" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor17", + "side": "computercraft:blocks/adv_monitor4", + "top": "computercraft:blocks/adv_monitor3", + "back": "computercraft:blocks/adv_monitor35" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_rd.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_rd.json index 90d2b4a40..4e96ecafa 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_rd.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_rd.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor29", - "side": "computercraft:blocks/adv_monitor7", - "top": "computercraft:blocks/adv_monitor3", - "back": "computercraft:blocks/adv_monitor47" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor29", + "side": "computercraft:blocks/adv_monitor7", + "top": "computercraft:blocks/adv_monitor3", + "back": "computercraft:blocks/adv_monitor47" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_ru.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_ru.json index 3350b160e..046c65ce6 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_ru.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_ru.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor23", - "side": "computercraft:blocks/adv_monitor38", - "top": "computercraft:blocks/adv_monitor3", - "back": "computercraft:blocks/adv_monitor41" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor23", + "side": "computercraft:blocks/adv_monitor38", + "top": "computercraft:blocks/adv_monitor3", + "back": "computercraft:blocks/adv_monitor41" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_rud.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_rud.json index fa38aced5..7cb6b7218 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_rud.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_rud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor26", - "side": "computercraft:blocks/adv_monitor37", - "top": "computercraft:blocks/adv_monitor3", - "back": "computercraft:blocks/adv_monitor44" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor26", + "side": "computercraft:blocks/adv_monitor37", + "top": "computercraft:blocks/adv_monitor3", + "back": "computercraft:blocks/adv_monitor44" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_u.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_u.json index 6914e9a35..78a99a448 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_u.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_u.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor22", - "side": "computercraft:blocks/adv_monitor38", - "top": "computercraft:blocks/adv_monitor0", - "back": "computercraft:blocks/adv_monitor38" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor22", + "side": "computercraft:blocks/adv_monitor38", + "top": "computercraft:blocks/adv_monitor0", + "back": "computercraft:blocks/adv_monitor38" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_monitor_ud.json b/src/main/resources/assets/computercraft/models/block/advanced_monitor_ud.json index ccc065056..f102b42bc 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_monitor_ud.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_monitor_ud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/adv_monitor21", - "side": "computercraft:blocks/adv_monitor37", - "top": "computercraft:blocks/adv_monitor0", - "back": "computercraft:blocks/adv_monitor37" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/adv_monitor21", + "side": "computercraft:blocks/adv_monitor37", + "top": "computercraft:blocks/adv_monitor0", + "back": "computercraft:blocks/adv_monitor37" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_turtle.json b/src/main/resources/assets/computercraft/models/block/advanced_turtle.json index 6836acfc9..aff0bdee3 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_turtle.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_turtle.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_base", - "textures": { - "texture": "computercraft:blocks/turtle_advanced" - } -} +{ + "parent": "computercraft:block/turtle_base", + "textures": { + "texture": "computercraft:blocks/turtle_advanced" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_left.json b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_left.json index 8177f2fc3..361a8369e 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_left.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_left.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_left", - "textures": { - "texture": "computercraft:blocks/adv_modem_face" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": { + "texture": "computercraft:blocks/adv_modem_face" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_right.json b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_right.json index 3621118c6..f23baad27 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_right.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_off_right.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_right", - "textures": { - "texture": "computercraft:blocks/adv_modem_face" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": { + "texture": "computercraft:blocks/adv_modem_face" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_left.json b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_left.json index 605fa6208..2cadf94c7 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_left.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_left.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_left", - "textures": { - "texture": "computercraft:blocks/adv_modem_face_on" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": { + "texture": "computercraft:blocks/adv_modem_face_on" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_right.json b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_right.json index 6239c74eb..aad434e78 100644 --- a/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_right.json +++ b/src/main/resources/assets/computercraft/models/block/advanced_turtle_modem_on_right.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_right", - "textures": { - "texture": "computercraft:blocks/adv_modem_face_on" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": { + "texture": "computercraft:blocks/adv_modem_face_on" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/cable_arm.json b/src/main/resources/assets/computercraft/models/block/cable_arm.json index 9e407d854..d5b17e8b2 100644 --- a/src/main/resources/assets/computercraft/models/block/cable_arm.json +++ b/src/main/resources/assets/computercraft/models/block/cable_arm.json @@ -1,19 +1,19 @@ -{ - "parent": "block/block", - "textures": { - "particle": "computercraft:blocks/cable_core", - "side": "computercraft:blocks/cable_side" - }, - "elements": [ - { - "from": [ 6, 6, 10 ], - "to": [ 10, 10, 16 ], - "faces": { - "down": { "uv": [ 6, 0, 10, 6 ], "texture": "#side" }, - "up": { "uv": [ 6, 10, 10, 16 ], "texture": "#side" }, - "west": { "uv": [ 0, 6, 6, 10 ], "texture": "#side" }, - "east": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" } - } - } - ] -} +{ + "parent": "block/block", + "textures": { + "particle": "computercraft:blocks/cable_core", + "side": "computercraft:blocks/cable_side" + }, + "elements": [ + { + "from": [ 6, 6, 10 ], + "to": [ 10, 10, 16 ], + "faces": { + "down": { "uv": [ 6, 0, 10, 6 ], "texture": "#side" }, + "up": { "uv": [ 6, 10, 10, 16 ], "texture": "#side" }, + "west": { "uv": [ 0, 6, 6, 10 ], "texture": "#side" }, + "east": { "uv": [ 10, 6, 16, 10 ], "texture": "#side" } + } + } + ] +} diff --git a/src/main/resources/assets/computercraft/models/block/cable_core_any.json b/src/main/resources/assets/computercraft/models/block/cable_core_any.json index 05d4daeb6..2287d0cca 100644 --- a/src/main/resources/assets/computercraft/models/block/cable_core_any.json +++ b/src/main/resources/assets/computercraft/models/block/cable_core_any.json @@ -5,7 +5,7 @@ "side": "computercraft:blocks/cable_side" }, "elements": [ - { + { "from": [ 6, 6, 6 ], "to": [ 10, 10, 10 ], "faces": { diff --git a/src/main/resources/assets/computercraft/models/block/cable_item.json b/src/main/resources/assets/computercraft/models/block/cable_item.json index 48c4d4368..96917a140 100644 --- a/src/main/resources/assets/computercraft/models/block/cable_item.json +++ b/src/main/resources/assets/computercraft/models/block/cable_item.json @@ -1,22 +1,22 @@ -{ - "parent": "block/block", - "textures": { - "particle": "computercraft:blocks/cable_core", - "side": "computercraft:blocks/cable_side", - "end": "computercraft:blocks/cable_core" - }, - "elements": [ - { - "from": [ 6, 6, 2 ], - "to": [ 10, 10, 14 ], - "faces": { - "down": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" }, - "up": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" }, - "north": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" }, - "south": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" }, - "west": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" }, - "east": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" } - } - } - ] -} +{ + "parent": "block/block", + "textures": { + "particle": "computercraft:blocks/cable_core", + "side": "computercraft:blocks/cable_side", + "end": "computercraft:blocks/cable_core" + }, + "elements": [ + { + "from": [ 6, 6, 2 ], + "to": [ 10, 10, 14 ], + "faces": { + "down": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" }, + "up": { "uv": [ 6, 2, 10, 14 ], "texture": "#side" }, + "north": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" }, + "south": { "uv": [ 6, 6, 10, 10 ], "texture": "#end" }, + "west": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" }, + "east": { "uv": [ 2, 6, 14, 10 ], "texture": "#side" } + } + } + ] +} diff --git a/src/main/resources/assets/computercraft/models/block/command_computer_blinking.json b/src/main/resources/assets/computercraft/models/block/command_computer_blinking.json index 2eeabc831..a160a3184 100644 --- a/src/main/resources/assets/computercraft/models/block/command_computer_blinking.json +++ b/src/main/resources/assets/computercraft/models/block/command_computer_blinking.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/command_computer_front_blink", - "side": "computercraft:blocks/command_computer_side", - "top": "computercraft:blocks/command_computer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/command_computer_front_blink", + "side": "computercraft:blocks/command_computer_side", + "top": "computercraft:blocks/command_computer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/command_computer_off.json b/src/main/resources/assets/computercraft/models/block/command_computer_off.json index 29e9bdf93..30d2efb01 100644 --- a/src/main/resources/assets/computercraft/models/block/command_computer_off.json +++ b/src/main/resources/assets/computercraft/models/block/command_computer_off.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/command_computer_front", - "side": "computercraft:blocks/command_computer_side", - "top": "computercraft:blocks/command_computer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/command_computer_front", + "side": "computercraft:blocks/command_computer_side", + "top": "computercraft:blocks/command_computer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/command_computer_on.json b/src/main/resources/assets/computercraft/models/block/command_computer_on.json index 7b87f0a3a..f068e1e88 100644 --- a/src/main/resources/assets/computercraft/models/block/command_computer_on.json +++ b/src/main/resources/assets/computercraft/models/block/command_computer_on.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/command_computer_front_on", - "side": "computercraft:blocks/command_computer_side", - "top": "computercraft:blocks/command_computer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/command_computer_front_on", + "side": "computercraft:blocks/command_computer_side", + "top": "computercraft:blocks/command_computer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/computer_blinking.json b/src/main/resources/assets/computercraft/models/block/computer_blinking.json index 6b7aabb4b..45fe82c91 100644 --- a/src/main/resources/assets/computercraft/models/block/computer_blinking.json +++ b/src/main/resources/assets/computercraft/models/block/computer_blinking.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/computer_front_blink", - "side": "computercraft:blocks/computer_side", - "top": "computercraft:blocks/computer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/computer_front_blink", + "side": "computercraft:blocks/computer_side", + "top": "computercraft:blocks/computer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/computer_off.json b/src/main/resources/assets/computercraft/models/block/computer_off.json index f5cd6dccc..ba281ec84 100644 --- a/src/main/resources/assets/computercraft/models/block/computer_off.json +++ b/src/main/resources/assets/computercraft/models/block/computer_off.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/computer_front", - "side": "computercraft:blocks/computer_side", - "top": "computercraft:blocks/computer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/computer_front", + "side": "computercraft:blocks/computer_side", + "top": "computercraft:blocks/computer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/computer_on.json b/src/main/resources/assets/computercraft/models/block/computer_on.json index 5ed7e30d9..138278fb7 100644 --- a/src/main/resources/assets/computercraft/models/block/computer_on.json +++ b/src/main/resources/assets/computercraft/models/block/computer_on.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/computer_front_on", - "side": "computercraft:blocks/computer_side", - "top": "computercraft:blocks/computer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/computer_front_on", + "side": "computercraft:blocks/computer_side", + "top": "computercraft:blocks/computer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/disk_drive_empty.json b/src/main/resources/assets/computercraft/models/block/disk_drive_empty.json index d412fad04..9ab150803 100644 --- a/src/main/resources/assets/computercraft/models/block/disk_drive_empty.json +++ b/src/main/resources/assets/computercraft/models/block/disk_drive_empty.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/disk_drive_front", - "side": "computercraft:blocks/disk_drive_side", - "top": "computercraft:blocks/disk_drive_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/disk_drive_front", + "side": "computercraft:blocks/disk_drive_side", + "top": "computercraft:blocks/disk_drive_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/disk_drive_full.json b/src/main/resources/assets/computercraft/models/block/disk_drive_full.json index 2b5c6f3f3..076231973 100644 --- a/src/main/resources/assets/computercraft/models/block/disk_drive_full.json +++ b/src/main/resources/assets/computercraft/models/block/disk_drive_full.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/disk_drive_front_accepted", - "side": "computercraft:blocks/disk_drive_side", - "top": "computercraft:blocks/disk_drive_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/disk_drive_front_accepted", + "side": "computercraft:blocks/disk_drive_side", + "top": "computercraft:blocks/disk_drive_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/disk_drive_invalid.json b/src/main/resources/assets/computercraft/models/block/disk_drive_invalid.json index 792ba8f63..5cf512ae6 100644 --- a/src/main/resources/assets/computercraft/models/block/disk_drive_invalid.json +++ b/src/main/resources/assets/computercraft/models/block/disk_drive_invalid.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/disk_drive_front_rejected", - "side": "computercraft:blocks/disk_drive_side", - "top": "computercraft:blocks/disk_drive_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/disk_drive_front_rejected", + "side": "computercraft:blocks/disk_drive_side", + "top": "computercraft:blocks/disk_drive_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/modem.json b/src/main/resources/assets/computercraft/models/block/modem.json index 6e5a3bcdd..358362e55 100644 --- a/src/main/resources/assets/computercraft/models/block/modem.json +++ b/src/main/resources/assets/computercraft/models/block/modem.json @@ -1,52 +1,52 @@ -{ - "parent": "block/block", - "textures": { - "particle": "#front" - }, - "elements": [ - { - "from": [ 2, 2, 0 ], - "to": [ 14, 14, 3 ], - "faces": { - "down": { "uv": [ 2, 13, 14, 16 ], "texture": "#front" }, - "up": { "uv": [ 2, 0, 14, 3 ], "texture": "#front" }, - "north": { "uv": [ 2, 2, 14, 14 ], "texture": "#back" }, - "south": { "uv": [ 2, 2, 14, 14 ], "texture": "#front" }, - "west": { "uv": [ 0, 2, 3, 14 ], "texture": "#front" }, - "east": { "uv": [ 13, 2, 16, 14 ], "texture": "#front" } - } - } - ], - "display": { - "gui": { - "rotation": [ 30, 45, 0 ], - "translation": [ 3.2, -2, 0], - "scale":[ 0.75, 0.75, 0.75 ] - }, - "ground": { - "rotation": [ 0, 0, 0 ], - "translation": [ 0, 3, 0], - "scale":[ 0.25, 0.25, 0.25 ] - }, - "fixed": { - "rotation": [ 0, 0, 0 ], - "translation": [ 0, 0, 0], - "scale":[ 0.5, 0.5, 0.5 ] - }, - "thirdperson_righthand": { - "rotation": [ 75, 180, 0 ], - "translation": [ 0, 2.5, 0], - "scale": [ 0.375, 0.375, 0.375 ] - }, - "firstperson_righthand": { - "rotation": [ 0, 45, 0 ], - "translation": [ 0, 0, 0 ], - "scale": [ 0.40, 0.40, 0.40 ] - }, - "firstperson_lefthand": { - "rotation": [ 0, 45, 0 ], - "translation": [ 0, 0, 0 ], - "scale": [ 0.40, 0.40, 0.40 ] - } - } -} +{ + "parent": "block/block", + "textures": { + "particle": "#front" + }, + "elements": [ + { + "from": [ 2, 2, 0 ], + "to": [ 14, 14, 3 ], + "faces": { + "down": { "uv": [ 2, 13, 14, 16 ], "texture": "#front" }, + "up": { "uv": [ 2, 0, 14, 3 ], "texture": "#front" }, + "north": { "uv": [ 2, 2, 14, 14 ], "texture": "#back" }, + "south": { "uv": [ 2, 2, 14, 14 ], "texture": "#front" }, + "west": { "uv": [ 0, 2, 3, 14 ], "texture": "#front" }, + "east": { "uv": [ 13, 2, 16, 14 ], "texture": "#front" } + } + } + ], + "display": { + "gui": { + "rotation": [ 30, 45, 0 ], + "translation": [ 3.2, -2, 0], + "scale":[ 0.75, 0.75, 0.75 ] + }, + "ground": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 3, 0], + "scale":[ 0.25, 0.25, 0.25 ] + }, + "fixed": { + "rotation": [ 0, 0, 0 ], + "translation": [ 0, 0, 0], + "scale":[ 0.5, 0.5, 0.5 ] + }, + "thirdperson_righthand": { + "rotation": [ 75, 180, 0 ], + "translation": [ 0, 2.5, 0], + "scale": [ 0.375, 0.375, 0.375 ] + }, + "firstperson_righthand": { + "rotation": [ 0, 45, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + }, + "firstperson_lefthand": { + "rotation": [ 0, 45, 0 ], + "translation": [ 0, 0, 0 ], + "scale": [ 0.40, 0.40, 0.40 ] + } + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor.json b/src/main/resources/assets/computercraft/models/block/monitor.json index 6a01fce69..706d0d56d 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor.json +++ b/src/main/resources/assets/computercraft/models/block/monitor.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor16", - "side": "computercraft:blocks/monitor4", - "top": "computercraft:blocks/monitor0", - "back": "computercraft:blocks/monitor4" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor16", + "side": "computercraft:blocks/monitor4", + "top": "computercraft:blocks/monitor0", + "back": "computercraft:blocks/monitor4" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_base.json b/src/main/resources/assets/computercraft/models/block/monitor_base.json index 726cb2f87..06ec832aa 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_base.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_base.json @@ -1,12 +1,12 @@ -{ - "parent": "block/cube", - "textures": { - "particle": "#front", - "down": "#top", - "up": "#top", - "north": "#front", - "east": "#side", - "south": "#back", - "west": "#side" - } -} +{ + "parent": "block/cube", + "textures": { + "particle": "#front", + "down": "#top", + "up": "#top", + "north": "#front", + "east": "#side", + "south": "#back", + "west": "#side" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_d.json b/src/main/resources/assets/computercraft/models/block/monitor_d.json index 098491b1b..010cefca5 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_d.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_d.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor20", - "side": "computercraft:blocks/monitor36", - "top": "computercraft:blocks/monitor0", - "back": "computercraft:blocks/monitor36" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor20", + "side": "computercraft:blocks/monitor36", + "top": "computercraft:blocks/monitor0", + "back": "computercraft:blocks/monitor36" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_item.json b/src/main/resources/assets/computercraft/models/block/monitor_item.json index 5c7818a8c..9d64c271a 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_item.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_item.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/monitor15", - "side": "computercraft:blocks/monitor4", - "top": "computercraft:blocks/monitor0" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/monitor15", + "side": "computercraft:blocks/monitor4", + "top": "computercraft:blocks/monitor0" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_l.json b/src/main/resources/assets/computercraft/models/block/monitor_l.json index 1a8fc4efe..98b267c7b 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_l.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_l.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor19", - "side": "computercraft:blocks/monitor4", - "top": "computercraft:blocks/monitor1", - "back": "computercraft:blocks/monitor33" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor19", + "side": "computercraft:blocks/monitor4", + "top": "computercraft:blocks/monitor1", + "back": "computercraft:blocks/monitor33" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_ld.json b/src/main/resources/assets/computercraft/models/block/monitor_ld.json index b3e0fb4af..cd68647b8 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_ld.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_ld.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor31", - "side": "computercraft:blocks/monitor7", - "top": "computercraft:blocks/monitor1", - "back": "computercraft:blocks/monitor45" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor31", + "side": "computercraft:blocks/monitor7", + "top": "computercraft:blocks/monitor1", + "back": "computercraft:blocks/monitor45" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_lr.json b/src/main/resources/assets/computercraft/models/block/monitor_lr.json index 36ebb5a0c..c98e6e43b 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_lr.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_lr.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor18", - "side": "computercraft:blocks/monitor4", - "top": "computercraft:blocks/monitor2", - "back": "computercraft:blocks/monitor34" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor18", + "side": "computercraft:blocks/monitor4", + "top": "computercraft:blocks/monitor2", + "back": "computercraft:blocks/monitor34" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_lrd.json b/src/main/resources/assets/computercraft/models/block/monitor_lrd.json index d8a0b0f68..545239bf9 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_lrd.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_lrd.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor30", - "side": "computercraft:blocks/monitor7", - "top": "computercraft:blocks/monitor2", - "back": "computercraft:blocks/monitor46" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor30", + "side": "computercraft:blocks/monitor7", + "top": "computercraft:blocks/monitor2", + "back": "computercraft:blocks/monitor46" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_lru.json b/src/main/resources/assets/computercraft/models/block/monitor_lru.json index f175842b4..e53cbfda9 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_lru.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_lru.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor24", - "side": "computercraft:blocks/monitor38", - "top": "computercraft:blocks/monitor2", - "back": "computercraft:blocks/monitor40" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor24", + "side": "computercraft:blocks/monitor38", + "top": "computercraft:blocks/monitor2", + "back": "computercraft:blocks/monitor40" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_lrud.json b/src/main/resources/assets/computercraft/models/block/monitor_lrud.json index 03a0f1e13..4b99691a5 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_lrud.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_lrud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor27", - "side": "computercraft:blocks/monitor37", - "top": "computercraft:blocks/monitor2", - "back": "computercraft:blocks/monitor43" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor27", + "side": "computercraft:blocks/monitor37", + "top": "computercraft:blocks/monitor2", + "back": "computercraft:blocks/monitor43" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_lu.json b/src/main/resources/assets/computercraft/models/block/monitor_lu.json index 9e2ca965e..3698e0321 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_lu.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_lu.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor25", - "side": "computercraft:blocks/monitor38", - "top": "computercraft:blocks/monitor1", - "back": "computercraft:blocks/monitor39" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor25", + "side": "computercraft:blocks/monitor38", + "top": "computercraft:blocks/monitor1", + "back": "computercraft:blocks/monitor39" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_lud.json b/src/main/resources/assets/computercraft/models/block/monitor_lud.json index d5b59ecc2..d3200aa45 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_lud.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_lud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor28", - "side": "computercraft:blocks/monitor37", - "top": "computercraft:blocks/monitor1", - "back": "computercraft:blocks/monitor42" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor28", + "side": "computercraft:blocks/monitor37", + "top": "computercraft:blocks/monitor1", + "back": "computercraft:blocks/monitor42" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_r.json b/src/main/resources/assets/computercraft/models/block/monitor_r.json index 2205b5123..6df1d8ed6 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_r.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_r.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor17", - "side": "computercraft:blocks/monitor4", - "top": "computercraft:blocks/monitor3", - "back": "computercraft:blocks/monitor35" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor17", + "side": "computercraft:blocks/monitor4", + "top": "computercraft:blocks/monitor3", + "back": "computercraft:blocks/monitor35" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_rd.json b/src/main/resources/assets/computercraft/models/block/monitor_rd.json index 4022ecd65..a70a1288a 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_rd.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_rd.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor29", - "side": "computercraft:blocks/monitor7", - "top": "computercraft:blocks/monitor3", - "back": "computercraft:blocks/monitor47" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor29", + "side": "computercraft:blocks/monitor7", + "top": "computercraft:blocks/monitor3", + "back": "computercraft:blocks/monitor47" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_ru.json b/src/main/resources/assets/computercraft/models/block/monitor_ru.json index 2ec567e24..4fdab8b57 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_ru.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_ru.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor23", - "side": "computercraft:blocks/monitor38", - "top": "computercraft:blocks/monitor3", - "back": "computercraft:blocks/monitor41" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor23", + "side": "computercraft:blocks/monitor38", + "top": "computercraft:blocks/monitor3", + "back": "computercraft:blocks/monitor41" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_rud.json b/src/main/resources/assets/computercraft/models/block/monitor_rud.json index d6fe96482..aebca56b5 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_rud.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_rud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor26", - "side": "computercraft:blocks/monitor37", - "top": "computercraft:blocks/monitor3", - "back": "computercraft:blocks/monitor44" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor26", + "side": "computercraft:blocks/monitor37", + "top": "computercraft:blocks/monitor3", + "back": "computercraft:blocks/monitor44" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_u.json b/src/main/resources/assets/computercraft/models/block/monitor_u.json index 24c2a904b..44c93e361 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_u.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_u.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor22", - "side": "computercraft:blocks/monitor38", - "top": "computercraft:blocks/monitor0", - "back": "computercraft:blocks/monitor38" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor22", + "side": "computercraft:blocks/monitor38", + "top": "computercraft:blocks/monitor0", + "back": "computercraft:blocks/monitor38" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/monitor_ud.json b/src/main/resources/assets/computercraft/models/block/monitor_ud.json index 771db2f18..5c59b92c7 100644 --- a/src/main/resources/assets/computercraft/models/block/monitor_ud.json +++ b/src/main/resources/assets/computercraft/models/block/monitor_ud.json @@ -1,9 +1,9 @@ -{ - "parent": "computercraft:block/monitor_base", - "textures": { - "front": "computercraft:blocks/monitor21", - "side": "computercraft:blocks/monitor37", - "top": "computercraft:blocks/monitor0", - "back": "computercraft:blocks/monitor37" - } -} +{ + "parent": "computercraft:block/monitor_base", + "textures": { + "front": "computercraft:blocks/monitor21", + "side": "computercraft:blocks/monitor37", + "top": "computercraft:blocks/monitor0", + "back": "computercraft:blocks/monitor37" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/printer_both_full.json b/src/main/resources/assets/computercraft/models/block/printer_both_full.json index 19b2f1a75..0db5558ea 100644 --- a/src/main/resources/assets/computercraft/models/block/printer_both_full.json +++ b/src/main/resources/assets/computercraft/models/block/printer_both_full.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/printer_front_both_trays", - "side": "computercraft:blocks/printer_side", - "top": "computercraft:blocks/printer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/printer_front_both_trays", + "side": "computercraft:blocks/printer_side", + "top": "computercraft:blocks/printer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/printer_bottom_full.json b/src/main/resources/assets/computercraft/models/block/printer_bottom_full.json index 1beec4182..90883f08f 100644 --- a/src/main/resources/assets/computercraft/models/block/printer_bottom_full.json +++ b/src/main/resources/assets/computercraft/models/block/printer_bottom_full.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/printer_front_bottom_tray", - "side": "computercraft:blocks/printer_side", - "top": "computercraft:blocks/printer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/printer_front_bottom_tray", + "side": "computercraft:blocks/printer_side", + "top": "computercraft:blocks/printer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/printer_empty.json b/src/main/resources/assets/computercraft/models/block/printer_empty.json index ae77b6a30..dadcd5209 100644 --- a/src/main/resources/assets/computercraft/models/block/printer_empty.json +++ b/src/main/resources/assets/computercraft/models/block/printer_empty.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/printer_front_empty", - "side": "computercraft:blocks/printer_side", - "top": "computercraft:blocks/printer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/printer_front_empty", + "side": "computercraft:blocks/printer_side", + "top": "computercraft:blocks/printer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/printer_top_full.json b/src/main/resources/assets/computercraft/models/block/printer_top_full.json index bf614dbd6..845719279 100644 --- a/src/main/resources/assets/computercraft/models/block/printer_top_full.json +++ b/src/main/resources/assets/computercraft/models/block/printer_top_full.json @@ -1,8 +1,8 @@ -{ - "parent": "block/orientable", - "textures": { - "front": "computercraft:blocks/printer_front_top_tray", - "side": "computercraft:blocks/printer_side", - "top": "computercraft:blocks/printer_top" - } -} +{ + "parent": "block/orientable", + "textures": { + "front": "computercraft:blocks/printer_front_top_tray", + "side": "computercraft:blocks/printer_side", + "top": "computercraft:blocks/printer_top" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle.json b/src/main/resources/assets/computercraft/models/block/turtle.json index b0be21551..9bd9823da 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle.json +++ b/src/main/resources/assets/computercraft/models/block/turtle.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_base", - "textures": { - "texture": "computercraft:blocks/turtle" - } -} +{ + "parent": "computercraft:block/turtle_base", + "textures": { + "texture": "computercraft:blocks/turtle" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_base.json b/src/main/resources/assets/computercraft/models/block/turtle_base.json index 09f24a8db..902838577 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_base.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_base.json @@ -1,31 +1,31 @@ -{ - "parent": "block/block", - "textures": { - "particle": "#texture" - }, - "elements": [ - { - "from": [ 2, 2, 2 ], - "to": [ 14, 14, 13 ], - "faces": { - "down": { "uv": [ 2.75, 0, 5.75, 2.75 ], "texture": "#texture" }, - "up": { "uv": [ 5.75, 0, 8.75, 2.75 ], "texture": "#texture" }, - "north": { "uv": [ 8.5, 5.75, 11.5, 2.75 ], "texture": "#texture" }, - "south": { "uv": [ 2.75, 5.75, 5.75, 2.75 ], "texture": "#texture" }, - "west": { "uv": [ 0, 5.75, 2.75, 2.75 ], "texture": "#texture" }, - "east": { "uv": [ 5.75, 5.75, 8.5, 2.75 ], "texture": "#texture" } - } - }, - { - "from": [ 3, 6, 13 ], - "to": [ 13, 13, 15 ], - "faces": { - "down": { "uv": [ 9.25, 0, 11.75, 0.5 ], "texture": "#texture" }, - "up": { "uv": [ 11.75, 0, 14.25, 0.5 ], "texture": "#texture" }, - "south": { "uv": [ 9.25, 2.25, 11.75, 0.5 ], "texture": "#texture" }, - "west": { "uv": [ 8.75, 2.25, 9.25, 0.5 ], "texture": "#texture" }, - "east": { "uv": [ 11.75, 2.25, 12.25, 0.5 ], "texture": "#texture" } - } - } - ] -} +{ + "parent": "block/block", + "textures": { + "particle": "#texture" + }, + "elements": [ + { + "from": [ 2, 2, 2 ], + "to": [ 14, 14, 13 ], + "faces": { + "down": { "uv": [ 2.75, 0, 5.75, 2.75 ], "texture": "#texture" }, + "up": { "uv": [ 5.75, 0, 8.75, 2.75 ], "texture": "#texture" }, + "north": { "uv": [ 8.5, 5.75, 11.5, 2.75 ], "texture": "#texture" }, + "south": { "uv": [ 2.75, 5.75, 5.75, 2.75 ], "texture": "#texture" }, + "west": { "uv": [ 0, 5.75, 2.75, 2.75 ], "texture": "#texture" }, + "east": { "uv": [ 5.75, 5.75, 8.5, 2.75 ], "texture": "#texture" } + } + }, + { + "from": [ 3, 6, 13 ], + "to": [ 13, 13, 15 ], + "faces": { + "down": { "uv": [ 9.25, 0, 11.75, 0.5 ], "texture": "#texture" }, + "up": { "uv": [ 11.75, 0, 14.25, 0.5 ], "texture": "#texture" }, + "south": { "uv": [ 9.25, 2.25, 11.75, 0.5 ], "texture": "#texture" }, + "west": { "uv": [ 8.75, 2.25, 9.25, 0.5 ], "texture": "#texture" }, + "east": { "uv": [ 11.75, 2.25, 12.25, 0.5 ], "texture": "#texture" } + } + } + ] +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_left.json b/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_left.json index ce9fcc59f..ce211fd19 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_left.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_left.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_left", - "textures": { - "texture": "computercraft:blocks/crafty_upgrade" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": { + "texture": "computercraft:blocks/crafty_upgrade" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_right.json b/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_right.json index a65c82fca..2538a8c8f 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_right.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_crafting_table_right.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_right", - "textures": { - "texture": "computercraft:blocks/crafty_upgrade" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": { + "texture": "computercraft:blocks/crafty_upgrade" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_elf_overlay.json b/src/main/resources/assets/computercraft/models/block/turtle_elf_overlay.json index 48a769c79..af0a1d7a7 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_elf_overlay.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_elf_overlay.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_overlay", - "textures": { - "texture": "computercraft:blocks/turtle_elf_overlay" - } -} +{ + "parent": "computercraft:block/turtle_overlay", + "textures": { + "texture": "computercraft:blocks/turtle_elf_overlay" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_modem_off_left.json b/src/main/resources/assets/computercraft/models/block/turtle_modem_off_left.json index 9cafea5e2..e47b5f73c 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_modem_off_left.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_modem_off_left.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_left", - "textures": { - "texture": "computercraft:blocks/wireless_modem_face" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": { + "texture": "computercraft:blocks/wireless_modem_face" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_modem_off_right.json b/src/main/resources/assets/computercraft/models/block/turtle_modem_off_right.json index 391be4862..b237d4f48 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_modem_off_right.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_modem_off_right.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_right", - "textures": { - "texture": "computercraft:blocks/wireless_modem_face" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": { + "texture": "computercraft:blocks/wireless_modem_face" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_modem_on_left.json b/src/main/resources/assets/computercraft/models/block/turtle_modem_on_left.json index 5273ba2a0..4bcf579a4 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_modem_on_left.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_modem_on_left.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_left", - "textures": { - "texture": "computercraft:blocks/wireless_modem_face_on" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_left", + "textures": { + "texture": "computercraft:blocks/wireless_modem_face_on" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_modem_on_right.json b/src/main/resources/assets/computercraft/models/block/turtle_modem_on_right.json index a91fb20a2..e61d6e0ab 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_modem_on_right.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_modem_on_right.json @@ -1,6 +1,6 @@ -{ - "parent": "computercraft:block/turtle_upgrade_base_right", - "textures": { - "texture": "computercraft:blocks/wireless_modem_face_on" - } -} +{ + "parent": "computercraft:block/turtle_upgrade_base_right", + "textures": { + "texture": "computercraft:blocks/wireless_modem_face_on" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_overlay.json b/src/main/resources/assets/computercraft/models/block/turtle_overlay.json index 4d21b7e70..29ec0db35 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_overlay.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_overlay.json @@ -1,43 +1,43 @@ -{ - "parent": "block/block", - "textures": { - "particle": "#texture" - }, - "elements": [ - { - "from": [ 2, 2, 2 ], - "to": [ 14, 14, 13 ], - "faces": { - "down": { "uv": [ 2.75, 0, 5.75, 2.75 ], "texture": "#texture" }, - "up": { "uv": [ 5.75, 0, 8.75, 2.75 ], "texture": "#texture" }, - "north": { "uv": [ 8.5, 5.75, 11.5, 2.75 ], "texture": "#texture" }, - "south": { "uv": [ 2.75, 5.75, 5.75, 2.75 ], "texture": "#texture" }, - "west": { "uv": [ 0, 5.75, 2.75, 2.75 ], "texture": "#texture" }, - "east": { "uv": [ 5.75, 5.75, 8.5, 2.75 ], "texture": "#texture" } - } - }, - { - "from": [ 3, 6, 13 ], - "to": [ 13, 13, 15 ], - "faces": { - "down": { "uv": [ 9.25, 0, 11.75, 0.5 ], "texture": "#texture" }, - "up": { "uv": [ 11.75, 0, 14.25, 0.5 ], "texture": "#texture" }, - "south": { "uv": [ 9.25, 2.25, 11.75, 0.5 ], "texture": "#texture" }, - "west": { "uv": [ 8.75, 2.25, 9.25, 0.5 ], "texture": "#texture" }, - "east": { "uv": [ 11.75, 2.25, 12.25, 0.5 ], "texture": "#texture" } - } - }, - { - "from": [ 1.5, 1.5, 1.5 ], - "to": [ 14.5, 14.5, 13.5 ], - "faces": { - "down": { "uv": [ 2.75, 8, 5.75, 10.75 ], "texture": "#texture" }, - "up": { "uv": [ 5.75, 8, 8.75, 10.75 ], "texture": "#texture" }, - "north": { "uv": [ 8.5, 13.75, 11.5, 10.75 ], "texture": "#texture" }, - "south": { "uv": [ 2.75, 13.75, 5.75, 10.75 ], "texture": "#texture" }, - "west": { "uv": [ 0, 13.75, 2.75, 10.75 ], "texture": "#texture" }, - "east": { "uv": [ 5.75, 13.75, 8.5, 10.75 ], "texture": "#texture" } - } - } - ] -} +{ + "parent": "block/block", + "textures": { + "particle": "#texture" + }, + "elements": [ + { + "from": [ 2, 2, 2 ], + "to": [ 14, 14, 13 ], + "faces": { + "down": { "uv": [ 2.75, 0, 5.75, 2.75 ], "texture": "#texture" }, + "up": { "uv": [ 5.75, 0, 8.75, 2.75 ], "texture": "#texture" }, + "north": { "uv": [ 8.5, 5.75, 11.5, 2.75 ], "texture": "#texture" }, + "south": { "uv": [ 2.75, 5.75, 5.75, 2.75 ], "texture": "#texture" }, + "west": { "uv": [ 0, 5.75, 2.75, 2.75 ], "texture": "#texture" }, + "east": { "uv": [ 5.75, 5.75, 8.5, 2.75 ], "texture": "#texture" } + } + }, + { + "from": [ 3, 6, 13 ], + "to": [ 13, 13, 15 ], + "faces": { + "down": { "uv": [ 9.25, 0, 11.75, 0.5 ], "texture": "#texture" }, + "up": { "uv": [ 11.75, 0, 14.25, 0.5 ], "texture": "#texture" }, + "south": { "uv": [ 9.25, 2.25, 11.75, 0.5 ], "texture": "#texture" }, + "west": { "uv": [ 8.75, 2.25, 9.25, 0.5 ], "texture": "#texture" }, + "east": { "uv": [ 11.75, 2.25, 12.25, 0.5 ], "texture": "#texture" } + } + }, + { + "from": [ 1.5, 1.5, 1.5 ], + "to": [ 14.5, 14.5, 13.5 ], + "faces": { + "down": { "uv": [ 2.75, 8, 5.75, 10.75 ], "texture": "#texture" }, + "up": { "uv": [ 5.75, 8, 8.75, 10.75 ], "texture": "#texture" }, + "north": { "uv": [ 8.5, 13.75, 11.5, 10.75 ], "texture": "#texture" }, + "south": { "uv": [ 2.75, 13.75, 5.75, 10.75 ], "texture": "#texture" }, + "west": { "uv": [ 0, 13.75, 2.75, 10.75 ], "texture": "#texture" }, + "east": { "uv": [ 5.75, 13.75, 8.5, 10.75 ], "texture": "#texture" } + } + } + ] +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_left.json b/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_left.json index 691f2fa37..c90690fcf 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_left.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_left.json @@ -1,19 +1,19 @@ -{ - "parent": "block/block", - "textures": { - "particle": "#texture" - }, - "elements": [ - { - "from": [ 0.5, 4.5, 3.5 ], - "to": [ 2, 12.5, 11.5 ], - "faces": { - "down": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, - "up": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, - "north": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, - "south": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, - "west": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" } - } - } - ] -} +{ + "parent": "block/block", + "textures": { + "particle": "#texture" + }, + "elements": [ + { + "from": [ 0.5, 4.5, 3.5 ], + "to": [ 2, 12.5, 11.5 ], + "faces": { + "down": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, + "up": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, + "north": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, + "south": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, + "west": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" } + } + } + ] +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_right.json b/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_right.json index bd3aec9ef..6bb4e1271 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_right.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_upgrade_base_right.json @@ -1,19 +1,19 @@ -{ - "parent": "block/block", - "textures": { - "particle": "#texture" - }, - "elements": [ - { - "from": [ 14, 4.5, 3.5 ], - "to": [ 15.5, 12.5, 11.5 ], - "faces": { - "down": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, - "up": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, - "north": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, - "south": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, - "east": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" } - } - } - ] -} +{ + "parent": "block/block", + "textures": { + "particle": "#texture" + }, + "elements": [ + { + "from": [ 14, 4.5, 3.5 ], + "to": [ 15.5, 12.5, 11.5 ], + "faces": { + "down": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, + "up": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, + "north": { "uv": [ 13, 2, 16, 14 ], "texture": "#texture" }, + "south": { "uv": [ 0, 2, 3, 14 ], "texture": "#texture" }, + "east": { "uv": [ 2, 2, 14, 14 ], "texture": "#texture" } + } + } + ] +} diff --git a/src/main/resources/assets/computercraft/models/block/turtle_white.json b/src/main/resources/assets/computercraft/models/block/turtle_white.json index 29d1477b2..94fa87e6d 100644 --- a/src/main/resources/assets/computercraft/models/block/turtle_white.json +++ b/src/main/resources/assets/computercraft/models/block/turtle_white.json @@ -1,54 +1,54 @@ -{ - "parent": "computercraft:block/turtle_base", - "textures": { - "texture": "computercraft:blocks/turtle_white" - }, - "elements": [ - { - "from": [ 2, 2, 2 ], - "to": [ 14, 14, 13 ], - "faces": { - "down": { "uv": [ 2.75, 5.75, 5.75, 8.5 ], "texture": "#texture", "tintindex":0 }, - "up": { "uv": [ 5.75, 5.75, 8.75, 8.5 ], "texture": "#texture", "tintindex":0 }, - "north": { "uv": [ 8.5, 11.5, 11.5, 8.5 ], "texture": "#texture", "tintindex":0 }, - "south": { "uv": [ 2.75, 11.5, 5.75, 8.5 ], "texture": "#texture", "tintindex":0 }, - "west": { "uv": [ 0, 11.5, 2.75, 8.5 ], "texture": "#texture", "tintindex":0 }, - "east": { "uv": [ 5.75, 11.5, 8.5, 8.555 ], "texture": "#texture", "tintindex":0 } - } - }, - { - "from": [ 3, 6, 13 ], - "to": [ 13, 13, 15 ], - "faces": { - "down": { "uv": [ 9.25, 5.75, 11.75, 6.25 ], "texture": "#texture", "tintindex":0 }, - "up": { "uv": [ 11.75, 5.75, 14.25, 6.25 ], "texture": "#texture", "tintindex":0 }, - "south": { "uv": [ 9.25, 8, 11.75, 6.25 ], "texture": "#texture", "tintindex":0 }, - "west": { "uv": [ 8.75, 8, 9.25, 6.25 ], "texture": "#texture", "tintindex":0 }, - "east": { "uv": [ 11.75, 8, 12.25, 6.25 ], "texture": "#texture", "tintindex":0 } - } - }, - { - "from": [ 2, 2, 2 ], - "to": [ 14, 14, 13 ], - "faces": { - "down": { "uv": [ 2.75, 0, 5.75, 2.75 ], "texture": "#texture" }, - "up": { "uv": [ 5.75, 0, 8.75, 2.75 ], "texture": "#texture" }, - "north": { "uv": [ 8.5, 5.75, 11.5, 2.75 ], "texture": "#texture" }, - "south": { "uv": [ 2.75, 5.75, 5.75, 2.75 ], "texture": "#texture" }, - "west": { "uv": [ 0, 5.75, 2.75, 2.75 ], "texture": "#texture" }, - "east": { "uv": [ 5.75, 5.75, 8.5, 2.75 ], "texture": "#texture" } - } - }, - { - "from": [ 3, 6, 13 ], - "to": [ 13, 13, 15 ], - "faces": { - "down": { "uv": [ 9.25, 0, 11.75, 0.5 ], "texture": "#texture" }, - "up": { "uv": [ 11.75, 0, 14.25, 0.5 ], "texture": "#texture" }, - "south": { "uv": [ 9.25, 2.25, 11.75, 0.5 ], "texture": "#texture" }, - "west": { "uv": [ 8.75, 2.25, 9.25, 0.5 ], "texture": "#texture" }, - "east": { "uv": [ 11.75, 2.25, 12.25, 0.5 ], "texture": "#texture" } - } - } - ] -} +{ + "parent": "computercraft:block/turtle_base", + "textures": { + "texture": "computercraft:blocks/turtle_white" + }, + "elements": [ + { + "from": [ 2, 2, 2 ], + "to": [ 14, 14, 13 ], + "faces": { + "down": { "uv": [ 2.75, 5.75, 5.75, 8.5 ], "texture": "#texture", "tintindex":0 }, + "up": { "uv": [ 5.75, 5.75, 8.75, 8.5 ], "texture": "#texture", "tintindex":0 }, + "north": { "uv": [ 8.5, 11.5, 11.5, 8.5 ], "texture": "#texture", "tintindex":0 }, + "south": { "uv": [ 2.75, 11.5, 5.75, 8.5 ], "texture": "#texture", "tintindex":0 }, + "west": { "uv": [ 0, 11.5, 2.75, 8.5 ], "texture": "#texture", "tintindex":0 }, + "east": { "uv": [ 5.75, 11.5, 8.5, 8.555 ], "texture": "#texture", "tintindex":0 } + } + }, + { + "from": [ 3, 6, 13 ], + "to": [ 13, 13, 15 ], + "faces": { + "down": { "uv": [ 9.25, 5.75, 11.75, 6.25 ], "texture": "#texture", "tintindex":0 }, + "up": { "uv": [ 11.75, 5.75, 14.25, 6.25 ], "texture": "#texture", "tintindex":0 }, + "south": { "uv": [ 9.25, 8, 11.75, 6.25 ], "texture": "#texture", "tintindex":0 }, + "west": { "uv": [ 8.75, 8, 9.25, 6.25 ], "texture": "#texture", "tintindex":0 }, + "east": { "uv": [ 11.75, 8, 12.25, 6.25 ], "texture": "#texture", "tintindex":0 } + } + }, + { + "from": [ 2, 2, 2 ], + "to": [ 14, 14, 13 ], + "faces": { + "down": { "uv": [ 2.75, 0, 5.75, 2.75 ], "texture": "#texture" }, + "up": { "uv": [ 5.75, 0, 8.75, 2.75 ], "texture": "#texture" }, + "north": { "uv": [ 8.5, 5.75, 11.5, 2.75 ], "texture": "#texture" }, + "south": { "uv": [ 2.75, 5.75, 5.75, 2.75 ], "texture": "#texture" }, + "west": { "uv": [ 0, 5.75, 2.75, 2.75 ], "texture": "#texture" }, + "east": { "uv": [ 5.75, 5.75, 8.5, 2.75 ], "texture": "#texture" } + } + }, + { + "from": [ 3, 6, 13 ], + "to": [ 13, 13, 15 ], + "faces": { + "down": { "uv": [ 9.25, 0, 11.75, 0.5 ], "texture": "#texture" }, + "up": { "uv": [ 11.75, 0, 14.25, 0.5 ], "texture": "#texture" }, + "south": { "uv": [ 9.25, 2.25, 11.75, 0.5 ], "texture": "#texture" }, + "west": { "uv": [ 8.75, 2.25, 9.25, 0.5 ], "texture": "#texture" }, + "east": { "uv": [ 11.75, 2.25, 12.25, 0.5 ], "texture": "#texture" } + } + } + ] +} diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_off.json b/src/main/resources/assets/computercraft/models/block/wired_modem_off.json index a9730f02e..4207636fe 100644 --- a/src/main/resources/assets/computercraft/models/block/wired_modem_off.json +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_off.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/wired_modem_face", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/wired_modem_face", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_off_peripheral.json b/src/main/resources/assets/computercraft/models/block/wired_modem_off_peripheral.json index 19f3c44ce..3a90b109a 100644 --- a/src/main/resources/assets/computercraft/models/block/wired_modem_off_peripheral.json +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_off_peripheral.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/wired_modem_face_peripheral", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/wired_modem_face_peripheral", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_on.json b/src/main/resources/assets/computercraft/models/block/wired_modem_on.json index 0158ce2d1..66ccdf8b1 100644 --- a/src/main/resources/assets/computercraft/models/block/wired_modem_on.json +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_on.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/wired_modem_face_on", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/wired_modem_face_on", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wired_modem_on_peripheral.json b/src/main/resources/assets/computercraft/models/block/wired_modem_on_peripheral.json index 73d020351..b4bfdd334 100644 --- a/src/main/resources/assets/computercraft/models/block/wired_modem_on_peripheral.json +++ b/src/main/resources/assets/computercraft/models/block/wired_modem_on_peripheral.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/wired_modem_face_peripheral_on", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/wired_modem_face_peripheral_on", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wireless_modem_off.json b/src/main/resources/assets/computercraft/models/block/wireless_modem_off.json index d3d377d18..7ac41f7de 100644 --- a/src/main/resources/assets/computercraft/models/block/wireless_modem_off.json +++ b/src/main/resources/assets/computercraft/models/block/wireless_modem_off.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/wireless_modem_face", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/wireless_modem_face", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/block/wireless_modem_on.json b/src/main/resources/assets/computercraft/models/block/wireless_modem_on.json index f4c56c827..b000209a4 100644 --- a/src/main/resources/assets/computercraft/models/block/wireless_modem_on.json +++ b/src/main/resources/assets/computercraft/models/block/wireless_modem_on.json @@ -1,7 +1,7 @@ -{ - "parent": "computercraft:block/modem", - "textures": { - "front": "computercraft:blocks/wireless_modem_face_on", - "back": "computercraft:blocks/modem_back" - } -} +{ + "parent": "computercraft:block/modem", + "textures": { + "front": "computercraft:blocks/wireless_modem_face_on", + "back": "computercraft:blocks/modem_back" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/advanced_computer.json b/src/main/resources/assets/computercraft/models/item/advanced_computer.json index b2ff4dc35..680707b87 100644 --- a/src/main/resources/assets/computercraft/models/item/advanced_computer.json +++ b/src/main/resources/assets/computercraft/models/item/advanced_computer.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/advanced_computer_blinking" -} +{ + "parent": "computercraft:block/advanced_computer_blinking" +} diff --git a/src/main/resources/assets/computercraft/models/item/advanced_modem.json b/src/main/resources/assets/computercraft/models/item/advanced_modem.json index e17df8bc9..769ce4ebf 100644 --- a/src/main/resources/assets/computercraft/models/item/advanced_modem.json +++ b/src/main/resources/assets/computercraft/models/item/advanced_modem.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/advanced_modem_off" -} +{ + "parent": "computercraft:block/advanced_modem_off" +} diff --git a/src/main/resources/assets/computercraft/models/item/advanced_monitor.json b/src/main/resources/assets/computercraft/models/item/advanced_monitor.json index 3d97e1393..c56c09ac4 100644 --- a/src/main/resources/assets/computercraft/models/item/advanced_monitor.json +++ b/src/main/resources/assets/computercraft/models/item/advanced_monitor.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/advanced_monitor_item" -} +{ + "parent": "computercraft:block/advanced_monitor_item" +} diff --git a/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_blinking.json b/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_blinking.json index e9827fc84..9f80a939f 100644 --- a/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_blinking.json +++ b/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_blinking.json @@ -1,8 +1,8 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/pocket_computer_blink", - "layer1": "computercraft:items/pocket_computer_advanced", - "layer2": "computercraft:items/pocket_computer_light" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/pocket_computer_blink", + "layer1": "computercraft:items/pocket_computer_advanced", + "layer2": "computercraft:items/pocket_computer_light" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_on.json b/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_on.json index 581fe4c20..3dd83edf9 100644 --- a/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_on.json +++ b/src/main/resources/assets/computercraft/models/item/advanced_pocket_computer_on.json @@ -1,8 +1,8 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/pocket_computer_on", - "layer1": "computercraft:items/pocket_computer_advanced", - "layer2": "computercraft:items/pocket_computer_light" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/pocket_computer_on", + "layer1": "computercraft:items/pocket_computer_advanced", + "layer2": "computercraft:items/pocket_computer_light" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/book.json b/src/main/resources/assets/computercraft/models/item/book.json index 2ac563ec5..c90e874db 100644 --- a/src/main/resources/assets/computercraft/models/item/book.json +++ b/src/main/resources/assets/computercraft/models/item/book.json @@ -1,6 +1,6 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/book" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/book" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/command_computer.json b/src/main/resources/assets/computercraft/models/item/command_computer.json index ce5f442d1..91cb0ef72 100644 --- a/src/main/resources/assets/computercraft/models/item/command_computer.json +++ b/src/main/resources/assets/computercraft/models/item/command_computer.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/command_computer_blinking" -} +{ + "parent": "computercraft:block/command_computer_blinking" +} diff --git a/src/main/resources/assets/computercraft/models/item/disk.json b/src/main/resources/assets/computercraft/models/item/disk.json index cdcb70545..69ec8ebe6 100644 --- a/src/main/resources/assets/computercraft/models/item/disk.json +++ b/src/main/resources/assets/computercraft/models/item/disk.json @@ -1,7 +1,7 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/disk_frame", - "layer1": "computercraft:items/disk_colour" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/disk_frame", + "layer1": "computercraft:items/disk_colour" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/monitor.json b/src/main/resources/assets/computercraft/models/item/monitor.json index 1a2a92a4e..5e1f25699 100644 --- a/src/main/resources/assets/computercraft/models/item/monitor.json +++ b/src/main/resources/assets/computercraft/models/item/monitor.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/monitor_item" -} +{ + "parent": "computercraft:block/monitor_item" +} diff --git a/src/main/resources/assets/computercraft/models/item/pages.json b/src/main/resources/assets/computercraft/models/item/pages.json index 1509fb3bb..55ef26785 100644 --- a/src/main/resources/assets/computercraft/models/item/pages.json +++ b/src/main/resources/assets/computercraft/models/item/pages.json @@ -1,6 +1,6 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/page_bundle" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/page_bundle" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/pocket_computer_blinking.json b/src/main/resources/assets/computercraft/models/item/pocket_computer_blinking.json index fe3eb8ec7..82a43f458 100644 --- a/src/main/resources/assets/computercraft/models/item/pocket_computer_blinking.json +++ b/src/main/resources/assets/computercraft/models/item/pocket_computer_blinking.json @@ -1,8 +1,8 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/pocket_computer_blink", - "layer1": "computercraft:items/pocket_computer", - "layer2": "computercraft:items/pocket_computer_light" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/pocket_computer_blink", + "layer1": "computercraft:items/pocket_computer", + "layer2": "computercraft:items/pocket_computer_light" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/pocket_computer_on.json b/src/main/resources/assets/computercraft/models/item/pocket_computer_on.json index 10a845d54..463f8c2fa 100644 --- a/src/main/resources/assets/computercraft/models/item/pocket_computer_on.json +++ b/src/main/resources/assets/computercraft/models/item/pocket_computer_on.json @@ -1,8 +1,8 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/pocket_computer_on", - "layer1": "computercraft:items/pocket_computer", - "layer2": "computercraft:items/pocket_computer_light" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/pocket_computer_on", + "layer1": "computercraft:items/pocket_computer", + "layer2": "computercraft:items/pocket_computer_light" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/printer.json b/src/main/resources/assets/computercraft/models/item/printer.json index 546626411..13979ae67 100644 --- a/src/main/resources/assets/computercraft/models/item/printer.json +++ b/src/main/resources/assets/computercraft/models/item/printer.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/printer_empty" -} +{ + "parent": "computercraft:block/printer_empty" +} diff --git a/src/main/resources/assets/computercraft/models/item/printout.json b/src/main/resources/assets/computercraft/models/item/printout.json index 39027619e..8af82c201 100644 --- a/src/main/resources/assets/computercraft/models/item/printout.json +++ b/src/main/resources/assets/computercraft/models/item/printout.json @@ -1,6 +1,6 @@ -{ - "parent": "item/generated", - "textures": { - "layer0": "computercraft:items/page" - } -} +{ + "parent": "item/generated", + "textures": { + "layer0": "computercraft:items/page" + } +} diff --git a/src/main/resources/assets/computercraft/models/item/turtle_elf_overlay.json b/src/main/resources/assets/computercraft/models/item/turtle_elf_overlay.json index 414309448..7d7ebff97 100644 --- a/src/main/resources/assets/computercraft/models/item/turtle_elf_overlay.json +++ b/src/main/resources/assets/computercraft/models/item/turtle_elf_overlay.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/turtle_elf_overlay" -} +{ + "parent": "computercraft:block/turtle_elf_overlay" +} diff --git a/src/main/resources/assets/computercraft/models/item/turtle_white.json b/src/main/resources/assets/computercraft/models/item/turtle_white.json index 46b31459c..04b89922b 100644 --- a/src/main/resources/assets/computercraft/models/item/turtle_white.json +++ b/src/main/resources/assets/computercraft/models/item/turtle_white.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/turtle_white" -} +{ + "parent": "computercraft:block/turtle_white" +} diff --git a/src/main/resources/assets/computercraft/models/item/wired_modem.json b/src/main/resources/assets/computercraft/models/item/wired_modem.json index e012bb41e..a1d809c37 100644 --- a/src/main/resources/assets/computercraft/models/item/wired_modem.json +++ b/src/main/resources/assets/computercraft/models/item/wired_modem.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/wired_modem_off" -} +{ + "parent": "computercraft:block/wired_modem_off" +} diff --git a/src/main/resources/assets/computercraft/models/item/wireless_modem.json b/src/main/resources/assets/computercraft/models/item/wireless_modem.json index 2cc3f692d..9be5c29ad 100644 --- a/src/main/resources/assets/computercraft/models/item/wireless_modem.json +++ b/src/main/resources/assets/computercraft/models/item/wireless_modem.json @@ -1,3 +1,3 @@ -{ - "parent": "computercraft:block/wireless_modem_off" -} +{ + "parent": "computercraft:block/wireless_modem_off" +} diff --git a/src/main/resources/assets/computercraft/recipes/_factories.json b/src/main/resources/assets/computercraft/recipes/_factories.json index c9a49396f..86582e275 100644 --- a/src/main/resources/assets/computercraft/recipes/_factories.json +++ b/src/main/resources/assets/computercraft/recipes/_factories.json @@ -6,6 +6,6 @@ "computer_upgrade" : "dan200.computercraft.shared.computer.recipe.ComputerFamilyRecipe$Factory" }, "ingredients": { - "computer": "dan200.computercraft.shared.computer.recipe.ComputerIngredient$Factory" + "computer": "dan200.computercraft.shared.computer.recipe.ComputerIngredient$Factory" } } diff --git a/src/main/resources/assets/computercraft/recipes/skull_cloudy.json b/src/main/resources/assets/computercraft/recipes/skull_cloudy.json index 00c0fcf17..32f6d7346 100644 --- a/src/main/resources/assets/computercraft/recipes/skull_cloudy.json +++ b/src/main/resources/assets/computercraft/recipes/skull_cloudy.json @@ -4,8 +4,8 @@ { "item": "minecraft:skull", "data": 32767 }, { "item": "computercraft:peripheral", "data": 2 } ], - "result": { - "item": "minecraft:skull", + "result": { + "item": "minecraft:skull", "data": 3, "nbt": { "SkullOwner": "Cloudhunter" } } diff --git a/src/main/resources/assets/computercraft/recipes/skull_dan200.json b/src/main/resources/assets/computercraft/recipes/skull_dan200.json index d86d45fc3..1f28e0139 100644 --- a/src/main/resources/assets/computercraft/recipes/skull_dan200.json +++ b/src/main/resources/assets/computercraft/recipes/skull_dan200.json @@ -4,8 +4,8 @@ { "item": "minecraft:skull", "data": 32767 }, { "item": "computercraft:computer", "data": 0 } ], - "result": { - "item": "minecraft:skull", + "result": { + "item": "minecraft:skull", "data": 3, "nbt": { "SkullOwner": "dan200" } }