Advertisement
freacknate09

umfloppy.lua

Jan 13th, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local floppy = component.drive
  4.  
  5. local capacityInit = floppy.getCapacity()
  6. local capacity = capacityInit/1024
  7. local fileName = ""
  8. local dataToWrite = ""
  9. local offset = 1
  10. local file
  11.  
  12. term.clear()
  13. term.write("Floppy's capacity is "..  capacity .. " kilobytes")
  14. term.setCursor(1,2)
  15. term.write("What file would you like to write to the floppy disk? File must be in the same folder as this program.")
  16. term.setCursor(1,3)
  17. fileName = io.read()
  18. term.setCursor(1,3)
  19. term.write(" ")
  20. term.setCursor(1,3)
  21. term.write("Writing to Floppy...")
  22. file = io.open(fileName, "rb")
  23.  
  24. repeat
  25.   dataToWrite = file:read(512)
  26.   if dataToWrite == nil then return end
  27.   floppy.writeSector(offset, dataToWrite)
  28.   offset = offset + 1
  29. until dataToWrite == nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement