Advertisement
Le_JuiceBOX

[App] diskLabeler.lua

Apr 1st, 2024
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local SEPERATOR = "======================================="
  2. local SYMBOL = "ยง"
  3. local PATTERN = "&"
  4.  
  5. function clear() shell.run("clear"); end
  6. function say(...) print(...); end
  7.  
  8. function MAIN()
  9.     clear()
  10.     say("Finding disk drive...")
  11.     local drive = peripheral.find("drive")
  12.     assert(drive,"No disk drive.")
  13.     --//////////////////////////////////////////////////////
  14.     clear()
  15.     say(SEPERATOR)
  16.     say("Welcome to AdvancedFloppyRename!")
  17.     say("Use the pattern '"..PATTERN.."C' to add color to labels.")
  18.     say(SEPERATOR)
  19.     say("Enter your new label text:")
  20.     local labelText = PATTERN.."f"..io.read() --// resets the default italic
  21.     labelText = string.gsub(labelText,PATTERN,SYMBOL)
  22.     say(SEPERATOR.."\n")
  23.     local renameSuccess = drive.setDiskLabel(labelText)
  24.     assert((renameSuccess ~= true),"Disk cannot be renamed.")
  25.     say("Renamed disk to \""..labelText.."\".\nEnd.\n")
  26.     drive.ejectDisk()
  27.     say(SEPERATOR)
  28. end
  29.  
  30. MAIN()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement