Advertisement
Guest User

umfloppy.lua

a guest
Apr 6th, 2020
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local floppy = component.drive
  4. local fs = require("filesystem")
  5. local io = require("io")
  6.  
  7. local capacityInit = floppy.getCapacity()
  8. local capacity = capacityInit/1024
  9. local fileName = ""
  10. local dataToWrite = ""
  11. local offset = 0
  12.  
  13. local function copyData()
  14.   file:seek(offset)
  15.   dataToWrite = file:read(offset)
  16.   floppy.writeByte(dataToWrite)
  17. end
  18. term.clear()
  19. term.write("Floppy's capacity is "..  capacity .. " kilobytes")
  20. term.setCursor(1,2)
  21. term.write("What file would you like to write to the floppy disk? File must be in the same folder as this program.")
  22. term.setCursor(1,3)
  23. fileName = term.read()
  24. term.setCursor(1,3)
  25. term.write(" ")
  26. term.setCursor(1,3)
  27. term.write("Writing to Floppy...")
  28. local file = fs.open(fileName, "r")
  29.  
  30. while (dataToWrite ~= nil) do
  31.   dataToWrite = file:read(offset)
  32.   floppy.writeByte(offset, dataToWrite)
  33.   offset = offset + 1
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement