From 0de5969ec135dfa3b7d96bbdc201964f07142da0 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Thu, 23 Jan 2020 15:11:50 +0000 Subject: [PATCH] Lint whitespace during CI --- .github/workflows/main-ci.yml | 3 + .../computercraft/lua/rom/help/adventure.txt | 2 +- .../computercraft/lua/rom/help/alias.txt | 2 +- .../computercraft/lua/rom/help/chat.txt | 2 +- .../computercraft/lua/rom/help/clear.txt | 2 +- .../computercraft/lua/rom/help/coroutine.txt | 2 +- .../computercraft/lua/rom/help/dance.txt | 2 +- .../computercraft/lua/rom/help/disk.txt | 2 +- .../assets/computercraft/lua/rom/help/dj.txt | 2 +- .../computercraft/lua/rom/help/drive.txt | 2 +- .../computercraft/lua/rom/help/drives.txt | 2 +- .../computercraft/lua/rom/help/earth.txt | 2 +- .../computercraft/lua/rom/help/edit.txt | 2 +- .../computercraft/lua/rom/help/exit.txt | 2 +- .../assets/computercraft/lua/rom/help/gps.txt | 4 +- .../computercraft/lua/rom/help/gpsapi.txt | 2 +- .../computercraft/lua/rom/help/hello.txt | 2 +- .../computercraft/lua/rom/help/help.txt | 2 +- .../assets/computercraft/lua/rom/help/id.txt | 2 +- .../assets/computercraft/lua/rom/help/io.txt | 2 +- .../computercraft/lua/rom/help/keys.txt | 4 +- .../computercraft/lua/rom/help/list.txt | 2 +- .../assets/computercraft/lua/rom/help/lua.txt | 2 +- .../computercraft/lua/rom/help/math.txt | 2 +- .../computercraft/lua/rom/help/mkdir.txt | 2 +- .../computercraft/lua/rom/help/modems.txt | 2 +- .../computercraft/lua/rom/help/monitor.txt | 2 +- .../computercraft/lua/rom/help/multishell.txt | 2 +- .../assets/computercraft/lua/rom/help/os.txt | 2 +- .../computercraft/lua/rom/help/parallel.txt | 2 +- .../computercraft/lua/rom/help/pocket.txt | 2 +- .../computercraft/lua/rom/help/printers.txt | 2 +- .../lua/rom/help/programming.txt | 2 +- .../computercraft/lua/rom/help/reboot.txt | 2 +- .../computercraft/lua/rom/help/redstone.txt | 2 +- .../computercraft/lua/rom/help/refuel.txt | 2 +- .../computercraft/lua/rom/help/repeat.txt | 2 +- .../computercraft/lua/rom/help/shell.txt | 2 +- .../computercraft/lua/rom/help/shutdown.txt | 2 +- .../computercraft/lua/rom/help/string.txt | 2 +- .../computercraft/lua/rom/help/table.txt | 2 +- .../computercraft/lua/rom/help/time.txt | 2 +- .../computercraft/lua/rom/help/type.txt | 2 +- .../GopherAtl/battleship/battleship.lua | 248 +++++------ .../treasure/GravityScore/LuaIDE/luaide.lua | 46 +- .../lua/treasure/JTK/maze3d/maze2d.lua | 76 ++-- .../lua/treasure/JTK/maze3d/maze3d.lua | 64 +-- .../lua/treasure/Lyqyd/nsh/get.lua | 2 +- .../lua/treasure/Lyqyd/nsh/nsh.lua | 2 +- .../lua/treasure/Lyqyd/nsh/put.lua | 2 +- .../TheOriginalBIT/tictactoe/tictactoe.lua | 12 +- .../dan200/alongtimeago/alongtimeago.lua | 2 +- .../deprecated/GopherAtl/talk/talk.lua | 2 +- .../fredthead/protector/protector.lua | 220 +++++----- .../nitrogenfingers/goldrunner/goldrunner.lua | 156 +++---- .../nitrogenfingers/npaintpro/3dprint.lua | 16 +- .../nitrogenfingers/npaintpro/gameutils.lua | 92 ++-- .../nitrogenfingers/npaintpro/npaintpro.lua | 406 +++++++++--------- .../treasure/vilsol/gameoflife/gameoflife.lua | 2 +- src/test/resources/test-rom/mcfly.lua | 2 +- .../test-rom/spec/programs/delete_spec.lua | 2 +- .../test-rom/spec/programs/edit_spec.lua | 2 +- .../spec/programs/http/pastebin_spec.lua | 2 +- .../test-rom/spec/programs/id_spec.lua | 2 +- .../test-rom/spec/programs/motd_spec.lua | 2 +- .../test-rom/spec/programs/set_spec.lua | 6 +- .../test-rom/spec/programs/time_spec.lua | 2 +- tools/check-lines.py | 28 ++ 68 files changed, 759 insertions(+), 728 deletions(-) create mode 100644 tools/check-lines.py diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml index d0caedbf2..d499cd33f 100644 --- a/.github/workflows/main-ci.yml +++ b/.github/workflows/main-ci.yml @@ -37,3 +37,6 @@ jobs: test -f bin/illuaminate || wget -q -Obin/illuaminate https://squiddev.cc/illuaminate/bin/illuaminate chmod +x bin/illuaminate bin/illuaminate lint + + - name: Check whitespace + run: python3 tools/check-lines.py diff --git a/src/main/resources/assets/computercraft/lua/rom/help/adventure.txt b/src/main/resources/assets/computercraft/lua/rom/help/adventure.txt index bd1d982cf..6a9880eba 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/adventure.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/adventure.txt @@ -1 +1 @@ -adventure is a text adventure game for CraftOS. To navigate around the world of adventure, type simple instructions to the interpreter, for example: "go north", "punch tree", "craft planks", "mine coal with pickaxe", "hit creeper with sword" \ No newline at end of file +adventure is a text adventure game for CraftOS. To navigate around the world of adventure, type simple instructions to the interpreter, for example: "go north", "punch tree", "craft planks", "mine coal with pickaxe", "hit creeper with sword" 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 4d11d45ce..8f742bd3f 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/alias.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/alias.txt @@ -3,4 +3,4 @@ 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 +"alias" will list all current aliases. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/chat.txt b/src/main/resources/assets/computercraft/lua/rom/help/chat.txt index 1e99ca45c..035cb463d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/chat.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/chat.txt @@ -2,4 +2,4 @@ Surf the rednet superhighway with "chat", the networked chat program for CraftOS ex: "chat host forgecraft" will create a chatroom with the name "forgecraft" -"chat join forgecraft direwolf20" will connect to the chatroom with the name "forgecraft", using the nickname "direwolf20" \ No newline at end of file +"chat join forgecraft direwolf20" will connect to the chatroom with the name "forgecraft", using the nickname "direwolf20" diff --git a/src/main/resources/assets/computercraft/lua/rom/help/clear.txt b/src/main/resources/assets/computercraft/lua/rom/help/clear.txt index ea517ddb3..6e3258411 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/clear.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/clear.txt @@ -1 +1 @@ -clear clears the screen. \ No newline at end of file +clear clears the screen. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/coroutine.txt b/src/main/resources/assets/computercraft/lua/rom/help/coroutine.txt index 12b366bd2..93d8f7b04 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/coroutine.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/coroutine.txt @@ -1,2 +1,2 @@ coroutine is a standard Lua5.1 API. -Refer to http://www.lua.org/manual/5.1/ for more information. \ No newline at end of file +Refer to http://www.lua.org/manual/5.1/ for more information. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/dance.txt b/src/main/resources/assets/computercraft/lua/rom/help/dance.txt index 3c776f8f0..cef419ab9 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/dance.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/dance.txt @@ -1 +1 @@ -dance is a program for Turtles. Turtles love to get funky. \ No newline at end of file +dance is a program for Turtles. Turtles love to get funky. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/disk.txt b/src/main/resources/assets/computercraft/lua/rom/help/disk.txt index f47bc625c..3c1348e6b 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/disk.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/disk.txt @@ -14,4 +14,4 @@ disk.getID( drive ) Events fired by the disk API: "disk" when a disk or other item is inserted into a disk drive. Argument is the name of the drive "disk_eject" when a disk is removed from a disk drive. Argument is the name of the drive -Type "help events" to learn about the event system. \ No newline at end of file +Type "help events" to learn about the event system. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/dj.txt b/src/main/resources/assets/computercraft/lua/rom/help/dj.txt index 2c7a02bd1..c41dccc6e 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/dj.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/dj.txt @@ -3,4 +3,4 @@ dj plays Music Discs from disk drives attached to the computer. ex: "dj" or "dj play" plays a random disc. "dj play left" plays the disc in the drive on the left of the computer. -"dj stop" stops the current disc. \ No newline at end of file +"dj stop" stops the current disc. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/drive.txt b/src/main/resources/assets/computercraft/lua/rom/help/drive.txt index 397c98c30..eb6472a8e 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/drive.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/drive.txt @@ -2,4 +2,4 @@ drive tells you which disk drive the current or specified directory is located i ex: "drive" tell you the disk drive of the current directory. -"drive foo" tells you the disk drive of the subdirectory "foo" \ No newline at end of file +"drive foo" tells you the disk drive of the subdirectory "foo" diff --git a/src/main/resources/assets/computercraft/lua/rom/help/drives.txt b/src/main/resources/assets/computercraft/lua/rom/help/drives.txt index 6f15f40f3..b793f8e7d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/drives.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/drives.txt @@ -16,4 +16,4 @@ getDiskID() Events fired by the Disk Drive: "disk" when a disk or other item is inserted into the drive. Argument is the name of the drive. "disk_eject" when a disk is removed from a drive. Argument is the name of the drive. -Type "help events" to learn about the event system. \ No newline at end of file +Type "help events" to learn about the event system. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/earth.txt b/src/main/resources/assets/computercraft/lua/rom/help/earth.txt index d1b452673..b9842d064 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/earth.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/earth.txt @@ -1 +1 @@ -Mostly harmless. \ No newline at end of file +Mostly harmless. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/edit.txt b/src/main/resources/assets/computercraft/lua/rom/help/edit.txt index 31d044496..6e89a7e08 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/edit.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/edit.txt @@ -1,4 +1,4 @@ edit is a text editor for creating or modifying programs or text files. After creating a program with edit, type its filename in the shell to run it. You can open any of the builtin programs with edit to learn how to program. ex: -"edit hello" opens a file called "hello" for editing. \ No newline at end of file +"edit hello" opens a file called "hello" for editing. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/exit.txt b/src/main/resources/assets/computercraft/lua/rom/help/exit.txt index 9b6c4347f..891745139 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/exit.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/exit.txt @@ -1 +1 @@ -exit will exit the current shell. \ No newline at end of file +exit will exit the current shell. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/gps.txt b/src/main/resources/assets/computercraft/lua/rom/help/gps.txt index e3e14b566..35b833580 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/gps.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/gps.txt @@ -4,7 +4,7 @@ Type "help gpsapi" for help using GPS functions in lua programs. ex: "gps locate" will connect to nearby GPS servers, and try to determine the position of the computer or turtle. "gps host" will try to determine the position, and host a GPS server if successful. -"gps host 10 20 30" will host a GPS server, using the manually entered position 10,20,30. +"gps host 10 20 30" will host a GPS server, using the manually entered position 10,20,30. Take care when manually entering host positions. If the positions entered into multiple GPS hosts -are not consistent, the results of locate calls will be incorrect. \ No newline at end of file +are not consistent, the results of locate calls will be incorrect. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/gpsapi.txt b/src/main/resources/assets/computercraft/lua/rom/help/gpsapi.txt index 7bb9fe601..83116f669 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/gpsapi.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/gpsapi.txt @@ -1,4 +1,4 @@ Functions in the GPS API: gps.locate( timeout ) -The locate function will send a signal to nearby gps servers, and wait for responses before the timeout. If it receives enough responses to determine this computers position then x, y and z co-ordinates will be returned, otherwise it will return nil. If GPS hosts do not have their positions configured correctly, results will be inaccurate. \ No newline at end of file +The locate function will send a signal to nearby gps servers, and wait for responses before the timeout. If it receives enough responses to determine this computers position then x, y and z co-ordinates will be returned, otherwise it will return nil. If GPS hosts do not have their positions configured correctly, results will be inaccurate. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/hello.txt b/src/main/resources/assets/computercraft/lua/rom/help/hello.txt index a58ae9908..0f2017aad 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/hello.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/hello.txt @@ -1 +1 @@ -hello prints the text "Hello World!" to the screen. \ No newline at end of file +hello prints the text "Hello World!" to the screen. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/help.txt b/src/main/resources/assets/computercraft/lua/rom/help/help.txt index fe85a2370..29c0b3a32 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/help.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/help.txt @@ -1,4 +1,4 @@ help is the help tool you're currently using. Type "help index" to see all help topics. Type "help" to see the help intro. -Type "help helpapi" for information on the help Lua API. \ No newline at end of file +Type "help helpapi" for information on the help Lua API. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/id.txt b/src/main/resources/assets/computercraft/lua/rom/help/id.txt index f87492bee..e23f1290a 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/id.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/id.txt @@ -2,4 +2,4 @@ id prints the unique identifier of this computer, or a Disk in an attached Disk ex: "id" will print this Computers ID and label -"id left" will print the ID and label of the disk in the Disk Drive on the left \ No newline at end of file +"id left" will print the ID and label of the disk in the Disk Drive on the left diff --git a/src/main/resources/assets/computercraft/lua/rom/help/io.txt b/src/main/resources/assets/computercraft/lua/rom/help/io.txt index f71cca207..8da72cbd1 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/io.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/io.txt @@ -1,2 +1,2 @@ io is a standard Lua5.1 API, reimplemented for CraftOS. Not all the features are availiable. -Refer to http://www.lua.org/manual/5.1/ for more information. \ No newline at end of file +Refer to http://www.lua.org/manual/5.1/ for more information. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/keys.txt b/src/main/resources/assets/computercraft/lua/rom/help/keys.txt index 0adb2016c..a46f10731 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/keys.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/keys.txt @@ -3,7 +3,7 @@ The keys API contains constants for all the key codes that can be returned by th Example usage: local sEvent, nKey = os.pullEvent() if sEvent == "key" and nKey == keys.enter then - -- Do something + -- Do something end -See http://www.minecraftwiki.net/wiki/Key_codes, or the source code, for a complete reference. \ No newline at end of file +See http://www.minecraftwiki.net/wiki/Key_codes, or the source code, for a complete reference. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/list.txt b/src/main/resources/assets/computercraft/lua/rom/help/list.txt index 9ab8cd06c..16c0fdf52 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/list.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/list.txt @@ -1 +1 @@ -ls will list all the directories and files in the current location. Use "type" to find out if an item is a file or a directory. \ No newline at end of file +ls will list all the directories and files in the current location. Use "type" to find out if an item is a file or a directory. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/lua.txt b/src/main/resources/assets/computercraft/lua/rom/help/lua.txt index da1cb187a..4d164c8b0 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/lua.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/lua.txt @@ -1 +1 @@ -lua is an interactive prompt for the lua programming language. It's a useful tool for learning the language. \ No newline at end of file +lua is an interactive prompt for the lua programming language. It's a useful tool for learning the language. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/math.txt b/src/main/resources/assets/computercraft/lua/rom/help/math.txt index ed3da1e49..35ed34827 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/math.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/math.txt @@ -1,2 +1,2 @@ math is a standard Lua5.1 API. -Refer to http://www.lua.org/manual/5.1/ for more information. \ No newline at end of file +Refer to http://www.lua.org/manual/5.1/ for more information. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/mkdir.txt b/src/main/resources/assets/computercraft/lua/rom/help/mkdir.txt index e7268dc63..e5e8fdab3 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/mkdir.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/mkdir.txt @@ -2,4 +2,4 @@ mkdir creates a directory in the current location. ex: "mkdir foo" creates a directory named "foo". -"mkdir ../foo" creates a directory named "foo" in the directory above the current directory. \ No newline at end of file +"mkdir ../foo" creates a directory named "foo" in the directory above the current directory. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/modems.txt b/src/main/resources/assets/computercraft/lua/rom/help/modems.txt index 960bc5058..281a87582 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/modems.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/modems.txt @@ -9,4 +9,4 @@ transmit( channel, replyChannel, message ) isWireless() Events fired by Modems: -"modem_message" when a message is received on an open channel. Arguments are name, channel, replyChannel, message, distance \ No newline at end of file +"modem_message" when a message is received on an open channel. Arguments are name, channel, replyChannel, message, distance diff --git a/src/main/resources/assets/computercraft/lua/rom/help/monitor.txt b/src/main/resources/assets/computercraft/lua/rom/help/monitor.txt index 6837b38d4..028a8bc80 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/monitor.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/monitor.txt @@ -3,4 +3,4 @@ Type "help monitors" for help using monitors as peripherals in lua programs. ex: "monitor left hello" will run the "hello" program on the monitor to the left of the computer. -"monitor top edit foo" will run the edit program on the top monitor, editing the file "foo". \ No newline at end of file +"monitor top edit foo" will run the edit program on the top monitor, editing the file "foo". diff --git a/src/main/resources/assets/computercraft/lua/rom/help/multishell.txt b/src/main/resources/assets/computercraft/lua/rom/help/multishell.txt index b16243112..8fbf8d75b 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/multishell.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/multishell.txt @@ -1,2 +1,2 @@ multishell is the toplevel program on Advanced Computers which manages background tabs. -Type "help shellapi" for information about the shell lua api. \ No newline at end of file +Type "help shellapi" for information about the shell lua api. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/os.txt b/src/main/resources/assets/computercraft/lua/rom/help/os.txt index 442d4a89b..b57bef8da 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/os.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/os.txt @@ -23,4 +23,4 @@ os.reboot() Events emitted by the os API: "timer" when a timeout started by os.startTimer() completes. Argument is the token returned by os.startTimer(). "alarm" when a time passed to os.setAlarm() is reached. Argument is the token returned by os.setAlarm(). -Type "help events" to learn about the event system. \ No newline at end of file +Type "help events" to learn about the event system. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/parallel.txt b/src/main/resources/assets/computercraft/lua/rom/help/parallel.txt index 822dd47a7..4b958c442 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/parallel.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/parallel.txt @@ -1,4 +1,4 @@ Functions in the Parallel API: parallel.waitForAny( function1, function2, ... ) parallel.waitForAll( function1, function2, ... ) -These methods provide an easy way to run multiple lua functions simultaneously. \ No newline at end of file +These methods provide an easy way to run multiple lua functions simultaneously. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/pocket.txt b/src/main/resources/assets/computercraft/lua/rom/help/pocket.txt index fc498c669..72925bdea 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/pocket.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/pocket.txt @@ -3,4 +3,4 @@ Functions in the pocket API: pocket.equipBack() pocket.unequipBack() -When equipping upgrades, it will search your inventory for a suitable upgrade, starting in the selected slot. If one cannot be found then it will check your offhand. \ No newline at end of file +When equipping upgrades, it will search your inventory for a suitable upgrade, starting in the selected slot. If one cannot be found then it will check your offhand. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/printers.txt b/src/main/resources/assets/computercraft/lua/rom/help/printers.txt index a855ab972..73295344e 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/printers.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/printers.txt @@ -9,4 +9,4 @@ getPageSize() setCursorPos( x, y ) getCursorPos() write( text ) -endPage() \ No newline at end of file +endPage() diff --git a/src/main/resources/assets/computercraft/lua/rom/help/programming.txt b/src/main/resources/assets/computercraft/lua/rom/help/programming.txt index 68e8621fc..4a14fb2e3 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/programming.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/programming.txt @@ -8,4 +8,4 @@ To quickly shutdown a computer, hold Ctrl+S for 1 second. To quickly reboot a computer, hold Ctrl+R for 1 second. To learn about the programming APIs availiable, type "apis" or "help apis". -If you get stuck, visit the forums at http://www.computercraft.info/ for advice and tutorials. \ No newline at end of file +If you get stuck, visit the forums at http://www.computercraft.info/ for advice and tutorials. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/reboot.txt b/src/main/resources/assets/computercraft/lua/rom/help/reboot.txt index 6cae9184d..525c9c979 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/reboot.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/reboot.txt @@ -1,2 +1,2 @@ reboot will turn the computer off and on again. -You can also hold Ctrl+R at any time to quickly reboot. \ No newline at end of file +You can also hold Ctrl+R at any time to quickly reboot. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/redstone.txt b/src/main/resources/assets/computercraft/lua/rom/help/redstone.txt index ea76f7827..ce86bb6b4 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/redstone.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/redstone.txt @@ -6,4 +6,4 @@ ex: "redstone set right blue false" turns off the blue wire in the bundled cable on the right redstone output. "redstone pulse front 10 1" emits 10 one second redstone pulses on the front redstone output. -Type "help redstoneapi" or "help rs" for information on the redstone Lua API. \ No newline at end of file +Type "help redstoneapi" or "help rs" for information on the redstone Lua API. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/refuel.txt b/src/main/resources/assets/computercraft/lua/rom/help/refuel.txt index 9fab3fa18..86e806b2c 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/refuel.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/refuel.txt @@ -3,4 +3,4 @@ refuel is a program for Turtles. Refuel will consume items from the inventory as ex: "refuel" will refuel with at most one fuel item "refuel 10" will refuel with at most 10 fuel items -"refuel all" will refuel with as many fuel items as possible \ No newline at end of file +"refuel all" will refuel with as many fuel items as possible diff --git a/src/main/resources/assets/computercraft/lua/rom/help/repeat.txt b/src/main/resources/assets/computercraft/lua/rom/help/repeat.txt index f65697d4a..a08ebf8da 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/repeat.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/repeat.txt @@ -1 +1 @@ -repeat is a program for repeating rednet messages across long distances. To use, connect 2 or more modems to a computer and run the "repeat" program; from then on, any rednet message sent from any computer in wireless range or connected by networking cable to either of the modems will be repeated to those on the other side. \ No newline at end of file +repeat is a program for repeating rednet messages across long distances. To use, connect 2 or more modems to a computer and run the "repeat" program; from then on, any rednet message sent from any computer in wireless range or connected by networking cable to either of the modems will be repeated to those on the other side. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/shell.txt b/src/main/resources/assets/computercraft/lua/rom/help/shell.txt index 080b8390a..9be848561 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/shell.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/shell.txt @@ -1,2 +1,2 @@ shell is the toplevel program which interprets commands and runs program. -Type "help shellapi" for information about the shell lua api. \ No newline at end of file +Type "help shellapi" for information about the shell lua api. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/shutdown.txt b/src/main/resources/assets/computercraft/lua/rom/help/shutdown.txt index 4a63391db..8bc734fc9 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/shutdown.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/shutdown.txt @@ -1 +1 @@ -shutdown will turn off the computer. \ No newline at end of file +shutdown will turn off the computer. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/string.txt b/src/main/resources/assets/computercraft/lua/rom/help/string.txt index 5dfe5d501..ce30dc916 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/string.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/string.txt @@ -1,2 +1,2 @@ string is a standard Lua5.1 API. -Refer to http://www.lua.org/manual/5.1/ for more information. \ No newline at end of file +Refer to http://www.lua.org/manual/5.1/ for more information. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/table.txt b/src/main/resources/assets/computercraft/lua/rom/help/table.txt index 80760d0de..d6943d035 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/table.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/table.txt @@ -1,2 +1,2 @@ table is a standard Lua5.1 API. -Refer to http://www.lua.org/manual/5.1/ for more information. \ No newline at end of file +Refer to http://www.lua.org/manual/5.1/ for more information. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/time.txt b/src/main/resources/assets/computercraft/lua/rom/help/time.txt index ae5113599..4a67ab57d 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/time.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/time.txt @@ -1 +1 @@ -time prints the current time of day. \ No newline at end of file +time prints the current time of day. diff --git a/src/main/resources/assets/computercraft/lua/rom/help/type.txt b/src/main/resources/assets/computercraft/lua/rom/help/type.txt index 74a4e8e79..1c8cad512 100644 --- a/src/main/resources/assets/computercraft/lua/rom/help/type.txt +++ b/src/main/resources/assets/computercraft/lua/rom/help/type.txt @@ -1 +1 @@ -type determines the type of a file or directory. Prints "file", "directory" or "does not exist". \ No newline at end of file +type determines the type of a file or directory. Prints "file", "directory" or "does not exist". diff --git a/src/main/resources/assets/computercraft/lua/treasure/GopherAtl/battleship/battleship.lua b/src/main/resources/assets/computercraft/lua/treasure/GopherAtl/battleship/battleship.lua index 03431406c..8d48eaaf5 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/GopherAtl/battleship/battleship.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/GopherAtl/battleship/battleship.lua @@ -1,8 +1,8 @@ --[[ battleship, - + by GopherAtl, 2013 - + Do whatever you want, just don't judge me by what a mess this code is. --]] @@ -17,21 +17,21 @@ 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) @@ -39,9 +39,9 @@ local function doColor_mono(text,background) else term.setTextColor(colors.white) term.setBackgroundColor(colors.black) - end + end end - + local function doScreenColor() if term.isColor() then doColor(colors.white,colors.lightGray) @@ -49,16 +49,16 @@ local function doScreenColor() 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) @@ -68,7 +68,7 @@ local function quit() print() error() end - + local foundModem=false --find modem for k,v in pairs(redstone.getSides()) do @@ -81,17 +81,17 @@ for k,v in pairs(redstone.getSides()) do 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) @@ -108,13 +108,13 @@ while true do 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 @@ -131,7 +131,7 @@ if action=="join" then end end local joined=false - + if opponentID then print("Joining game!") rednet.send(opponentID,"bs start") @@ -142,7 +142,7 @@ 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() + 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..") @@ -154,7 +154,7 @@ elseif action=="host" then quit() end end - + if opponentID then rednet.send(opponentID,"bs accept "..myName) local timeout=os.startTimer(1) @@ -166,17 +166,17 @@ elseif action=="host" then elseif event=="timer" and p1==timeout then print("player joined another game. Waiting for another...") opponentID=nil - break + 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}, @@ -184,12 +184,12 @@ local ships={ {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]={} @@ -199,8 +199,8 @@ for i=1,10 do oppGrid[i][j]={hit=false,ship=false} end end - -local function drawShipsToGrid(ships,grid) + +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 @@ -211,18 +211,18 @@ local function drawShipsToGrid(ships,grid) end end end - + local function drawShotToGrid(shot,grid) grid[shot[1]][shot[2]].shot=true - grid[shot[1]][shot[2]].hit=shot[3] + 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 - + end + local shot={x,y,tile.ship} drawShotToGrid(shot,grid) if tile.ship then @@ -232,12 +232,12 @@ local function makeShot(x,y,grid) end end return shot -end - - +end + + local function drawTile(scrX,scrY,tile) term.setCursorPos(scrX,scrY) - + if tile.ship then if tile.shot then doColor(colors.red,colors.gray) @@ -259,31 +259,31 @@ local function drawTile(scrX,scrY,tile) 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) + 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]) + 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 @@ -303,8 +303,8 @@ function moveTargetIndicator(newX,newY) term.write("^") term.setCursorPos(targetGridBounds.minX+newX-1,targetGridBounds.minY-3) term.write("v") - - targetX=newX + + targetX=newX end if newY~=targetY then --space over old @@ -319,11 +319,11 @@ function moveTargetIndicator(newX,newY) 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)) + 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) @@ -331,18 +331,18 @@ function moveTargetIndicator(newX,newY) 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 @@ -358,9 +358,9 @@ local function printLog() 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 @@ -371,31 +371,31 @@ local function drawShip(size,align,x,y,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, @@ -404,20 +404,20 @@ local function getPointBounds(x,y) maxY=y, } end - + local function boundsIntersect(boundsA,boundsB) return not ( boundsA.minX>boundsB.maxX or boundsA.maxXboundsB.maxY or boundsA.maxY="0" and p1<="9" then local t=string.byte(p1)-string.byte("0") if t==0 then t=10 end - moveTargetIndicator(t,targetY) + moveTargetIndicator(t,targetY) end elseif e=="key" then if p1==keys.enter or p1==keys.space and targetX and targetY then @@ -736,7 +736,7 @@ local function runGame() moveTargetIndicator(math.max(targetX-1,1),targetY) elseif p1==keys.right then moveTargetIndicator(math.min(targetX+1,10),targetY) - end + end end end --shot sent, wait for my turn to resolve (top coroutine will switch turns and draw the hit to the grid) @@ -746,12 +746,12 @@ local function runGame() 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 @@ -762,12 +762,12 @@ for k,v in pairs(originalTerm) do 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 @@ -791,7 +791,7 @@ while true do opponentReady=true os.queueEvent("kickcoroutine") elseif cmd=="cointoss" then - myTurn=args=="true" + myTurn=args=="true" if myTurn then setStatusLine(2,"Your turn, take your shot!") else @@ -807,11 +807,11 @@ while true do 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) + 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(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 @@ -838,7 +838,7 @@ while true do setStatusLine(2,"Waiting for opponent...") os.queueEvent("kickcoroutine") end - + elseif cmd=="win" then --we won! setStatusLine(3,"You won the game! Congratulations!") @@ -852,24 +852,24 @@ while true do 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/GravityScore/LuaIDE/luaide.lua b/src/main/resources/assets/computercraft/lua/treasure/GravityScore/LuaIDE/luaide.lua index b8de7b147..7ec78c299 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/GravityScore/LuaIDE/luaide.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/GravityScore/LuaIDE/luaide.lua @@ -1,8 +1,8 @@ --- +-- -- Lua IDE -- Made by GravityScore --- +-- -- -------- Variables @@ -44,7 +44,7 @@ local function isAdvanced() return term.isColor and term.isColor() end local function modRead(properties) local w, h = term.getSize() - local defaults = {replaceChar = nil, history = nil, visibleLength = nil, textLength = nil, + local defaults = {replaceChar = nil, history = nil, visibleLength = nil, textLength = nil, liveUpdates = nil, exitOnKey = nil} if not properties then properties = {} end for k, v in pairs(defaults) do if not properties[k] then properties[k] = v end end @@ -58,7 +58,7 @@ local function modRead(properties) local function redraw(repl) local scroll = 0 - if properties.visibleLength and sx + pos > properties.visibleLength + 1 then + if properties.visibleLength and sx + pos > properties.visibleLength + 1 then scroll = (sx + pos) - (properties.visibleLength + 1) end @@ -133,9 +133,9 @@ local function modRead(properties) elseif (but == keys.up or but == keys.down) and properties.history then redraw(" ") if but == keys.up then - if historyPos == nil and #properties.history > 0 then + if historyPos == nil and #properties.history > 0 then historyPos = #properties.history - elseif historyPos > 1 then + elseif historyPos > 1 then historyPos = historyPos - 1 end elseif but == keys.down then @@ -173,9 +173,9 @@ local function modRead(properties) elseif but == keys["end"] then pos = line:len() redraw() - elseif properties.exitOnKey then - if but == properties.exitOnKey or (properties.exitOnKey == "control" and - (but == 29 or but == 157)) then + elseif properties.exitOnKey then + if but == properties.exitOnKey or (properties.exitOnKey == "control" and + (but == 29 or but == 157)) then term.setCursorBlink(false) return nil end @@ -296,7 +296,7 @@ end local function centerRead(wid, begt) local function liveUpdate(line, e, but, x, y, p4, p5) - if isAdvanced() and e == "mouse_click" and x >= w/2 - wid/2 and x <= w/2 - wid/2 + 10 + if isAdvanced() and e == "mouse_click" and x >= w/2 - wid/2 and x <= w/2 - wid/2 + 10 and y >= 13 and y <= 15 then return true, "" end @@ -707,7 +707,7 @@ languages.brainfuck.mapLoops = function(code) loopLocations[loc] = true elseif let == "]" then local found = false - for i = loc, 1, -1 do + for i = loc, 1, -1 do if loopLocations[i] == true then loopLocations[i] = loc found = true @@ -877,7 +877,7 @@ local function run(path, lines, useArgs) local s = centerRead(w - 13, fs.getName(path) .. " ") for m in string.gmatch(s, "[^ \t]+") do ar[#ar + 1] = m:gsub("^%s*(.-)%s*$", "%1") end end - + saveFile(path, lines) term.setCursorBlink(false) term.setBackgroundColor(colors.black) @@ -949,7 +949,7 @@ local function run(path, lines, useArgs) term.setCursorPos(5, 14) term.write(b) end - + local opt = prompt({{"Error Help", w/2 - 15, 17}, {"Go To Line", w/2 + 2, 17}}, "horizontal") if opt == "Error Help" then @@ -1459,7 +1459,7 @@ end local function writeHighlighted(line) if curLanguage == languages.lua then - while line:len() > 0 do + while line:len() > 0 do line = attemptToHighlight(line, "^%-%-%[%[.-%]%]", colors[theme.comment]) or attemptToHighlight(line, "^%-%-.*", colors[theme.comment]) or attemptToHighlight(line, "^\".*[^\\]\"", colors[theme.string]) or @@ -1491,7 +1491,7 @@ local function draw() for i = 1, edh do local a = lines[scrolly + i] if a then - local ln = string.rep(" ", offx - 1 - tostring(scrolly + i):len()) .. tostring(scrolly + i) + local ln = string.rep(" ", offx - 1 - tostring(scrolly + i):len()) .. tostring(scrolly + i) local l = a:sub(scrollx + 1, edw + scrollx + 1) ln = ln .. ":" @@ -1541,7 +1541,7 @@ local function drawLine(...) for _, ly in pairs(ls) do local a = lines[ly] if a then - local ln = string.rep(" ", offx - 1 - tostring(ly):len()) .. tostring(ly) + local ln = string.rep(" ", offx - 1 - tostring(ly):len()) .. tostring(ly) local l = a:sub(scrollx + 1, edw + scrollx + 1) ln = ln .. ":" @@ -1651,7 +1651,7 @@ local function edit(path) draw() term.setCursorPos(x + offx, y + offy) term.setCursorBlink(true) - + -- Main loop local tid = os.startTimer(3) while true do @@ -1692,8 +1692,8 @@ local function edit(path) if f then table.insert(lines, y + 1, string.rep(" ", spaces + 2)) if not f:find("else", 1, true) and not f:find("elseif", 1, true) then - table.insert(lines, y + 2, string.rep(" ", spaces) .. - (f:find("repeat", 1, true) and "until " or f:find("{", 1, true) and "}" or + table.insert(lines, y + 2, string.rep(" ", spaces) .. + (f:find("repeat", 1, true) and "until " or f:find("{", 1, true) and "}" or "end")) end x, y = spaces + 3, y + 1 @@ -1771,7 +1771,7 @@ local function edit(path) x = math.min(lines[y]:len() + 1, x) cursorLoc(x, y, true) end - elseif e == "char" and allowEditorEvent and (displayCode and true or + elseif e == "char" and allowEditorEvent and (displayCode and true or y + scrolly - 1 == liveErr.line) then local shouldIgnore = false for k, v in pairs(liveCompletions) do @@ -2083,7 +2083,7 @@ local function changeTheme() sleep(1.6) return "menu" end - + term.write("LuaIDE - Could Not Load Theme!") fs.delete("/.LuaIDE_temp_theme_file") sleep(1.6) @@ -2100,7 +2100,7 @@ local function settings() title("LuaIDE - Settings") local opt = prompt({{"Change Theme", w/2 - 17, 8}, {"Return to Menu", w/2 - 19, 13}, - --[[{"Check for Updates", w/2 + 2, 8},]] {"Exit IDE", w/2 + 2, 13, bg = colors[theme.err], + --[[{"Check for Updates", w/2 + 2, 8},]] {"Exit IDE", w/2 + 2, 13, bg = colors[theme.err], highlight = colors[theme.errHighlight]}}, "vertical", true) if opt == "Change Theme" then return changeTheme() -- elseif opt == "Check for Updates" then return update() @@ -2189,7 +2189,7 @@ if err and not err:find("Terminated") then term.write("Please report this error to") term.setCursorPos(6, cy + 3) term.write("GravityScore! ") - + term.setBackgroundColor(colors[theme.background]) if isAdvanced() then centerPrint("Click to Exit...", h - 1) else centerPrint("Press Any Key to Exit...", h - 1) end diff --git a/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze2d.lua b/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze2d.lua index ccc85fb29..be942df95 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze2d.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze2d.lua @@ -1,6 +1,6 @@ --[[ Project info: - + Name: Maze Creator: Jesusthekiller Language: Lua (CC) @@ -24,7 +24,7 @@ --[[ LICENSE: - + Maze Copyright (c) 2013 Jesusthekiller @@ -73,7 +73,7 @@ repeat cwrite("Enter maze size (5-99):") size = read() - + size = tonumber(size) if not size then size = 0 @@ -82,18 +82,18 @@ until size > 4 and size < 100 -- The generate local function mazeGen(mx, my) - + --[[ Format: - + maze.x.y.(1/2/3/4) = true/false - + 1 - top 2 - bottom 3 - right 4 - left ]]-- - + local maze = {} for i = 1, mx do maze[i] = {} @@ -116,26 +116,26 @@ local function mazeGen(mx, my) local intact = {} local x = curr.x local y = curr.y - + if x - 1 >= 1 and maze[x-1][y][1] and maze[x-1][y][2] and maze[x-1][y][3] and maze[x-1][y][4] then -- Check for full cells intact[#intact+1] = {x-1, y, 1} end - + if x + 1 <= mx and maze[x+1][y][1] and maze[x+1][y][2] and maze[x+1][y][3] and maze[x+1][y][4] then intact[#intact+1] = {x+1, y, 2} end - + if y + 1 <= my and maze[x][y+1][1] and maze[x][y+1][2] and maze[x][y+1][3] and maze[x][y+1][4] then intact[#intact+1] = {x, y+1, 3} end - + if y - 1 >= 1 and maze[x][y-1][1] and maze[x][y-1][2] and maze[x][y-1][3] and maze[x][y-1][4] then intact[#intact+1] = {x, y-1, 4} end - + if #intact > 0 then local i = math.random(1, #intact) -- Choose random - + if intact[i][3] == 1 then -- Set intact's attached wall to false maze[intact[i][1]][intact[i][2]][2] = false elseif intact[i][3] == 2 then @@ -145,11 +145,11 @@ local function mazeGen(mx, my) elseif intact[i][3] == 4 then maze[intact[i][1]][intact[i][2]][3] = false end - + maze[x][y][intact[i][3]] = false -- Set attached wall to false - + vis = vis + 1 -- Increase vis - + stack[#stack+1] = intact[i] -- Add to stack else local tmp = table.remove(stack) -- Get last cell @@ -157,7 +157,7 @@ local function mazeGen(mx, my) curr.y = tmp[2] end end - + return maze end @@ -177,7 +177,7 @@ local tab = {} for x = 1, size * 2 + 1 do tab[x] = {} - + for y = 1, size * 2 + 1 do if x % 2 == 0 and y % 2 == 0 then -- Fill cells (empty) tab[x][y] = false @@ -201,7 +201,7 @@ repeat -- Print map term.setBackgroundColor(colors.white) term.clear() - + if posx == 2 and posy == 2 then term.setCursorPos(1, 1) term.setTextColor(colors.black) @@ -211,27 +211,27 @@ repeat print("Goal: Step on # (It's on bottom right corner)") print("\nGood Luck!") end - + --[[ term.setTextColor(colors.black) term.setCursorPos(1, 19) write("X: "..posx.." Y: "..posy) ]] - + for x, tV in ipairs(tab) do -- Print the map for y, v in ipairs(tV) do if offsety+y > 20 then break end - + term.setCursorPos(offsetx+x, offsety+y) - + if v then term.setBackgroundColor(colors.black) else term.setBackgroundColor(colors.white) end - + if offsety+y < 20 and offsety+y > 0 and offsetx+x < 52 and offsetx+x > 0 then if x == size*2 and y == size*2 then if term.isColor() then @@ -243,51 +243,51 @@ repeat end end end - + if offsetx+x > 51 then break end - end - + end + term.setCursorPos(51/2, 19/2) term.setBackgroundColor(colors.white) - + if term.isColor() then term.setTextColor(colors.red) else term.setTextColor(colors.black) end - + write("X") - + -- Wait for key - + local e, k = os.pullEvent("char") - + if k == "a" and (not tab[posx-1][posy]) then posx = posx - 1 offsetx = offsetx + 1 end - + if k == "d" and (not tab[posx+1][posy]) then posx = posx + 1 offsetx = offsetx - 1 end - + if k == "w" and (not tab[posx][posy-1]) then posy = posy - 1 offsety = offsety + 1 end - + if k == "s" and (not tab[posx][posy+1]) then posy = posy + 1 offsety = offsety - 1 end - + if k == "q" then break end - + if k == "r" then posx = 2 posy = 2 @@ -324,4 +324,4 @@ term.setBackgroundColor(colors.black) term.setTextColor(colors.white) term.clear() term.setCursorPos(1, 1) -cprint(" Maze by JTK. Thanks for playing!") \ No newline at end of file +cprint(" Maze by JTK. Thanks for playing!") diff --git a/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze3d.lua b/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze3d.lua index 85343aeab..a8a04ee85 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze3d.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/JTK/maze3d/maze3d.lua @@ -1,6 +1,6 @@ --[[ Project info: - + Name: Maze 3D Creator: Jesusthekiller Language: Lua (CC) @@ -28,7 +28,7 @@ --[[ LICENSE: - + Maze 3D Copyright (c) 2013 Jesusthekiller @@ -78,7 +78,7 @@ repeat cwrite("Enter maze size (5-99):") size = read() - + size = tonumber(size) if not size then size = 0 @@ -87,18 +87,18 @@ until size > 4 and size < 100 -- The generate local function mazeGen(mx, my) - + --[[ Format: - + maze.x.y.(1/2/3/4) = true/false - + 1 - top 2 - bottom 3 - right 4 - left ]]-- - + local maze = {} for i = 1, mx do maze[i] = {} @@ -121,26 +121,26 @@ local function mazeGen(mx, my) local intact = {} local x = curr.x local y = curr.y - + if x - 1 >= 1 and maze[x-1][y][1] and maze[x-1][y][2] and maze[x-1][y][3] and maze[x-1][y][4] then -- Check for full cells intact[#intact+1] = {x-1, y, 1} end - + if x + 1 <= mx and maze[x+1][y][1] and maze[x+1][y][2] and maze[x+1][y][3] and maze[x+1][y][4] then intact[#intact+1] = {x+1, y, 2} end - + if y + 1 <= my and maze[x][y+1][1] and maze[x][y+1][2] and maze[x][y+1][3] and maze[x][y+1][4] then intact[#intact+1] = {x, y+1, 3} end - + if y - 1 >= 1 and maze[x][y-1][1] and maze[x][y-1][2] and maze[x][y-1][3] and maze[x][y-1][4] then intact[#intact+1] = {x, y-1, 4} end - + if #intact > 0 then local i = math.random(1, #intact) -- Choose random - + if intact[i][3] == 1 then -- Set intact's attached wall to false maze[intact[i][1]][intact[i][2]][2] = false elseif intact[i][3] == 2 then @@ -150,11 +150,11 @@ local function mazeGen(mx, my) elseif intact[i][3] == 4 then maze[intact[i][1]][intact[i][2]][3] = false end - + maze[x][y][intact[i][3]] = false -- Set attached wall to false - + vis = vis + 1 -- Increase vis - + stack[#stack+1] = intact[i] -- Add to stack else local tmp = table.remove(stack) -- Get last cell @@ -162,7 +162,7 @@ local function mazeGen(mx, my) curr.y = tmp[2] end end - + return maze end @@ -180,7 +180,7 @@ local tab = {} for x = 1, size * 2 + 1 do tab[x] = {} - + for y = 1, size * 2 + 1 do if x % 2 == 0 and y % 2 == 0 then -- Fill cells (empty) tab[x][y] = " " @@ -263,13 +263,13 @@ if redirect then print("redirect API found, using buffer") else local pe=printError - rawset(_G,"printError",error) + rawset(_G,"printError",error) local ok, err=pcall(os.loadAPI,"redirect") if not ok then print("trying "..shell.dir().."/redirect") ok,err=pcall(os.loadAPI,shell.dir().."/redirect") end - if ok then + if ok then print("Loaded redirect API, using buffer") buffer=redirect.createRedirectBuffer() loadedAPI=true @@ -277,7 +277,7 @@ else print("redirect API not found or could not be loaded, drawing directly; this may cause flickering.") end rawset(_G,"printError",pe) -end +end local colorSchemes = { {0,8}, --white+gray @@ -338,10 +338,10 @@ local function cast(cx,cy,angle) end local wall=map[y]:sub(x,x) if wall~=" " then - + return colorSchemes[tonumber(wall)][isX and 1 or 2], hitD end - end + end end local w,h=term.getSize() @@ -370,7 +370,7 @@ for x=1,w do t.angle=math.atan2(x-centerX,screenDist) t.dist=((x-centerX)^2+screenDist^2)^.5/screenDist end - + local function redraw() local oldTerm if buffer.isBuffer then @@ -411,15 +411,15 @@ local function clampCollision(x,y,radius) --I am. Complete fail, do nothing. return x,y end - + --ok, check the neighbors. local right=math.floor(x+radius)>gx local left=math.floor(x-radius)gy - + local pushed=false - + if right and map[gy]:sub(gx+1,gx+1)~=" " then --push left pushed=true @@ -429,7 +429,7 @@ local function clampCollision(x,y,radius) pushed=true x=gx+radius end - + if front and map[gy-1]:sub(gx,gx)~=" " then --push back pushed=true @@ -442,7 +442,7 @@ local function clampCollision(x,y,radius) y=gy+1-radius end - + --if I wasn't pushed out on any side, I might be hitting a corner if not pushed then --square rad @@ -482,7 +482,7 @@ local function clampCollision(x,y,radius) x=x+pushx y=y+pushy end - + return x,y end @@ -533,7 +533,7 @@ while true do redraw() dirty=false end - + local e={os.pullEvent()} if e[1]=="key" then if e[2]==keys.left then @@ -565,7 +565,7 @@ while true do dir=startdir dirty=true end - + if px >= mapW-1 and py >= mapH-1 then win = true break 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 6c95fbd6d..a8d7901d3 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 @@ -23,4 +23,4 @@ if fs.exists(args[1]) then else print("Client rejected file!") end -end \ No newline at end of file +end 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 a76aba8d6..df62694fc 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 @@ -718,4 +718,4 @@ elseif #args >= 1 then --either no server running or we are the local shell on t else print("Usage: nsh [resume]") print(" nsh host [remote [local [name]]]") -end \ No newline at end of file +end 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 23e6a2e3c..a31fe0be9 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 @@ -32,4 +32,4 @@ if message ~= "fileNotFound" then else print("Empty file not written!") end -end \ No newline at end of file +end diff --git a/src/main/resources/assets/computercraft/lua/treasure/TheOriginalBIT/tictactoe/tictactoe.lua b/src/main/resources/assets/computercraft/lua/treasure/TheOriginalBIT/tictactoe/tictactoe.lua index 8fdfbbf85..88e394b1e 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/TheOriginalBIT/tictactoe/tictactoe.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/TheOriginalBIT/tictactoe/tictactoe.lua @@ -124,7 +124,7 @@ end local function getAIMove() -- make it seem like the computer actually has to think about its move sleep(0.8) - + -- check if AI can win and return the 3rd tile to create a win, if it cannot, check for a human attempt at winning and stop it, if there is none, return a random return (search(currentPlayer) or search(opposites[currentPlayer])) or math.random(1,9) end @@ -177,7 +177,7 @@ local function modread( _mask, _history, _limit ) redraw(' ') if event[2] == keys.up then if not historyPos then - historyPos = #_history + historyPos = #_history elseif historyPos > 1 then historyPos = historyPos - 1 end @@ -308,14 +308,14 @@ local function render() writeAt('+'..string.rep('-', sw-2)..'+', 1, 3) writeAt('+'..string.rep('-', sw-2)..'+', 1, sh-2) writeAt('+'..string.rep('-', sw-2)..'+', 1, sh) - + if term.isColor and term.isColor() then term.setCursorPos(sw, 1) term.setBackgroundColor(colors.red) term.setTextColor(colors.black) writeWithFormat('X') end - + -- set our colours term.setBackgroundColor(colors.white) term.setTextColor(colors.black) @@ -359,7 +359,7 @@ local function render() writeAt((board[i + 6] == 'x' and '/\\' or '\\/'), 18+((i-1)*7), 14) end end - + -- draw the current player term.setCursorPos(3, sh - 3) if not winner then @@ -441,4 +441,4 @@ cwriteWithFormat('&4Thank you for playing CCTicTacToe v1.0', 1) cwriteWithFormat('&4By &8TheOriginal&3BIT\n', 2) -- restore the default terminal object -term.redirect( oldTermObj ) \ No newline at end of file +term.redirect( oldTermObj ) diff --git a/src/main/resources/assets/computercraft/lua/treasure/dan200/alongtimeago/alongtimeago.lua b/src/main/resources/assets/computercraft/lua/treasure/dan200/alongtimeago/alongtimeago.lua index bf126850d..dc1672f70 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/dan200/alongtimeago/alongtimeago.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/dan200/alongtimeago/alongtimeago.lua @@ -22,7 +22,7 @@ while not bFinished do break end - -- Get this every frame incase the monitor resizes + -- Get this every frame incase the monitor resizes local w,h = term.getSize() local startX = math.floor( (w - 65) / 2 ) local startY = math.floor( (h - 14) / 2 ) diff --git a/src/main/resources/assets/computercraft/lua/treasure/deprecated/GopherAtl/talk/talk.lua b/src/main/resources/assets/computercraft/lua/treasure/deprecated/GopherAtl/talk/talk.lua index ee7e8a8f8..c43fd6d4a 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/deprecated/GopherAtl/talk/talk.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/deprecated/GopherAtl/talk/talk.lua @@ -1 +1 @@ -print( "\"talk\" was removed in ComputerCraft 1.6, use the builtin \"chat\" program instead!" ) \ No newline at end of file +print( "\"talk\" was removed in ComputerCraft 1.6, use the builtin \"chat\" program instead!" ) diff --git a/src/main/resources/assets/computercraft/lua/treasure/fredthead/protector/protector.lua b/src/main/resources/assets/computercraft/lua/treasure/fredthead/protector/protector.lua index 255c238d1..bd88cee1d 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/fredthead/protector/protector.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/fredthead/protector/protector.lua @@ -27,11 +27,11 @@ function initVariables() human6x = 85 human6y = 18 human1 = true - human2 = true - human3 = true - human4 = true - human5 = true - human6 = true + human2 = true + human3 = true + human4 = true + human5 = true + human6 = true human1Abducted=false human2Abducted=false human3Abducted=false @@ -245,7 +245,7 @@ function printScore() end function rewriteScores() - if newScore > score1 then + if newScore > score1 then name5=name4 score5=score4 name4=name3 score4=score3 name3=name2 score3=score2 @@ -264,7 +264,7 @@ function rewriteScores() name5=name4 score5=score4 name4=newName score4=newScore elseif newScore > score5 then - name5=newName score5=newScore + name5=newName score5=newScore end local highScoreTable = {{name1, score1}, {name2,score2}, {name3,score3}, {name4,score4}, {name5,score5}} local newHighScoreStr = textutils.serialize(highScoreTable) @@ -289,7 +289,7 @@ function newHighScoreObtained() newNameStr=newNameStr..p1 newNameStrLen=newNameStrLen+1 printCent(14,newNameStr.." ") - + elseif event=="key" and p1 == 14 and newNameStrLen>0 then newNameStr=string.sub(newNameStr,1,string.len(newNameStr)-1) newNameStrLen=newNameStrLen-1 @@ -303,9 +303,9 @@ function newHighScoreObtained() printScore() end end - - + + end function highScore() @@ -327,8 +327,8 @@ function highScore() newHighScoreObtained() end printScore() - - + + end @@ -351,24 +351,24 @@ function gameOver(gameOverMsg) running=false sleep(1.5) highScore()-- new - --playAgain + --playAgain end function playAgain() sleep(1) printCent(12,"Play again (Y or N)") - + while true do local event,p1,p2,p3 = os.pullEvent() if event=="char" then - if string.lower(p1)=="y" then + if string.lower(p1)=="y" then runGame() - elseif string.lower(p1)=="n" then + elseif string.lower(p1)=="n" then os.shutdown() end end end - + end function killPlayer() @@ -378,7 +378,7 @@ function killPlayer() moveDown=false delShip(shipYPos) lives=lives-1 - if lives==0 then + if lives==0 then gameOver("OUT OF LIVES") end killedState=true @@ -438,7 +438,7 @@ function right() end function up() - if shipYPos > 2 then + if shipYPos > 2 then delShip(shipYPos) shipYPos=shipYPos-1 checkShipCollision() @@ -449,7 +449,7 @@ function up() end function down() - if shipYPos<17 then + if shipYPos<17 then delShip(shipYPos) shipYPos=shipYPos+1 checkShipCollision() @@ -480,7 +480,7 @@ function checkShipCollision() if human3x >=24 and human3x <= 26 then human3=false humanHitRoutine() - end + end elseif human4==true and human4y==shipYPos then if human4x >=24 and human4x <= 26 then human4=false @@ -495,7 +495,7 @@ function checkShipCollision() if human6x >=24 and human6x <= 26 then human6=false humanHitRoutine() - end + end end end end @@ -551,7 +551,7 @@ function alienDown() alien1Abduct=true alien1Carry=true alien1Step=17 - end + end end end @@ -564,74 +564,74 @@ function alienRoutine() end alien1Abduct=false alien1Carry=false - if humansLeft==0 then + if humansLeft==0 then gameOver("NO HUMANS LEFT") end - + end function alienUp() if alien1==true and alien1Abduct==true then - if alien1x+1 == human1x then + if alien1x+1 == human1x then human1Abducted=true alien1Step=alien1Step-stepValue alien1y=math.floor(alien1Step) human1y=math.floor(alien1Step)+1 human1x=alien1x+1 - if human1y<=2 then + if human1y<=2 then alienRoutine() human1=false end - elseif alien1x+1 == human2x then + elseif alien1x+1 == human2x then human2Abducted=true alien1Step=alien1Step-stepValue alien1y=math.floor(alien1Step) human2y=math.floor(alien1Step)+1 human2x=alien1x+1 - if human2y<=2 then + if human2y<=2 then alienRoutine() human2=false end - elseif alien1x+1 == human3x then + elseif alien1x+1 == human3x then human3Abducted=true alien1Step=alien1Step-stepValue alien1y=math.floor(alien1Step) human3y=math.floor(alien1Step)+1 human3x=alien1x+1 - if human3y<=2 then + if human3y<=2 then alienRoutine() human3=false end - elseif alien1x+1 == human4x then + elseif alien1x+1 == human4x then human4Abducted=true alien1Step=alien1Step-stepValue alien1y=math.floor(alien1Step) human4y=math.floor(alien1Step)+1 human4x=alien1x+1 - if human4y<=2 then + if human4y<=2 then alienRoutine() human4=false end - elseif alien1x+1 == human5x then + elseif alien1x+1 == human5x then human5Abducted=true alien1Step=alien1Step-stepValue alien1y=math.floor(alien1Step) human5y=math.floor(alien1Step)+1 human5x=alien1x+1 - if human5y<=2 then + if human5y<=2 then alienRoutine() human5=false end - elseif alien1x+1 == human6x then + elseif alien1x+1 == human6x then human6Abducted=true alien1Step=alien1Step-stepValue alien1y=math.floor(alien1Step) human6y=math.floor(alien1Step)+1 human6x=alien1x+1 - if human6y<=2 then + if human6y<=2 then alienRoutine() human6=false - end + end end end if alien1==false then alienGen() end @@ -645,7 +645,7 @@ function keyPress() -- 200 UP, 208 DOWN, 203 LEFT, 205 RIGHT, 57 SPACE, 16 Q moveDown=true moveUp=false elseif pressedKey==203 or pressedKey == 30 then -- left - moveLeft=true + moveLeft=true moveRight=false elseif pressedKey==205 or pressedKey == 32 then -- right moveRight=true @@ -654,7 +654,7 @@ function keyPress() -- 200 UP, 208 DOWN, 203 LEFT, 205 RIGHT, 57 SPACE, 16 Q if bulletState==false then bulletYPos=shipYPos bulletState=true - if shipFacingRight==true then + if shipFacingRight==true then bulletXPos=shipXPos+3 bulletGoingRight=true else @@ -665,13 +665,13 @@ function keyPress() -- 200 UP, 208 DOWN, 203 LEFT, 205 RIGHT, 57 SPACE, 16 Q elseif pressedKey==25 then -- q (use 25 if p for quit) gameOver("YOU QUIT") end - + --term.setCursorPos(30,1) --write(pressedKey.." ") end function removeBullet() - if bulletGoingRight==true then + if bulletGoingRight==true then bulletXPos = 60 else bulletXPos = -10 @@ -691,7 +691,7 @@ end function humanHitRoutine() score=score-50 humansLeft=humansLeft-1 - if humansLeft==0 then + if humansLeft==0 then gameOver("NO HUMANS LEFT") end if alien1Carry==true then alien1Carry=false end @@ -699,9 +699,9 @@ end function checkBulletCollision() - if alien1 == true and bulletYPos == alien1y then - if bulletXPos >= alien1x and bulletXPos <= alien1x + 3 then - alien1Hit() + if alien1 == true and bulletYPos == alien1y then + if bulletXPos >= alien1x and bulletXPos <= alien1x + 3 then + alien1Hit() end end if human1 == true and bulletYPos == human1y and bulletXPos == human1x then human1=false humanHitRoutine() end @@ -737,15 +737,15 @@ end function gameControl() gameTimer=os.startTimer(0.1) - + while running do local event,p1,p2,p3 = os.pullEvent() if score<0 then score=0 end term.setCursorPos(1,1) term.setBackgroundColour(colours.yellow) write(string.rep(" ",w)) - - + + term.setTextColour(colours.red) term.setCursorPos(5,1) write("Score: "..score.." ") @@ -753,15 +753,15 @@ function gameControl() write("Humans Left: "..humansLeft.." ") term.setCursorPos(40,1) write("Lives: "..lives.." ") - + term.setBackgroundColour(colours.black) term.setTextColour(colours.white) - + local newStepValue = (score+0.1)/1000 if newStepValue > stepValue then stepValue= newStepValue end if stepValue>0.4 then stepValue=0.4 end - - + + --[[DEBUG term.setCursorPos(2,2) write("human1x "..human1x.." ") @@ -776,10 +776,10 @@ function gameControl() term.setCursorPos(2,7) write("human6x "..human6x.." ") ]]-- - - + + if event=="timer" and gameTimer == p1 then - if killedState==true then + if killedState==true then delShip(shipYPos) delHumans() dropHumans() @@ -800,15 +800,15 @@ function gameControl() else moveLeft=true moveRight=false - end + end killedDelay=0 end else - + --alienGen() drawShip(shipYPos) delAliens() - + delHumans() dropHumans() alienDown() @@ -817,7 +817,7 @@ function gameControl() drawHumans() drawBorder() end - + if bulletState==true then if bulletGoingRight==true then delBullet() @@ -839,7 +839,7 @@ function gameControl() end end end - + if moveLeft==true then left() end @@ -852,16 +852,16 @@ function gameControl() if moveDown==true then down() end - + gameTimer=os.startTimer(0.1) - - elseif event=="key" and killedState==false then + + elseif event=="key" and killedState==false then pressedKey=p1 keyPress() end - - end - + + end + end function runGame() @@ -875,7 +875,7 @@ end function pix(xCo,yCo,text,col) - if col== nil then term.setBackgroundColour(colours.black) + if col== nil then term.setBackgroundColour(colours.black) elseif col =="white" then term.setBackgroundColour(colours.white) elseif col =="green" then term.setBackgroundColour(colours.green) elseif col =="pink" then term.setBackgroundColour(colours.pink) @@ -977,7 +977,7 @@ function line2() pix(38,5," ","white") pix(40,5," ","white") pix(42,5," ","white") - + end function line3() @@ -1030,7 +1030,7 @@ function startScreen() term.setCursorPos(1,h) write(string.rep(" ",w)) local screenStage=0 - + screenTimer=os.startTimer(0.1) while true do local event,p1,p2,p3=os.pullEvent() @@ -1039,12 +1039,12 @@ function startScreen() clear() runGame() elseif event=="timer" and screenTimer == p1 then - + --term.setCursorPos(1,1) write("screenStage: "..screenStage.." ") - + term.setBackgroundColour(colours.black) term.setCursorPos(35,1) write("SPACE WHEN READY") - + if screenStage>0 and screenStage<0.5 then humanPixY = 18 drawHumanPix() @@ -1055,17 +1055,17 @@ function startScreen() alienPixY = -2 delAlienPix() alienPixY = -1 - drawAlienPix() + drawAlienPix() elseif screenStage>4 and screenStage<4.9 then alienPixY = -1 delAlienPix() alienPixY = 0 - drawAlienPix() + drawAlienPix() elseif screenStage>5 and screenStage<5.9 then alienPixY = 0 delAlienPix() alienPixY = 1 - drawAlienPix() + drawAlienPix() elseif screenStage>6 and screenStage<6.9 then alienPixY = 1 delAlienPix() @@ -1080,7 +1080,7 @@ function startScreen() alienPixY = 3 delAlienPix() alienPixY = 4 - drawAlienPix() + drawAlienPix() elseif screenStage>8 and screenStage<9.9 then alienPixY = 4 delAlienPix() @@ -1120,7 +1120,7 @@ function startScreen() pix(22,17," ","yellow") pix(22,18," ","yellow") humanPixY = 18 - drawHumanPix() + drawHumanPix() elseif screenStage>10.8 and screenStage<11 then pix(25,8," ","yellow") pix(24,9," ","yellow") @@ -1134,7 +1134,7 @@ function startScreen() pix(20,17," ","yellow") pix(20,18," ","yellow") humanPixY = 18 - drawHumanPix() + drawHumanPix() elseif screenStage>11.9 and screenStage<12 then pix(1,6," ","yellow") elseif screenStage>12 and screenStage<12.1 then @@ -1142,7 +1142,7 @@ function startScreen() pix(3,6," ","yellow") elseif screenStage>12.1 and screenStage<12.2 then pix(3,6," ") - pix(5,6," ","yellow") + pix(5,6," ","yellow") elseif screenStage>12.2 and screenStage<12.3 then pix(5,6," ") pix(7,6," ","yellow") @@ -1166,102 +1166,102 @@ function startScreen() end humanPixY=18 drawHumanPix() - elseif screenStage>13 and screenStage<13.1 then + elseif screenStage>13 and screenStage<13.1 then shipPixX= -16 drawShipPix() - elseif screenStage>13 and screenStage<13.1 then + elseif screenStage>13 and screenStage<13.1 then delShipPix() shipPixX= -15 - drawShipPix() - elseif screenStage>13.1 and screenStage<13.2 then + drawShipPix() + elseif screenStage>13.1 and screenStage<13.2 then delShipPix() shipPixX= -12 - drawShipPix() - elseif screenStage>13.2 and screenStage<13.3 then + drawShipPix() + elseif screenStage>13.2 and screenStage<13.3 then delShipPix() shipPixX= -9 drawShipPix() - elseif screenStage>13.2 and screenStage<13.3 then + elseif screenStage>13.2 and screenStage<13.3 then delShipPix() shipPixX= -6 drawShipPix() - elseif screenStage>13.3 and screenStage<13.4 then + elseif screenStage>13.3 and screenStage<13.4 then delShipPix() shipPixX= -3 drawShipPix() - elseif screenStage>13.4 and screenStage<13.5 then + elseif screenStage>13.4 and screenStage<13.5 then delShipPix() shipPixX= 0 drawShipPix() - elseif screenStage>13.6 and screenStage<13.7 then + elseif screenStage>13.6 and screenStage<13.7 then delShipPix() shipPixX= 3 drawShipPix() - elseif screenStage>13.8 and screenStage<13.9 then + elseif screenStage>13.8 and screenStage<13.9 then delShipPix() shipPixX= 6 drawShipPix() - elseif screenStage>13.9 and screenStage<14 then + elseif screenStage>13.9 and screenStage<14 then delShipPix() shipPixX= 9 drawShipPix() - elseif screenStage>14.1 and screenStage<14.2 then + elseif screenStage>14.1 and screenStage<14.2 then delShipPix() shipPixX= 12 drawShipPix() - elseif screenStage>14.2 and screenStage<14.3 then + elseif screenStage>14.2 and screenStage<14.3 then delShipPix() shipPixX= 15 drawShipPix() - elseif screenStage>14.3 and screenStage<14.4 then + elseif screenStage>14.3 and screenStage<14.4 then delShipPix() shipPixX= 18 drawShipPix() - elseif screenStage>14.4 and screenStage<14.5 then + elseif screenStage>14.4 and screenStage<14.5 then delShipPix() shipPixX= 21 drawShipPix() - elseif screenStage>14.5 and screenStage<14.6 then + elseif screenStage>14.5 and screenStage<14.6 then delShipPix() shipPixX= 24 drawShipPix() - elseif screenStage>14.6 and screenStage<14.7 then + elseif screenStage>14.6 and screenStage<14.7 then delShipPix() shipPixX= 27 drawShipPix() - elseif screenStage>14.7 and screenStage<14.8 then + elseif screenStage>14.7 and screenStage<14.8 then delShipPix() shipPixX= 30 drawShipPix() - elseif screenStage>14.8 and screenStage<14.9 then + elseif screenStage>14.8 and screenStage<14.9 then delShipPix() shipPixX= 33 drawShipPix() - elseif screenStage>14.9 and screenStage<15 then + elseif screenStage>14.9 and screenStage<15 then delShipPix() shipPixX= 36 drawShipPix() - elseif screenStage>15 and screenStage<15.1 then + elseif screenStage>15 and screenStage<15.1 then delShipPix() shipPixX= 39 drawShipPix() - elseif screenStage>15.1 and screenStage<15.2 then + elseif screenStage>15.1 and screenStage<15.2 then delShipPix() shipPixX= 41 drawShipPix() - elseif screenStage>15.2 and screenStage<15.3 then + elseif screenStage>15.2 and screenStage<15.3 then delShipPix() shipPixX= 44 drawShipPix() - elseif screenStage>15.3 and screenStage<15.4 then + elseif screenStage>15.3 and screenStage<15.4 then delShipPix() shipPixX= 47 drawShipPix() - elseif screenStage>15.4 and screenStage<15.5 then + elseif screenStage>15.4 and screenStage<15.5 then delShipPix() shipPixX= 50 drawShipPix() - elseif screenStage>15.5 and screenStage<15.6 then + elseif screenStage>15.5 and screenStage<15.6 then delShipPix() elseif screenStage>16 and screenStage<16.9 then humanPixY=18 @@ -1284,7 +1284,7 @@ function startScreen() write("Fire when ready") elseif screenStage>22.1 and screenStage <27 then introHighScoreTable() - elseif screenStage>27 then + elseif screenStage>27 then term.setBackgroundColour(colours.black) for i = 2,h-1 do term.setCursorPos(1,i) @@ -1292,7 +1292,7 @@ function startScreen() end screenStage=0 end - + screenStage=screenStage+0.1 screenTimer=os.startTimer(0.025) end @@ -1308,4 +1308,4 @@ else term.setCursorPos(1,1) print("I'm sorry, Protector requires an Advanced Computer to run") print(" ") -end \ No newline at end of file +end diff --git a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/goldrunner/goldrunner.lua b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/goldrunner/goldrunner.lua index 2aeaf4072..b75a5ca79 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/goldrunner/goldrunner.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/goldrunner/goldrunner.lua @@ -89,7 +89,7 @@ local titleLevel = { local function parseValue(x, y, lchar) if tonumber(lchar, 16) then lchar = math.pow(2, tonumber(lchar,16)) - + if lchar == colours.blue then map[y][x] = 0 elseif lchar == colours.brown then @@ -146,7 +146,7 @@ local function loadMap(_sPath) goldMap = {} monks = {} goldCount = 0 - + local file = fs.open(_sPath, "r") local line = file:readLine() while line do @@ -279,14 +279,14 @@ local function resetMap() monk.x = monk.spawnX monk.y = monk.spawnY end - + for _,timer in pairs(blockTimers) do map[timer.y][timer.x] = 0 end blockTimers = {} plX = plspawnX plY = plspawnY - + moveTimer = -1 shootTimer = -1 spawnTimer = -1 @@ -320,27 +320,27 @@ end local function drawLevelList() local minLev = ((levelLot-1) * 10 + 1) local maxLev = minLev + math.min(10, #levelList - (levelLot-1) * 10) - 1 - + term.setCursorPos(7, 2) term.setBackgroundColour(colours.black) term.clearLine() for j = 1,49 do updateMap(j,2) end - + term.setBackgroundColour(colours.black) term.setTextColour(colours.white) term.setCursorPos(7, 2) local msg = "Levels "..minLev.." to "..maxLev.." of "..#levelList term.write(msg) - + term.setTextColour(colours.yellow) term.setCursorPos(4, 2) if levelLot > 1 then term.write("<-") - else term.write(" ") end - + else term.write(" ") end + term.setCursorPos(8 + #msg, 2) if maxLev < #levelList then term.write("->") else term.write(" ") end - + for i = 1,10 do term.setCursorPos(1, 3+i) for j = 1,49 do updateMap(j,3+i) end @@ -371,12 +371,12 @@ local function loadTitleScreen() if #map == 18 then break end end maxGoldCount = goldCount - + drawMap() term.setCursorPos(1,19) term.setBackgroundColour(colours.blue) term.clearLine() - + menIndex = 1 titleLoaded = true end @@ -384,22 +384,22 @@ end --Opens an in-game menu to display a series of options. local function inGameMenu(menuList) menIndex = 1 - + local squareTop,squareBottom = 4,6 + #menuList * 2 local squareSize = 0 for i=1,#menuList do squareSize = math.max(squareSize, #menuList[i] + 6) end - + for y=squareTop,squareBottom do term.setCursorPos(w/2 - squareSize/2, y) term.setBackgroundColour(colours.lightBlue) term.write(string.rep(" ", squareSize)) - + if y ~= squareTop and y ~= squareBottom then term.setCursorPos(w/2 - squareSize/2 + 1, y) term.setBackgroundColour(colours.black) term.write(string.rep(" ", squareSize - 2)) end - + if y ~= squareTop and y ~= squareBottom and y % 2 == 0 then local opt = menuList[(y - squareTop) / 2] term.setCursorPos(w/2 - #opt/2, y) @@ -407,7 +407,7 @@ local function inGameMenu(menuList) term.write(opt) end end - + local p1 = nil repeat for i=1,#menuList do @@ -426,20 +426,20 @@ local function inGameMenu(menuList) end end _,p1 = os.pullEvent("key") - + if p1 == keys.up and menIndex > 1 then menIndex = menIndex - 1 elseif p1 == keys.down and menIndex < #menuList then menIndex = menIndex + 1 end until p1 == keys.enter - + return menuList[menIndex] end --Checks to see if any given desired move is legal. Monks and players both use this. local function isLegalMove(initX,initY,finX,finY) - if finY < 1 or finY > #map or finX < 1 or finX > 49 then - return false + if finY < 1 or finY > #map or finX < 1 or finX > 49 then + return false end - + if map[finY][finX] ~= 0 and map[finY][finX] ~= '#' then --This reports 'self moves' as being illegal, but that's fine for _,monk in pairs(monks) do @@ -450,10 +450,10 @@ local function isLegalMove(initX,initY,finX,finY) then return true elseif finY == initY+1 and (map[finY][finX] == "H" or (map[finY][finX] == "h" and goldCount == 0) or (type(map[finY][finX]) == "number" and map[finY][finX] > 0) or map[finY][finX] == nil or - map[finY][finX] == "V" or map[finY][finX] == "-" or (map[finY][finX] == 'h' and goldCount ~= 0)) + map[finY][finX] == "V" or map[finY][finX] == "-" or (map[finY][finX] == 'h' and goldCount ~= 0)) then return true - elseif finX == initX-1 or finX == initX+1 then - return true + elseif finX == initX-1 or finX == initX+1 then + return true end end end @@ -461,12 +461,12 @@ end --Moves the player to a given step. local function movePlayer(x,y,ignoreLegal) if not ignoreLegal and not isLegalMove(plX,plY,x,y) then return false end - + local ox = plX local oy = plY plX = x plY = y - + updateMap(ox,oy) updateMap(x,y) if goldMap[y][x] == 1 then @@ -481,14 +481,14 @@ local function movePlayer(x,y,ignoreLegal) started = false nextLevel = true end - - pfalling = (y < #map and map[y][x] ~= '-' and map[y][x] ~= 'H' and not (map[y][x] == 'h' and goldCount == 0) + + pfalling = (y < #map and map[y][x] ~= '-' and map[y][x] ~= 'H' and not (map[y][x] == 'h' and goldCount == 0) and (map[y+1][x] == nil or map[y+1][x] == "V" or map[y+1][x] == 2 or map[y+1][x] == '-')) if (y < #map and map[y+1][x] == 'h' and goldCount ~= 0) then pfalling = true end for _,monk in pairs(monks) do if monk.x == plX and monk.y == plY + 1 then pfalling = false break end end - + return true end @@ -634,7 +634,7 @@ local function updateMonks() end end end - + if not (monk.trapped or monk.dead) then --Has the monk decided on moving left or right? If so we try to move him if monk.desX and not monk.falling then @@ -708,7 +708,7 @@ local function updateBlockTimer(tid) end local function shootBlock(x,y) - if y <= #map and map[y][x] == 0 and (map[y-1][x] == nil + if y <= #map and map[y][x] == 0 and (map[y-1][x] == nil or map[y-1][x] == 2 or (map[y-1][x] == 'h' and goldCount > 0)) then map[y][x] = 3 table.insert(blockTimers, {x = x; y = y; timer = os.startTimer(0.1);} ) @@ -718,14 +718,14 @@ end local function handleEvents() local id,p1,p2,p3 = os.pullEvent() - + if id == "key" then --Menu Handling if p1 == keys.up then if menIndex > 1 then menIndex = menIndex - 1 end elseif p1 == keys.down then - if inLevelSelect then - if menIndex < math.min(10, #levelList - (levelLot-1)*10) then + if inLevelSelect then + if menIndex < math.min(10, #levelList - (levelLot-1)*10) then menIndex = menIndex + 1 end elseif menIndex < #titleOptions then menIndex = menIndex + 1 end @@ -736,7 +736,7 @@ local function handleEvents() levelLot = levelLot + 1 drawLevelList() end - + --Game Handling if p1 == keys.a and moveTimer == -1 and spawnTimer == -1 then movePlayer(plX-1,plY) @@ -811,7 +811,7 @@ local function handleEvents() monk.trapped = nil monk.behaviour = "none" monk.justEscaped = true - + updateMap(monk.x, monk.y+1) drawMonk(monk) end @@ -859,12 +859,12 @@ local pallette = { { t = colours.black, b = colours.blue, s = " ", n = "Solid G local brushType = 1 local function getHexOf(colour) - if not colour or not tonumber(colour) then - return " " + if not colour or not tonumber(colour) then + return " " end local value = math.log(colour)/math.log(2) - if value > 9 then - value = hexnums[value] + if value > 9 then + value = hexnums[value] end return value end @@ -878,7 +878,7 @@ local function drawFooter() term.setCursorPos(w,i) term.write(" ") end - + term.setBackgroundColour(colours.black) term.setTextColour(colours.blue) term.setCursorPos(2,h) @@ -904,7 +904,7 @@ local function drawPallette(xpos,ypos) local top = ypos if xpos + xdim > w then left = left + (w - xpos - xdim) end if ypos + ydim > h then top = top + (h - ypos - ydim) end - + --There's no easy way to do this... so we draw it manually :( for i=0,4 do term.setCursorPos(left, top + i) @@ -913,25 +913,25 @@ local function drawPallette(xpos,ypos) if i == 0 or i == 4 then term.write("*-----*") else term.write("* *") end end - + for i=1,#pallette-1 do local ypl = 1 local xmv = i if i > 5 then ypl = 2 xmv = i - 5 end - + term.setCursorPos(left + xmv, top+ypl) term.setBackgroundColour(pallette[i].b) term.setTextColour(pallette[i].t) term.write(pallette[i].s) end - + term.setCursorPos(left + 1, top + 3) term.setBackgroundColour(colours.red) term.setTextColour(colours.black) term.write("ERASE") - + local _,button,x,y = os.pullEvent("mouse_click") - + if button == 1 then if y == top + 1 and x > left and x < left + 6 then brushType = x-left @@ -941,9 +941,9 @@ local function drawPallette(xpos,ypos) brushType = 11 end end - + for y = top,top+ydim do - for x = left,left+xdim do + for x = left,left+xdim do --Not sure why the -2 is necessary if map[y+drawOffsetY] then updateMap(x-2,y+drawOffsetY) end end @@ -955,7 +955,7 @@ end local function saveCurrentMap(path) local file = io.open(shell.resolve(".").."/levels/"..path, "w") if not file then return false end - + drawMap() drawFooter() local msg = "Saving.." @@ -968,7 +968,7 @@ local function saveCurrentMap(path) term.write(string.rep(" ", 18)) term.setCursorPos(w/2-9,6) term.setBackgroundColour(colours.lime) - + for y=1,#map do local xstr = "" for x=1,49 do @@ -1016,14 +1016,14 @@ local function runLevelEditor() end monks = {} end - + drawMap() drawFooter() - + while inLevelEditor do local id,button,x,y = os.pullEvent() if id == "mouse_click" or id == "mouse_drag" then - if button == 2 then + if button == 2 then drawPallette(x,y) elseif x > drawOffsetX and x <= 49 + drawOffsetX and y > drawOffsetY and y <= 18 + drawOffsetY then if pallette[brushType].v == "player" then @@ -1095,7 +1095,7 @@ local function runLevelSelect() if not titleLoaded then loadTitleScreen() monkTimer = os.startTimer(moveIntv * 1.5) - else + else drawMap() drawEndgameMap() term.setCursorPos(1,19) @@ -1103,11 +1103,11 @@ local function runLevelSelect() term.clearLine() end drawLevelList() - + menSel = "none" repeat handleEvents() - + term.setBackgroundColour(colours.black) term.setTextColour(colours.yellow) for i=1,10 do @@ -1131,23 +1131,23 @@ local function runTitle() term.write("Gold Runner") term.setCursorPos(16,4) term.write("By Nitrogen Fingers") - + term.setTextColour(colours.white) for i=1,#titleOptions do term.setCursorPos(19, 5 + (i*2)) term.write(titleOptions[i]) end - + term.setCursorPos(16, 7) term.setTextColour(colours.yellow) term.write("->") - + menSel = "none" monkTimer = os.startTimer(moveIntv * 1.5) - + repeat handleEvents() - + term.setBackgroundColour(colours.black) term.setTextColour(colours.yellow) for i=1,#titleOptions do @@ -1166,25 +1166,25 @@ local function playLevel() drawHUD() os.pullEvent("key") movePlayer(plX,plY,true) - + monkTimer = os.startTimer(moveIntv * 1.5) moveTimer = os.startTimer(moveIntv) shootTimer = -1 spawnTimer = -1 - + started = true while started do handleEvents() end - + if menSel == "Quit" or menSel == "Back to Title" or menSel == "Edit Level" then running = false return end menSel = "none" - + if nextLevel then - if currentLevel == #levelList then + if currentLevel == #levelList then started = false running = false break @@ -1198,12 +1198,12 @@ local function playLevel() else playerLives = playerLives-1 if playerLives > 0 then resetMap() - else - running = false + else + running = false end end end - + if nextLevel then local msg = "All levels defeated, Gold Runner!" term.setBackgroundColour(colours.black) @@ -1247,7 +1247,7 @@ while menSel ~= "Quit" do term.setCursorPos(1,19) term.setBackgroundColour(colours.blue) term.clearLine() - + term.setCursorPos(16,10) term.setBackgroundColour(colours.black) term.setTextColour(colours.white) @@ -1256,13 +1256,13 @@ while menSel ~= "Quit" do term.setCursorPos(17,11) term.setCursorBlink(true) local levelName = "" - + local id,p1 repeat id,p1 = os.pullEvent() if id == "key" and p1 == keys.backspace then levelName = string.sub(levelName, 1, #levelName - 1) - elseif id == "timer" and p1 == monkTimer then + elseif id == "timer" and p1 == monkTimer then updateMonks() monkTimer = os.startTimer(moveIntv * 2) elseif id == "char" and #levelName < 14 then @@ -1273,15 +1273,15 @@ while menSel ~= "Quit" do term.write(levelName..string.rep(" ",14 - #levelName)) term.setCursorPos(17 + #levelName ,11) until id == "key" and p1 == keys.enter and #levelName > 0 - + term.setCursorBlink(false) levelEditName = levelName runLevelEditor() - + if menSel == "Play Level" then currentLevel = nil levelList = fs.list(shell.resolve(".").."/levels") - for num,name in pairs(levelList) do + for num,name in pairs(levelList) do if name == levelName then currentLevel = num break @@ -1296,7 +1296,7 @@ while menSel ~= "Quit" do runLevelEditor() term.setBackgroundColour(colours.black) term.clear() - + if menSel == "Play Level" then menSel = "New Game" else diff --git a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/3dprint.lua b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/3dprint.lua index be40631ff..89dc031cc 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/3dprint.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/3dprint.lua @@ -1,7 +1,7 @@ --[[ 3D Print A printing program for use with NPaintPro - + By NitrogenFingers ]]-- @@ -30,7 +30,7 @@ local commandList = { ["DE"] = endPrint; } ---Splits a string according to a pattern into a table +--Splits a string according to a pattern into a table local function split(str, pattern) local t = { } local fpat = "(.-)" .. pattern @@ -56,11 +56,11 @@ local function respondToQuery() print("Listening for ACT/ID query") local id,key = rednet.receive() print("Received : "..key) - + if key == "$3DPRINT IDENTIFY" then print("Requested Identification") rednet.send(id, "$3DPRINT IDACK "..os.getComputerLabel()) - + elseif key == "$3DPRINT ACTIVATE" then print("Requested Activation") activeCommander = id @@ -76,10 +76,10 @@ local function performPrint() while operatingPrint do local id,msg = rednet.receive() print("Command : "..msg) - + if id == activeCommander and string.find(msg, "$PC") == 1 then local cmds = split(msg, " ") - + --It's a bit of a hack, but those are the 2 methods required for a refuel if turtle.getFuelLevel() == 0 and cmds[2] ~= "SS" and cmds[2] ~= "RF" then rednet.send(id, "$3DPRINT OOF") @@ -95,7 +95,7 @@ local function performPrint() commandList[cmds[2]][i](tonumber(cmds[3])) end end - + rednet.send(activeCommander, "$3DPRINT ACK") end end @@ -116,4 +116,4 @@ while true do respondToQuery() --Perform the print performPrint() -end \ No newline at end of file +end diff --git a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/gameutils.lua b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/gameutils.lua index 8a029e83b..dac2bcc78 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/gameutils.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/gameutils.lua @@ -25,7 +25,7 @@ function initializeBuffer(terminal) if not terminal.isColour() then error("Parameter does not represent an advanced computer.") end - + tw,th = terminal.getSize() backbuffer = { } for y=1,th do @@ -41,8 +41,8 @@ end function clearBuffer(colour) if not backbuffer then error("Back buffer not yet initialized!") - end - + end + for y=1,#backbuffer do backbuffer[y] = { } if colour then @@ -60,26 +60,26 @@ end function writeToBuffer(entity) if not backbuffer then error("Back buffer not yet initialized!") - end - + end + local image = nil if entity.type == "animation" then image = entity.frames[entity.currentFrame] else image = entity.image end - + for y=1,image.dimensions.height do for x=1,image.dimensions.width do if image[y][x] then local xpos,ypos = x,y if entity.mirror.x then xpos = image.dimensions.width - x + 1 end if entity.mirror.y then ypos = image.dimensions.height - y + 1 end - + --If the YPos doesn't exist, no need to loop through the rest of X! --Don't you love optimization? if not backbuffer[entity.y + ypos - 1] then break end - + backbuffer[entity.y + ypos - 1][entity.x + xpos - 1] = image[y][x] end end @@ -93,7 +93,7 @@ end function drawBuffer(terminal) if not backbuffer then error("Back buffer not yet initialized!") - end + end if not terminal then terminal = term end if not terminal.setCursorPos or not terminal.setBackgroundColour or not terminal.write then error("Parameter cannot be used to initialize the backbuffer.") @@ -101,7 +101,7 @@ function drawBuffer(terminal) if not terminal.isColour() then error("Parameter does not represent an advanced computer.") end - + for y=1,math.min(#backbuffer, th) do for x=1,tw do if backbuffer[y][x] then @@ -167,14 +167,14 @@ end ]]-- local function drawS(self) local image = self.image - + for y=1,image.dimensions.height do for x=1,image.dimensions.width do if image[y][x] then local xpos,ypos = x,y if self.mirror.x then xpos = image.dimensions.width - x + 1 end if self.mirror.y then ypos = image.dimensions.height - y + 1 end - + term.setBackgroundColour(image[y][x]) term.setCursorPos(self.x + xpos - 1, self.y + ypos - 1) term.write(" ") @@ -198,7 +198,7 @@ local function drawA(self, frame) local xpos,ypos = x,y if self.mirror.x then xpos = image.dimensions.width - x + 1 end if self.mirror.y then ypos = image.dimensions.height - y + 1 end - + term.setBackgroundColour(image[y][x]) term.setCursorPos(self.x + xpos - 1, self.y + ypos - 1) term.write(" ") @@ -259,16 +259,16 @@ local function drawBounds(entity, colour) local image = nil if entity.type == "animation" then image = entity.frames[entity.currentFrame] else image = entity.image end - + term.setBackgroundColour(colour) - + corners = { topleft = { x = entity.x + image.bounds.x - 1, y = entity.y + image.bounds.y - 1 }; topright = { x = entity.x + image.bounds.x + image.bounds.width - 2, y = entity.y + image.bounds.y - 1 }; botleft = { x = entity.x + image.bounds.x - 1, y = entity.y + image.bounds.y + image.bounds.height - 2 }; botright = { x = entity.x + image.bounds.x + image.bounds.width - 2, y = entity.y + image.bounds.y + image.bounds.height - 2 }; } - + term.setCursorPos(corners.topleft.x, corners.topleft.y) term.write(" ") term.setCursorPos(corners.topright.x, corners.topright.y) @@ -308,7 +308,7 @@ end local function rCollidesWith(self, other) --First we construct the rectangles local img1C, img2C = createRectangle(self), createRectangle(other) - + --We then determine the "relative position" , in terms of which is farther left or right leftmost,rightmost,topmost,botmost = nil,nil,nil,nil if img1C.left < img2C.left then @@ -325,13 +325,13 @@ local function rCollidesWith(self, other) topmost = img2C botmost = img1C end - + --Then we determine the distance between the "extreme" edges- --distance between leftmost/right edge and rightmost/left edge --distance between topmost/bottom edge and bottommost/top edge local xdist = rightmost.left - leftmost.right local ydist = botmost.top - topmost.bottom - + --If both are negative, our rectangles intersect! return xdist <= 0 and ydist <= 0 end @@ -352,13 +352,13 @@ local function pCollidesWith(self, other) else img1 = self.image end if other.type == "animation" then img2 = other.frames[other.currentFrame] else img2 = other.image end - + --...then we position them... leftmost,rightmost,topmost,botmost = nil,nil,nil,nil --We also keep track of which is left and which is right- it doesn't matter in a rectangle --collision but it does in a pixel collision. img1T,img2T = {},{} - + if img1C.left < img2C.left then leftmost = img1C rightmost = img2C @@ -377,15 +377,15 @@ local function pCollidesWith(self, other) botmost = img1C img2T.top = true end - + --...and we again find the distances between the extreme edges. local xdist = rightmost.left - leftmost.right local ydist = botmost.top - topmost.bottom - + --If these distances are > 0 then we stop- no need to go any farther. if xdist > 0 or ydist > 0 then return false end - - + + for x = rightmost.left, rightmost.left + math.abs(xdist) do for y = botmost.top, botmost.top + math.abs(ydist) do --We know a collision has occurred if a pixel is occupied by both images. We do this by @@ -398,16 +398,16 @@ local function pCollidesWith(self, other) else testX = x - img1C.left + 1 end if img1T.top then testY = y - img1C.top + 1 else testY = y - img1C.top + 1 end - + local occupy1 = img1[testY + img1.bounds.y-1][testX + img1.bounds.x-1] ~= nil - + if img2T.left then testX = x - img2C.left + 1 else testX = x - img2C.left + 1 end if img2T.top then testY = y - img2C.top + 1 else testY = y - img2C.top + 1 end - + local occupy2 = img2[testY + img2.bounds.y-1][testX + img2.bounds.x-1] ~= nil - + if occupy1 and occupy2 then return true end end end @@ -429,7 +429,7 @@ local function moveTo(self, x, y) else image = self.image end - + self.x = x - image.bounds.x + 1 self.y = y - image.bounds.y + 1 end @@ -448,7 +448,7 @@ image:table = a table of the image. Indexed by height, a series of sub-tables, e dimensions:table = width = the width of the entire image in pixels height = the height of the entire image in pixels - + mirror:table = x:bool = whether or not the image is mirrored on the X axis y:bool = whether or not the image is mirrored on the Y axis @@ -464,19 +464,19 @@ draw:function = see drawS (above) y:number = the initial Y position of the sprite ]]-- function loadSprite(path, x, y) - local sprite = { + local sprite = { type = "sprite", x = x, y = y, image = { }, mirror = { x = false, y = false } } - + if fs.exists(path) then local file = io.open(path, "r" ) local leftX, rightX = math.huge, 0 local topY, botY = nil,nil - + local lcount = 0 for line in file:lines() do lcount = lcount+1 @@ -492,7 +492,7 @@ function loadSprite(path, x, y) end end file:close() - + sprite.image.bounds = { x = leftX, width = rightX - leftX + 1, @@ -503,10 +503,10 @@ function loadSprite(path, x, y) width = rightX, height = botY } - + sprite.x = sprite.x - leftX + 1 sprite.y = sprite.y - topY + 1 - + sprite.repaint = repaintS sprite.rCollidesWith = rCollidesWith sprite.pCollidesWith = pCollidesWith @@ -536,13 +536,13 @@ function loadAnimation(path, x, y, currentFrame) mirror = { x = false, y = false }, currentFrame = currentFrame } - + table.insert(anim.frames, { }) if fs.exists(path) then local file = io.open(path, "r") local leftX, rightX = math.huge, 0 local topY, botY = nil,nil - + local lcount = 0 for line in file:lines() do lcount = lcount+1 @@ -589,17 +589,17 @@ function loadAnimation(path, x, y, currentFrame) } anim.x = anim.x - leftX + 1 anim.y = anim.y - topY + 1 - - if not currentFrame or type(currentFrame) ~= "number" or currentFrame < 1 or - currentFrame > #anim.frames then - anim.currentFrame = 1 + + if not currentFrame or type(currentFrame) ~= "number" or currentFrame < 1 or + currentFrame > #anim.frames then + anim.currentFrame = 1 end - + anim.timerID = nil anim.lowerBound = 1 anim.upperBound = #anim.frames anim.updating = false - + anim.repaint = repaintA anim.rCollidesWith = rCollidesWith anim.pCollidesWith = pCollidesWith @@ -612,4 +612,4 @@ function loadAnimation(path, x, y, currentFrame) else error(path.." not found!") end -end \ No newline at end of file +end diff --git a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/npaintpro.lua b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/npaintpro.lua index 0c214a60d..826468eb7 100644 --- a/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/npaintpro.lua +++ b/src/main/resources/assets/computercraft/lua/treasure/nitrogenfingers/npaintpro/npaintpro.lua @@ -68,7 +68,7 @@ local px,py,pz,pfx,pfz = 0,0,0,0,0 --The form of layering used local layering = "up" ---The animation state of the selection rectangle and image buffer +--The animation state of the selection rectangle and image buffer local rectblink = 0 --The ID for the timer local recttimer = nil @@ -268,7 +268,7 @@ local helpTopics = { message = "Clicking on the mode display at the bottom of the screen will open the options menu. Here you can".. " activate all of the modes in the program with a simple mouse click. Pressing left control will open up the".. " file menu automatically.", - controls = { + controls = { { "leftCtrl", "Opens the file menu" }, { "leftAlt", "Opens the paint menu" } } @@ -317,8 +317,8 @@ local toplim,botlim,leflim,riglim = nil,nil,nil,nil --The selected path local sPath = nil ---[[ - Section: Helpers +--[[ + Section: Helpers ]]-- --[[Converts a colour parameter into a single-digit hex coordinate for the colour @@ -326,12 +326,12 @@ local sPath = nil Returns:string A string conversion of the colour ]]-- local function getHexOf(colour) - if not colour or not tonumber(colour) then - return " " + if not colour or not tonumber(colour) then + return " " end local value = math.log(colour)/math.log(2) - if value > 9 then - value = hexnums[value] + if value > 9 then + value = hexnums[value] end return value end @@ -355,7 +355,7 @@ end local function updateImageLims(forAllFrames) local f,l = sFrame,sFrame if forAllFrames == true then f,l = 1,framecount end - + toplim,botlim,leflim,riglim = nil,nil,nil,nil for locf = f,l do for y,_ in pairs(frames[locf]) do @@ -371,7 +371,7 @@ local function updateImageLims(forAllFrames) end end end - + --There is just... no easier way to do this. It's horrible, but necessary if textEnabled then for locf = f,l do @@ -406,19 +406,19 @@ end function calculateMaterials() updateImageLims(animated) requiredMaterials = {} - for i=1,16 do - requiredMaterials[i] = 0 + for i=1,16 do + requiredMaterials[i] = 0 end - + if not toplim then return end - + for i=1,#frames do for y = toplim, botlim do for x = leflim, riglim do if type(frames[i][y][x]) == "number" then requiredMaterials[math.log(frames[i][y][x],10)/math.log(2,10) + 1] = requiredMaterials[math.log(frames[i][y][x],10)/math.log(2,10) + 1] + 1 - end + end end end end @@ -455,16 +455,16 @@ end local function rsTimeReceive(timeout) local timerID if timeout then timerID = os.startTimer(timeout) end - + local id,key,msg = nil,nil while true do id,key,msg = os.pullEvent() - + if id == "timer" then if key == timerID then return else updateTimer(key) end end - if id == "rednet_message" then + if id == "rednet_message" then return key,msg end end @@ -490,9 +490,9 @@ local function drawPictureTable(image, xinit, yinit, alpha) end end ---[[ - Section: Loading -]]-- +--[[ + Section: Loading +]]-- --[[Loads a non-animted paint file into the program Params: path:string = The path in which the file is located @@ -526,7 +526,7 @@ local function loadNFT(path) frames[sFrame] = { } frames[sFrame].text = { } frames[sFrame].textcol = { } - + if fs.exists(path) then local file = io.open(path, "r") local sLine = file:read() @@ -535,7 +535,7 @@ local function loadNFT(path) table.insert(frames[sFrame], num, {}) table.insert(frames[sFrame].text, num, {}) table.insert(frames[sFrame].textcol, num, {}) - + --As we're no longer 1-1, we keep track of what index to write to local writeIndex = 1 --Tells us if we've hit a 30 or 31 (BG and FG respectively)- next char specifies the curr colour @@ -614,13 +614,13 @@ local function saveNFP(path) local file = io.open(path, "w") updateImageLims(false) - if not toplim then + if not toplim then file:close() return end for y=1,botlim do local line = "" - if frames[sFrame][y] then + if frames[sFrame][y] then for x=1,riglim do line = line..getHexOf(frames[sFrame][y][x]) end @@ -639,7 +639,7 @@ local function saveNFT(path) if not fs.exists(sDir) then fs.makeDir(sDir) end - + local file = io.open(path, "w") updateImageLims(false) if not toplim then @@ -678,17 +678,17 @@ local function saveNFA(path) if not fs.exists(sDir) then fs.makeDir(sDir) end - + local file = io.open(path, "w") updateImageLims(true) - if not toplim then + if not toplim then file:close() return end for i=1,#frames do for y=1,botlim do local line = "" - if frames[i][y] then + if frames[i][y] then for x=1,riglim do line = line..getHexOf(frames[i][y][x]) end @@ -709,14 +709,14 @@ local function init() if textEnabled then loadNFT(sPath) table.insert(ddModes, 2, { "text", "textpaint", name = "text"}) - elseif animated then + elseif animated then loadNFA(sPath) table.insert(ddModes, #ddModes, { "record", "play", name = "anim" }) table.insert(ddModes, #ddModes, { "go to", "remove", name = "frames"}) table.insert(ddModes[2], #ddModes[2], "blueprint on") table.insert(ddModes[2], #ddModes[2], "layers on") - else - loadNFP(sPath) + else + loadNFP(sPath) table.insert(ddModes[2], #ddModes[2], "blueprint on") end @@ -725,8 +725,8 @@ local function init() end end ---[[ - Section: Drawing +--[[ + Section: Drawing ]]-- @@ -747,7 +747,7 @@ local function drawLogo() msg = "By NitrogenFingers" term.setCursorPos(w/2 - #msg/2, h-2) term.write(msg) - + os.pullEvent() end @@ -772,13 +772,13 @@ local function drawCanvas() if pz >= 1 and pz <= #frames then sFrame = pz end - + if py < sy then sy = py elseif py > sy + h - 1 then sy = py + h - 1 end if px < sx then sx = px elseif px > sx + w - 2 then sx = px + w - 2 end end - + if pfx == 1 then turtlechar = ">" elseif pfx == -1 then turtlechar = "<" elseif pfz == 1 then turtlechar = "V" @@ -794,10 +794,10 @@ local function drawCanvas() else topLayer,botLayer = sFrame,sFrame end - + for currframe = botLayer,topLayer,1 do for y=sy+1,sy+h-1 do - if frames[currframe][y] then + if frames[currframe][y] then for x=sx+1,sx+w-2 do term.setCursorPos(x-sx,y-sy) if frames[currframe][y][x] then @@ -808,7 +808,7 @@ local function drawCanvas() else term.write(" ") end - else + else tileExists = false for i=currframe-1,botLayer,-1 do if frames[i][y][x] then @@ -816,7 +816,7 @@ local function drawCanvas() break end end - + if not tileExists then if blueprint then term.setBackgroundColour(colours.blue) @@ -835,7 +835,7 @@ local function drawCanvas() term.write(" ") end else - term.setBackgroundColour(alphaC) + term.setBackgroundColour(alphaC) if textEnabled and frames[currframe].textcol[y][x] and frames[currframe].text[y][x] then term.setTextColour(frames[currframe].textcol[y][x]) term.write(frames[currframe].text[y][x]) @@ -849,7 +849,7 @@ local function drawCanvas() else for x=sx+1,sx+w-2 do term.setCursorPos(x-sx,y-sy) - + tileExists = false for i=currframe-1,botLayer,-1 do if frames[i][y] and frames[i][y][x] then @@ -857,7 +857,7 @@ local function drawCanvas() break end end - + if not tileExists then if blueprint then term.setBackgroundColour(colours.blue) @@ -876,7 +876,7 @@ local function drawCanvas() term.write(" ") end else - term.setBackgroundColour(alphaC) + term.setBackgroundColour(alphaC) term.write(" ") end end @@ -884,7 +884,7 @@ local function drawCanvas() end end end - + --Then the printer, if he's on if state == "active print" then local bgColour = alphaC @@ -899,14 +899,14 @@ local function drawCanvas() bgColour = frames[sFrame][py-sy][px-sx] elseif blueprint then bgColour = colours.blue end end - + term.setBackgroundColour(bgColour) if bgColour == colours.black then term.setTextColour(colours.white) else term.setTextColour(colours.black) end - + term.write(turtlechar) end - + --Then the buffer if selectrect then if buffer and rectblink == 1 then @@ -920,12 +920,12 @@ local function drawCanvas() end end end - + --This draws the "selection" box local add = nil if buffer then term.setBackgroundColour(colours.lightGrey) - else + else term.setBackgroundColour(colours.grey) end for i=selectrect.x1, selectrect.x2 do @@ -947,7 +947,7 @@ local function drawCanvas() end end ---[[Draws the colour picker on the right side of the screen, the colour pallette and the footer with any +--[[Draws the colour picker on the right side of the screen, the colour pallette and the footer with any messages currently being displayed Params: none Returns:nil @@ -1001,7 +1001,7 @@ local function drawInterface() end --Footer if inMenu then return end - + term.setCursorPos(1, h) term.setBackgroundColour(colours.lightGrey) term.setTextColour(colours.grey) @@ -1016,14 +1016,14 @@ local function drawInterface() term.setBackgroundColour(colours.lightGrey) term.setTextColour(colours.grey) term.write(getStateMessage()) - + local coords="X:"..sx.." Y:"..sy if animated then coords = coords.." Frame:"..sFrame.."/"..framecount.." " end term.setCursorPos(w-#coords+1,h) if state == "play" then term.setBackgroundColour(colours.lime) elseif record then term.setBackgroundColour(colours.red) end term.write(coords) - + if animated then term.setCursorPos(w-1,h) term.setBackgroundColour(colours.grey) @@ -1075,17 +1075,17 @@ local function drawHelpScreen() print(helpTopics[selectedHelp].controls[i][2]) end end - + local id,p1,p2,p3 = os.pullEvent() - + if id == "timer" then updateTimer(p1) - elseif id == "key" then + elseif id == "key" then if selectedHelp then selectedHelp = nil else break end elseif id == "mouse_click" then - if not selectedHelp then + if not selectedHelp then if p3 >=3 and p3 <= 2+#helpTopics then - selectedHelp = p3-2 + selectedHelp = p3-2 else break end else selectedHelp = nil @@ -1137,7 +1137,7 @@ local function wprintOffCenter(msg, height, width, offset) end term.setCursorPos(width/2 - #string.sub(msg, ops)/2 + offset, height + inc) term.write(string.sub(msg, ops)) - + return inc + 1 end @@ -1151,7 +1151,7 @@ local function displayConfirmDialogue(ctitle, msg) local dialogoffset = 8 --We actually print twice- once to get the lines, second time to print proper. Easier this way. local lines = wprintOffCenter(msg, 5, w - (dialogoffset+2) * 2, dialogoffset + 2) - + term.setCursorPos(dialogoffset, 3) term.setBackgroundColour(colours.grey) term.setTextColour(colours.lightGrey) @@ -1163,11 +1163,11 @@ local function displayConfirmDialogue(ctitle, msg) term.setCursorPos(dialogoffset, 4) term.write(string.rep(" ", w - dialogoffset * 2)) for i=5,5+lines do - term.setCursorPos(dialogoffset, i) + term.setCursorPos(dialogoffset, i) term.write(" "..string.rep(" ", w - (dialogoffset) * 2 - 2).." ") end wprintOffCenter(msg, 5, w - (dialogoffset+2) * 2, dialogoffset + 2) - + --In the event of a message, the player hits anything to continue while true do local id,key = os.pullEvent() @@ -1190,24 +1190,24 @@ local function displayDropDown(x, y, options) for i=1,#options do local currVal = options[i] if type(currVal) == "table" then currVal = currVal.name end - + longestX = math.max(longestX, #currVal) end local xOffset = math.max(0, longestX - ((w-2) - x) + 1) local yOffset = math.max(0, #options - ((h-1) - y)) - + local clickTimes = 0 local tid = nil local selection = nil while clickTimes < 2 do drawCanvas() drawInterface() - + term.setCursorPos(x-xOffset,y-yOffset) term.setBackgroundColour(colours.grey) term.setTextColour(colours.lightGrey) term.write(options.name..string.rep(" ", longestX-#options.name + 2)) - + for i=1,#options do term.setCursorPos(x-xOffset, y-yOffset+i) if i==selection and clickTimes % 2 == 0 then @@ -1218,7 +1218,7 @@ local function displayDropDown(x, y, options) term.setTextColour(colours.grey) end local currVal = options[i] - if type(currVal) == "table" then + if type(currVal) == "table" then term.write(currVal.name..string.rep(" ", longestX-#currVal.name + 1)) term.setBackgroundColour(colours.grey) term.setTextColour(colours.lightGrey) @@ -1227,18 +1227,18 @@ local function displayDropDown(x, y, options) term.write(currVal..string.rep(" ", longestX-#currVal + 2)) end end - + local id, p1, p2, p3 = os.pullEvent() if id == "timer" then - if p1 == tid then + if p1 == tid then clickTimes = clickTimes + 1 - if clickTimes > 2 then + if clickTimes > 2 then break - else - tid = os.startTimer(0.1) + else + tid = os.startTimer(0.1) end - else - updateTimer(p1) + else + updateTimer(p1) drawCanvas() drawInterface() end @@ -1252,15 +1252,15 @@ local function displayDropDown(x, y, options) end end end - + if type(selection) == "number" then selection = options[selection] end - - if type(selection) == "string" then + + if type(selection) == "string" then inDropDown = false return selection - elseif type(selection) == "table" then + elseif type(selection) == "table" then return displayDropDown(x, y, selection) end end @@ -1285,16 +1285,16 @@ local function readInput(lim) --As events queue immediately, we may get an unwanted key... this will solve that problem local inputTimer = os.startTimer(0.01) local keysAllowed = false - + while true do local id,key = os.pullEvent() - + if keysAllowed then if id == "key" and key == 14 and #inputString > 0 then inputString = string.sub(inputString, 1, #inputString-1) term.setCursorPos(ox + #inputString,oy) term.write(" ") - elseif id == "key" and key == 28 and inputString ~= string.rep(" ", #inputString) then + elseif id == "key" and key == 28 and inputString ~= string.rep(" ", #inputString) then break elseif id == "key" and key == keys.leftCtrl then return "" @@ -1302,9 +1302,9 @@ local function readInput(lim) inputString = inputString..key end end - + if id == "timer" then - if key == inputTimer then + if key == inputTimer then keysAllowed = true else updateTimer(key) @@ -1318,7 +1318,7 @@ local function readInput(lim) term.write(inputString) term.setCursorPos(ox + #inputString, oy) end - + while string.sub(inputString, 1, 1) == " " do inputString = string.sub(inputString, 2, #inputString) end @@ -1326,12 +1326,12 @@ local function readInput(lim) inputString = string.sub(inputString, 1, #inputString-1) end term.setCursorBlink(false) - + return inputString end ---[[ - Section: Image tools +--[[ + Section: Image tools ]]-- @@ -1341,13 +1341,13 @@ end ]]-- local function copyToBuffer(removeImage) buffer = { width = selectrect.x2 - selectrect.x1 + 1, height = selectrect.y2 - selectrect.y1 + 1, contents = { } } - + local containsSomething = false for y=1,buffer.height do buffer.contents[y] = { } local f,l = sFrame,sFrame if record then f,l = 1, framecount end - + for fra = f,l do if frames[fra][selectrect.y1 + y - 1] then for x=1,buffer.width do @@ -1372,7 +1372,7 @@ local function copyFromBuffer(removeBuffer) for y = 1, math.min(buffer.height,selectrect.y2-selectrect.y1+1) do local f,l = sFrame, sFrame if record then f,l = 1, framecount end - + for fra = f,l do if not frames[fra][selectrect.y1+y-1] then frames[fra][selectrect.y1+y-1] = { } end for x = 1, math.min(buffer.width,selectrect.x2-selectrect.x1+1) do @@ -1380,7 +1380,7 @@ local function copyFromBuffer(removeBuffer) end end end - + if removeBuffer then buffer = nil end end @@ -1394,7 +1394,7 @@ local function moveImage(newx,newy) if newx <=0 or newy <=0 then return end local f,l = sFrame,sFrame if record then f,l = 1,framecount end - + for i=f,l do local newlines = { } for y=toplim,botlim do @@ -1418,7 +1418,7 @@ local function moveImage(newx,newy) end end end - + newlines.textcol = { } for y=toplim,botlim do local line = frames[i].textcol[y] @@ -1430,7 +1430,7 @@ local function moveImage(newx,newy) end end end - + frames[i] = newlines end end @@ -1451,7 +1451,7 @@ local function clearImage() if string.find(string.upper(readInput(1)), "Y") then local f,l = sFrame,sFrame if record then f,l = 1,framecount end - + for i=f,l do frames[i] = { } end @@ -1470,9 +1470,9 @@ end local function floodFill(x, y, targetColour, newColour) if not newColour or not targetColour then return end local nodeList = { } - + table.insert(nodeList, {x = x, y = y}) - + while #nodeList > 0 do local node = nodeList[1] if frames[sFrame][node.y] and frames[sFrame][node.y][node.x] == targetColour then @@ -1486,8 +1486,8 @@ local function floodFill(x, y, targetColour, newColour) end end ---[[ - Section: Animation Tools +--[[ + Section: Animation Tools ]]-- --[[Enters play mode, allowing the animation to play through. Interface is restricted to allow this, @@ -1498,14 +1498,14 @@ end local function playAnimation() state = "play" selectedrect = nil - + local animt = os.startTimer(animtime) repeat drawCanvas() drawInterface() - + local id,key,_,y = os.pullEvent() - + if id=="timer" then if key == animt then animt = os.startTimer(animtime) @@ -1536,15 +1536,15 @@ local function changeFrame(newframe) term.setBackgroundColour(colours.lightGrey) term.setTextColour(colours.grey) term.clearLine() - + term.write("Go to frame: ") newframe = tonumber(readInput(2)) if not newframe or newframe <= 0 then inMenu = false - return + return end elseif newframe <= 0 then return end - + if newframe > framecount then for i=framecount+1,newframe do frames[i] = {} @@ -1570,12 +1570,12 @@ local function removeFramesAfter(frame) if frame==framecount then return end drawMessage("Remove frames "..(frame+1).."/"..framecount.."? Y/N :") local answer = string.upper(readInput(1)) - - if string.find(answer, string.upper("Y")) ~= 1 then + + if string.find(answer, string.upper("Y")) ~= 1 then inMenu = false - return + return end - + for i=frame+1, framecount do frames[i] = nil end @@ -1596,7 +1596,7 @@ end local function getLeft(curx, curz) local hand = "left" if layering == "up" then hand = "right" end - + if hand == "right" then if curx == 1 then return 0,-1 end if curx == -1 then return 0,1 end @@ -1619,7 +1619,7 @@ end local function getRight(curx, curz) local hand = "left" if layering == "up" then hand = "right" end - + if hand == "right" then if curx == 1 then return 0,1 end if curx == -1 then return 0,-1 end @@ -1647,7 +1647,7 @@ local function locatePrinters() drawCanvas() drawInterface() state = oldState - + local modemOpened = false for k,v in pairs(rs.getSides()) do if peripheral.isPresent(v) and peripheral.getType(v) == "modem" then @@ -1656,17 +1656,17 @@ local function locatePrinters() break end end - + if not modemOpened then displayConfirmDialogue("Modem not found!", "No modem peripheral. Must have network modem to locate printers.") return false end - + rednet.broadcast("$3DPRINT IDENTIFY") - + while true do local id, msg = rsTimeReceive(1) - + if not id then break end if string.find(msg, "$3DPRINT IDACK") == 1 then msg = string.gsub(msg, "$3DPRINT IDACK ", "") @@ -1674,7 +1674,7 @@ local function locatePrinters() table.insert(printerNames, msg) end end - + if #printerList == 0 then displayConfirmDialogue("Printers not found!", "No active printers found in proximity of this computer.") return false @@ -1692,7 +1692,7 @@ local function sendPC(command,param) local msg = "$PC "..command if param then msg = msg.." "..param end rednet.send(printerList[selectedPrinter], msg) - + while true do local id,key = rsTimeReceive() if id == printerList[selectedPrinter] then @@ -1713,7 +1713,7 @@ local function sendPC(command,param) end end end - + --Changes to position are handled after the event has been successfully completed if command == "FW" then px = px + pfx @@ -1724,13 +1724,13 @@ local function sendPC(command,param) elseif command == "UP" then if layering == "up" then py = py + 1 - else + else py = py - 1 end elseif command == "DW" then if layering == "up" then py = py - 1 - else + else py = py + 1 end elseif command == "TL" then @@ -1741,7 +1741,7 @@ local function sendPC(command,param) pfx = -pfx pfz = -pfz end - + drawCanvas() drawInterface() end @@ -1788,7 +1788,7 @@ local function performPrint() --An up layering starts our builder bot on the bottom left corner of our build px,py,pz = leflim, 0, botlim + 1 pfx,pfz = 0,-1 - + --We move him forward and up a bit from his original position. sendPC("FW") sendPC("UP") @@ -1801,7 +1801,7 @@ local function performPrint() else rowbot,rowtop,rowinc = toplim,botlim,1 end - + for rows = rowbot,rowtop,rowinc do --Then we decide if we're going left or right, depending on what side we're on local linebot,linetop,lineinc = nil,nil,nil @@ -1814,7 +1814,7 @@ local function performPrint() turnToFace(-1,0) linebot,linetop,lineinc = riglim,leflim,-1 end - + for lines = linebot,linetop,lineinc do --We move our turtle forward, placing the right material at each step local material = frames[py][pz][px] @@ -1827,7 +1827,7 @@ local function performPrint() sendPC("FW") end end - + --The printer then has to do a U-turn, depending on which way he's facing and --which way he needs to go local temppfx,temppfz = getLeft(pfx,pfz) @@ -1873,7 +1873,7 @@ local function performPrint() while pz < #frames do sendPC("FW") end - + --For each layer in the frame we build our wall, the move back for layers = 1,#frames do --We first decide if we're going left or right based on our position @@ -1883,7 +1883,7 @@ local function performPrint() else rowbot,rowtop,rowinc = riglim,leflim,-1 end - + for rows = rowbot,rowtop,rowinc do --Then we decide if we're going up or down, depending on our given altitude local linebot,linetop,lineinc = nil,nil,nil @@ -1892,7 +1892,7 @@ local function performPrint() else linebot,linetop,lineinc = toplim,botlim,1 end - + for lines = linebot,linetop,lineinc do --We move our turtle up/down, placing the right material at each step local material = frames[pz][py][px] @@ -1906,14 +1906,14 @@ local function performPrint() else sendPC("UP") end end end - + if rows ~= rowtop then turnToFace(rowinc,0) sendPC("FW") turnToFace(0,1) end end - + if layers ~= #frames then sendPC("TU") sendPC("FW") @@ -1927,14 +1927,14 @@ local function performPrint() end turnToFace(0,1) end - + sendPC("DE") - + displayConfirmDialogue("Print complete", "The 3D print was successful.") end ---[[ - Section: Interface +--[[ + Section: Interface ]]-- --[[Runs the printing interface. Allows users to find/select a printer, the style of printing to perform and to begin the operation @@ -1953,7 +1953,7 @@ local function runPrintInterface() if not locatePrinters() then return false end - + layering = "up" requirementsDisplayed = false selectedPrinter = 1 @@ -1967,7 +1967,7 @@ local function runPrintInterface() drawInterface() term.setBackgroundColour(colours.lightGrey) term.setTextColour(colours.black) - + local msg = "3D Printing" term.setCursorPos(w/2-#msg/2 - 2, 1) term.write(msg) @@ -1982,7 +1982,7 @@ local function runPrintInterface() term.write(msg) term.setBackgroundColour(colours.lightGrey) term.setTextColour(colours.black) - + term.setCursorPos(7, 2) term.write("Layering") drawPictureTable(layerUpIcon, 3, 3, colours.white) @@ -2001,7 +2001,7 @@ local function runPrintInterface() end term.setCursorPos(12, 9) term.write("Forward") - + term.setBackgroundColour(colours.lightGrey) term.setTextColour(colours.black) term.setCursorPos(31, 2) @@ -2014,16 +2014,16 @@ local function runPrintInterface() term.setTextColour(colours.red) end term.write(" "..printerNames[selectedPrinter].." ") - + term.setBackgroundColour(colours.grey) term.setTextColour(colours.lightGrey) term.setCursorPos(25, 10) term.write(" Cancel ") term.setCursorPos(40, 10) term.write(" Print ") - + local id, p1, p2, p3 = os.pullEvent() - + if id == "timer" then updateTimer(p1) elseif id == "mouse_click" then @@ -2052,7 +2052,7 @@ local function runPrintInterface() ready = false while true do local id,msg = rsTimeReceive(10) - + if id == printerList[selectedPrinter] and msg == "$3DPRINT ACTACK" then ready = true break @@ -2077,100 +2077,100 @@ end ]]-- local function performSelection(mode) if not mode or mode == "" then return - + elseif mode == "help" then drawHelpScreen() - + elseif mode == "blueprint on" then blueprint = true ddModes[2][3] = "blueprint off" - + elseif mode == "blueprint off" then blueprint = false ddModes[2][3] = "blueprint on" - + elseif mode == "layers on" then layerDisplay = true ddModes[2][4] = "layers off" - + elseif mode == "layers off" then layerDisplay = false ddModes[2][4] = "layers on" - + elseif mode == "direction on" then printDirection = true ddModes[2][5] = "direction off" - + elseif mode == "direction off" then printDirection = false ddModes[2][5] = "direction on" - + elseif mode == "go to" then changeFrame() - + elseif mode == "remove" then removeFramesAfter(sFrame) - + elseif mode == "play" then playAnimation() - + elseif mode == "copy" then if selectrect and selectrect.x1 ~= selectrect.x2 then copyToBuffer(false) end - + elseif mode == "cut" then - if selectrect and selectrect.x1 ~= selectrect.x2 then + if selectrect and selectrect.x1 ~= selectrect.x2 then copyToBuffer(true) end - + elseif mode == "paste" then - if selectrect and selectrect.x1 ~= selectrect.x2 then + if selectrect and selectrect.x1 ~= selectrect.x2 then copyFromBuffer(false) end - + elseif mode == "hide" then selectrect = nil if state == "select" then state = "corner select" end - + elseif mode == "alpha to left" then if lSel then alphaC = lSel end - + elseif mode == "alpha to right" then if rSel then alphaC = rSel end - + elseif mode == "record" then record = not record - + elseif mode == "clear" then if state=="select" then buffer = nil else clearImage() end - + elseif mode == "select" then if state=="corner select" or state=="select" then state = "paint" elseif selectrect and selectrect.x1 ~= selectrect.x2 then state = "select" else - state = "corner select" + state = "corner select" end - + elseif mode == "print" then state = "print" runPrintInterface() state = "paint" - + elseif mode == "save" then if animated then saveNFA(sPath) elseif textEnabled then saveNFT(sPath) else saveNFP(sPath) end - + elseif mode == "exit" then isRunning = false - + elseif mode ~= state then state = mode else state = "paint" - + end end @@ -2184,12 +2184,12 @@ local function handleEvents() while isRunning do drawCanvas() drawInterface() - + if state == "text" then term.setCursorPos(textCurX - sx, textCurY - sy) term.setCursorBlink(true) end - + local id,p1,p2,p3 = os.pullEvent() term.setCursorBlink(false) if id=="timer" then @@ -2212,20 +2212,20 @@ local function handleEvents() if state=="pippette" then if p1==1 then if frames[sFrame][p3+sy] and frames[sFrame][p3+sy][p2+sx] then - lSel = frames[sFrame][p3+sy][p2+sx] + lSel = frames[sFrame][p3+sy][p2+sx] end elseif p1==2 then if frames[sFrame][p3+sy] and frames[sFrame][p3+sy][p2+sx] then - rSel = frames[sFrame][p3+sy][p2+sx] + rSel = frames[sFrame][p3+sy][p2+sx] end end elseif state=="move" then updateImageLims(record) moveImage(p2,p3) elseif state=="flood" then - if p1 == 1 and lSel and frames[sFrame][p3+sy] then + if p1 == 1 and lSel and frames[sFrame][p3+sy] then floodFill(p2,p3,frames[sFrame][p3+sy][p2+sx],lSel) - elseif p1 == 2 and rSel and frames[sFrame][p3+sy] then + elseif p1 == 2 and rSel and frames[sFrame][p3+sy] then floodFill(p2,p3,frames[sFrame][p3+sy][p2+sx],rSel) end elseif state=="corner select" then @@ -2234,10 +2234,10 @@ local function handleEvents() elseif selectrect.x1 ~= p2+sx and selectrect.y1 ~= p3+sy then if p2+sx w + sx - 2 then sx = textCurX - w + 2 end elseif tonumber(p1) then @@ -2335,16 +2335,16 @@ local function handleEvents() textCurY = textCurY+1 if textCurY > h + sy - 1 then sy = textCurY - h + 1 end end - + elseif p1==keys.leftCtrl then - local sel = displayDropDown(1, h-1, ddModes[#ddModes]) + local sel = displayDropDown(1, h-1, ddModes[#ddModes]) performSelection(sel) elseif p1==keys.leftAlt then - local sel = displayDropDown(1, h-1, ddModes[1]) + local sel = displayDropDown(1, h-1, ddModes[1]) performSelection(sel) - elseif p1==keys.h then + elseif p1==keys.h then performSelection("help") - elseif p1==keys.x then + elseif p1==keys.x then performSelection("cut") elseif p1==keys.c then performSelection("copy") @@ -2415,7 +2415,7 @@ local function handleEvents() selectrect.y1 = selectrect.y1-1 selectrect.y2 = selectrect.y2-1 elseif sy > 0 then sy=sy-1 end - elseif p1==keys.down then + elseif p1==keys.down then if state == "move" then updateImageLims(record) if toplim and leflim then @@ -2431,7 +2431,7 @@ local function handleEvents() end --[[ - Section: Main + Section: Main ]]-- if not term.isColour() then @@ -2475,15 +2475,15 @@ if fs.exists(sPath) then print("Can only edit .nfp, .nft and .nfa files:",string.find(sPath, ".nfp"),#sPath-3) return end - + if string.find(sPath, ".nfa") == #sPath-3 then animated = true end - + if string.find(sPath, ".nft") == #sPath-3 then textEnabled = true - end - + end + if string.find(sPath, ".nfp") == #sPath-3 and animated then print("Convert to nfa? Y/N") if string.find(string.lower(io.read()), "y") then @@ -2494,24 +2494,24 @@ if fs.exists(sPath) then animated = false end end - + --Again this is possible, I just haven't done it. Maybe I will? if textEnabled and (string.find(sPath, ".nfp") == #sPath-3 or string.find(sPath, ".nfa") == #sPath-3) then print("Cannot convert to nft") end else - if not animated and not textEnabled and string.find(sPath, ".nfp") ~= #sPath-3 then + if not animated and not textEnabled and string.find(sPath, ".nfp") ~= #sPath-3 then sPath = sPath..".nfp" - elseif animated and string.find(sPath, ".nfa") ~= #sPath-3 then + elseif animated and string.find(sPath, ".nfa") ~= #sPath-3 then sPath = sPath..".nfa" elseif textEnabled and string.find(sPath, ".nft") ~= #sPath-3 then sPath = sPath..".nft" end -end +end drawLogo() init() handleEvents() term.setBackgroundColour(colours.black) -shell.run("clear") \ No newline at end of file +shell.run("clear") 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 bcd57c718..2a1a447a4 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 @@ -175,4 +175,4 @@ drawScreen() while true do loop() parallel.waitForAny(loop, compute) -end \ No newline at end of file +end diff --git a/src/test/resources/test-rom/mcfly.lua b/src/test/resources/test-rom/mcfly.lua index d1b0ad599..ac64ad565 100644 --- a/src/test/resources/test-rom/mcfly.lua +++ b/src/test/resources/test-rom/mcfly.lua @@ -13,7 +13,7 @@ -- -- @tparam string func The function's name -- @tparam int idx The argument index to this function --- @tparam string ty The type this argument should have. May be 'value' for +-- @tparam string ty The type this argument should have. May be 'value' for -- any non-nil value. -- @param val val The value to check -- @throws If this value doesn't match the expected type. diff --git a/src/test/resources/test-rom/spec/programs/delete_spec.lua b/src/test/resources/test-rom/spec/programs/delete_spec.lua index 5036f7eae..1eec95cc4 100644 --- a/src/test/resources/test-rom/spec/programs/delete_spec.lua +++ b/src/test/resources/test-rom/spec/programs/delete_spec.lua @@ -39,7 +39,7 @@ describe("The rm program", function() expect(capture(stub, "rm")) :matches { ok = true, output = "Usage: rm \n", error = "" } end) - + it("errors when trying to delete a read-only file", function() expect(capture(stub, "rm /rom/startup.lua")) :matches { ok = true, output = "", error = "/rom/startup.lua: Access denied\n" } diff --git a/src/test/resources/test-rom/spec/programs/edit_spec.lua b/src/test/resources/test-rom/spec/programs/edit_spec.lua index 7ca0b04f2..e58938e23 100644 --- a/src/test/resources/test-rom/spec/programs/edit_spec.lua +++ b/src/test/resources/test-rom/spec/programs/edit_spec.lua @@ -2,7 +2,7 @@ local capture = require "test_helpers".capture_program describe("The edit program", function() - it("displays its usage when given no argument", function() + it("displays its usage when given no argument", function() expect(capture(stub, "edit")) :matches { ok = true, output = "Usage: edit \n", error = "" } end) diff --git a/src/test/resources/test-rom/spec/programs/http/pastebin_spec.lua b/src/test/resources/test-rom/spec/programs/http/pastebin_spec.lua index 5b13d59a9..831d88fc1 100644 --- a/src/test/resources/test-rom/spec/programs/http/pastebin_spec.lua +++ b/src/test/resources/test-rom/spec/programs/http/pastebin_spec.lua @@ -51,7 +51,7 @@ describe("The pastebin program", function() local file = fs.open( "testup", "w" ) file.close() - + expect(capture(stub, "pastebin", "put", "testup" )) :matches { ok = true, output = "Connecting to pastebin.com... Success.\nUploaded as https://pastebin.com/abcde\nRun \"pastebin get abcde\" to download anywhere\n", error = "" } end) diff --git a/src/test/resources/test-rom/spec/programs/id_spec.lua b/src/test/resources/test-rom/spec/programs/id_spec.lua index 73206e7fb..7c5d47da7 100644 --- a/src/test/resources/test-rom/spec/programs/id_spec.lua +++ b/src/test/resources/test-rom/spec/programs/id_spec.lua @@ -1,7 +1,7 @@ local capture = require "test_helpers".capture_program describe("The id program", function() - + it("displays computer id", function() local id = os.getComputerID() diff --git a/src/test/resources/test-rom/spec/programs/motd_spec.lua b/src/test/resources/test-rom/spec/programs/motd_spec.lua index 3781e2e16..72becbf30 100644 --- a/src/test/resources/test-rom/spec/programs/motd_spec.lua +++ b/src/test/resources/test-rom/spec/programs/motd_spec.lua @@ -7,7 +7,7 @@ describe("The motd program", function() file.write("Hello World!") file.close() settings.set("motd.path", "/modt_check.txt") - + expect(capture(stub, "motd")) :matches { ok = true, output = "Hello World!\n", error = "" } end) diff --git a/src/test/resources/test-rom/spec/programs/set_spec.lua b/src/test/resources/test-rom/spec/programs/set_spec.lua index 64dba1447..46cf0b84d 100644 --- a/src/test/resources/test-rom/spec/programs/set_spec.lua +++ b/src/test/resources/test-rom/spec/programs/set_spec.lua @@ -6,7 +6,7 @@ describe("The set program", function() settings.clear() settings.set("Test", "Hello World!") settings.set("123", 456) - + expect(capture(stub, "set")) :matches { ok = true, output = '"123" is 456\n"Test" is "Hello World!"\n', error = "" } end) @@ -15,12 +15,12 @@ describe("The set program", function() settings.clear() settings.set("Test", "Hello World!") settings.set("123", 456) - + expect(capture(stub, "set Test")) :matches { ok = true, output = '"Test" is "Hello World!"\n', error = "" } end) - it("set a setting", function() + it("set a setting", function() expect(capture(stub, "set Test Hello")) :matches { ok = true, output = '"Test" set to "Hello"\n', error = "" } diff --git a/src/test/resources/test-rom/spec/programs/time_spec.lua b/src/test/resources/test-rom/spec/programs/time_spec.lua index e9c1eff31..91f82fef0 100644 --- a/src/test/resources/test-rom/spec/programs/time_spec.lua +++ b/src/test/resources/test-rom/spec/programs/time_spec.lua @@ -5,7 +5,7 @@ describe("The time program", function() it("displays time", function() local time = textutils.formatTime(os.time()) local day = os.day() - + expect(capture(stub, "time")) :matches { ok = true, output = "The time is " .. time .. " on Day " .. day .. "\n", error = "" } end) diff --git a/tools/check-lines.py b/tools/check-lines.py new file mode 100644 index 000000000..e1fcba620 --- /dev/null +++ b/tools/check-lines.py @@ -0,0 +1,28 @@ +import pathlib, sys + +problems = False + +# Skip images and files without extensions +exclude = [ ".png", "" ] + +for path in pathlib.Path(".").glob("src/**/*"): + if path.is_dir() or path.suffix in exclude: + continue + + with path.open(encoding="utf-8") as file: + has_dos, has_trailing, needs_final = False, False, False + for i, line in enumerate(file): + if len(line) >= 2 and line[-2] == "\r" and line[-1] == "\n" and not has_line: + print("%s has contains '\\r\\n' on line %d" % (path, i + 1)) + problems = has_dos = True + + if len(line) >= 2 and line[-2] in " \t" and line[-1] == "\n" and not has_trailing: + print("%s has trailing whitespace on line %d" % (path, i + 1)) + problems = has_trailing = True + + if line is not None and len(line) >= 1 and line[-1] != "\n": + print("%s should end with '\\n'" % path) + problems = True + +if problems: + sys.exit(1)