1
0
Fork 0

Added more options

This commit is contained in:
Casey 2023-10-18 01:06:35 +03:00
parent 11be60a0b1
commit b4d4d64c16
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 41 additions and 21 deletions

View File

@ -1,5 +1,16 @@
local args = { ... }
local shouldSeek = true
local driveName = nil
if args[1] == "-S" then
shouldSeek = false
table.remove(args, 1)
end
if args[1] == "-D" then
table.remove(args, 1)
driveName = table.remove(args, 1)
end
local function n_to_kib(value)
return string.format("%6.1f kiB", value / 1024)
end
@ -31,24 +42,29 @@ local function textProgress(p, c1, c2, fmt, ...)
term.setBackgroundColor(bg)
end
local tape = { peripheral.find("tape_drive") }
if #tape == 0 then
print("tape where")
return
elseif #tape ~= 1 then
print("More than one drive found:")
for i = 1, #tape do
print(peripheral.getName(tape[i]))
end
print("Input drive name:")
io.write("> ")
tape = peripheral.wrap(read())
if not tape then
printError("wrong name")
return
end
local tape
if driveName ~= nil then
tape = peripheral.wrap(driveName)
else
tape = tape[1]
local drives = { peripheral.find("tape_drive") }
if #drives == 0 then
print("Drive where")
return
elseif #tape ~= 1 then
print("More than one drive found:")
for i = 1, #drives do
print(peripheral.getName(drives[i]))
end
print("Input drive name:")
io.write("> ")
tape = peripheral.wrap(read())
if not tape then
printError("wrong name")
return
end
else
tape = drives[1]
end
end
if not http then
@ -77,8 +93,10 @@ if length > tape.getSize() then
end
tape.stop()
tape.seek(-tape.getSize())
tape.stop()
if shouldSeek then
tape.seek(-tape.getSize())
tape.stop()
end
local _, y = term.getCursorPos()
local written = 0
@ -103,5 +121,7 @@ term.clearLine()
print("Written "..n_to_kib(written))
tape.stop()
tape.seek(-tape.getSize())
tape.stop()
if shouldSeek then
tape.seek(-tape.getSize())
tape.stop()
end