Advertisement
Guest User

umfloppy.lua

a guest
Apr 6th, 2020
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 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 = term.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. while (dataToWrite ~= nil) do
  25.   dataToWrite = file:read(512)
  26.   floppy.writeSector(offset, dataToWrite)
  27.   -- offset = offset + 1
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement