Advertisement
Le_JuiceBOX

[App] diskLabeler.lua

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