Update tapewrite.lua

This commit is contained in:
LDDestroier 2023-09-30 01:14:38 -04:00 committed by GitHub
parent 9f71f189ed
commit 554a099a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 10 deletions

View File

@ -1,4 +1,8 @@
local tArg = {...}
-- this doesn't work very well, keep it false
local doByteByByte = false
local fileName = tArg[1]
local tapeName = tArg[2]
local tape = peripheral.find("tape_drive")
@ -11,11 +15,16 @@ end
local byte = 0
tape.seek(-tape.getPosition())
if tapeName then
tape.setLabel(tapeName)
end
local counter = 0
local totalSize = tape.getSize()
if doByteByByte then
while true do
byte = file.read()
if not byte then break end
@ -29,6 +38,18 @@ while true do
end
end
else
print("Writing...")
local contents = file.readAll()
if #contents > totalSize then
contents = contents:sub(1, totalSize)
print("Tape too small. Audio was written incompletely.")
end
tape.write(contents)
end
tape.seek(-tape.getPosition())
file.close()