daily pastebin goal
38%
SHARE
TWEET

disk.lua

a guest Mar 18th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. local function isDrive( name )
  3.     if type( name ) ~= "string" then
  4.         error( "bad argument #1 (expected string, got " .. type( name ) .. ")", 3 )
  5.     end
  6.     return peripheral.getType( name ) == "drive"
  7. end
  8.  
  9. function isPresent( name )
  10.     if isDrive( name ) then
  11.         return peripheral.call( name, "isDiskPresent" )
  12.     end
  13.     return false
  14. end
  15.  
  16. function getLabel( name )
  17.     if isDrive( name ) then
  18.         return peripheral.call( name, "getDiskLabel" )
  19.     end
  20.     return nil
  21. end
  22.  
  23. function setLabel( name, label )
  24.     if isDrive( name ) then
  25.         peripheral.call( name, "setDiskLabel", label )
  26.     end
  27. end
  28.  
  29. function hasData( name )
  30.     if isDrive( name ) then
  31.         return peripheral.call( name, "hasData" )
  32.     end
  33.     return false
  34. end
  35.  
  36. function getMountPath( name )
  37.     if isDrive( name ) then
  38.         return peripheral.call( name, "getMountPath" )
  39.     end
  40.     return nil
  41. end
  42.  
  43. function hasAudio( name )
  44.     if isDrive( name ) then
  45.         return peripheral.call( name, "hasAudio" )
  46.     end
  47.     return false
  48. end
  49.  
  50. function getAudioTitle( name )
  51.     if isDrive( name ) then
  52.         return peripheral.call( name, "getAudioTitle" )
  53.     end
  54.     return nil
  55. end
  56.  
  57. function playAudio( name )
  58.     if isDrive( name ) then
  59.         peripheral.call( name, "playAudio" )
  60.     end
  61. end
  62.  
  63. function stopAudio( name )
  64.     if not name then
  65.         for n,sName in ipairs( peripheral.getNames() ) do
  66.             stopAudio( sName )
  67.         end
  68.     else
  69.         if isDrive( name ) then
  70.             peripheral.call( name, "stopAudio" )
  71.         end
  72.     end
  73. end
  74.  
  75. function eject( name )
  76.     if isDrive( name ) then
  77.         peripheral.call( name, "ejectDisk" )
  78.     end
  79. end
  80.  
  81. function getID( name )
  82.     if isDrive( name ) then
  83.         return peripheral.call( name, "getDiskID" )
  84.     end
  85.     return nil
  86. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top