Advertisement
TheOddByte

[ComputerCraft][Program] F0RMATTER

Feb 8th, 2014
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. --[[
  2.     [Program] F0RMATTER
  3.     @version 1.0, "Deleting.."
  4.     @author Hellkid98, HK98
  5. --]]
  6.  
  7. local function centerPrint( y, text )
  8.     local w, h = term.getSize()
  9.     term.setCursorPos( w/2 - #text/2, y )
  10.     write( text )
  11.     print("")
  12. end
  13.  
  14. local input
  15. repeat
  16.     term.clear()
  17.     term.setCursorPos( 1, 1 )
  18.     term.setTextColor( colors.lime )
  19.     centerPrint( 1, #fs.list("/") .. " files  |  Free Space  " .. fs.getFreeSpace("/") .. " Kb\n" )
  20.     term.setTextColor( colors.green )
  21.     write("Format? (y/n): ")
  22.     input = string.lower(read())
  23. until input:sub( 1,1 ) == "y" or input:sub( 1,1 ) == "n" or input:find( "yes" ) or input:find( "no" )
  24. if input:sub(1,1) == "y" or input:find( "yes" ) then
  25.     for _, f in ipairs( fs.list("") ) do
  26.         if not fs.isReadOnly( f ) and f ~= "disk" then
  27.             term.setTextColor( colors.lime )
  28.             print("Deleting [" .. f .. "]" )
  29.             fs.delete( f )
  30.         else
  31.             term.setTextColor( colors.green )
  32.             print("Ignored [" .. f .. "]" )
  33.         end
  34.     end
  35.     term.setTextColor( colors.yellow )
  36.     print("\nFormatting done! Press any key to continue" )
  37.     os.pullEvent( "key" )
  38. end
  39. term.clear()
  40. term.setCursorPos( 1,1 )
  41. term.setTextColor( colors.white )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement