From 77a8d5442f88f66ced9fc92a54137b4a9f1cc221 Mon Sep 17 00:00:00 2001 From: mint Date: Fri, 7 May 2021 03:36:40 -0400 Subject: [PATCH] added manual mode --- rhythmblock.lua | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/rhythmblock.lua b/rhythmblock.lua index 266c873..1899de3 100644 --- a/rhythmblock.lua +++ b/rhythmblock.lua @@ -4,30 +4,33 @@ buttonColor = colors.lightGray textColor = colors.lightGray altTextColor = colors.gray backgroundColor = colors.black - +if arg[1] == nil then function round(n) -- We need a function to round the center of the terminal return n % 1 >= 0.5 and math.ceil(n) or math.floor(n) end width, height = term.getSize() -- Gets the terminal size to determine the center centerWidth = round(width / 2) -- Defines the horizontal center centerHeight = round(height / 2) -- Defines the vertical center -peripherals = peripheral.getNames() -- Gets peripherals to check if any disk drives are avavailable -if #peripherals < 0 then - print "No drive" - return true -- Exits if there's no disk drive -else - driveCount = 0 - for n = 1, #peripherals do - local driveCheck = peripherals[n] - if peripheral.getType(driveCheck) == "drive" then - drive = driveCheck - driveCount = driveCount + 1 + peripherals = peripheral.getNames() -- Gets peripherals to check if any disk drives are avavailable + if #peripherals < 0 then + print "No drive" + return true -- Exits if there's no disk drive + else + driveCount = 0 + for n = 1, #peripherals do + local driveCheck = peripherals[n] + if peripheral.getType(driveCheck) == "drive" then + drive = driveCheck + driveCount = driveCount + 1 + end + end + if driveCount > 1 then + print("Too many disk drives. Specify where the disk drive is by running rhythmbox [drive position]") -- For safety reasons + os.exit() end end - if driveCount > 1 then - print("Too many disk drives. Specify where the disk drive is by running rhythmbox [drive position]") -- For safety reasons - os.exit() - end +else + drive = arg[1] end --[[ Instead of calling every status by string, we call the variables storing the strings. This may ease translation if we plan to do it in the future.