soulgriever

EasyMethod - Simple program to list methods of peripherals

Nov 15th, 2018
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. --Simple Program to list Methods for Peripheral's
  2.  
  3.  
  4. print("Making a file for each peripheral currently available")
  5.  
  6.  directory ="methods/" --directory where files will be stored
  7.  if fs.isDir(directory) then fs.delete(directory) end
  8.  fs.makeDir(directory)
  9.  
  10. for i,v in pairs(peripheral.getNames()) do
  11.  local file = peripheral.getType(v)
  12.  local h = fs.open(file, "w")
  13.  
  14.  h.writeLine("--PeripheralType:")
  15.  h.writeLine(peripheral.getType(v))
  16.  h.writeLine()
  17.  h.writeLine("--PeripheralName:")
  18.  h.writeLine(v)
  19.  h.writeLine()
  20.  h.writeLine("--Methods:")
  21.  
  22.  local methods = peripheral.getMethods(v)
  23.  table.sort(methods)
  24.  
  25.  for o,b in pairs(methods) do
  26.   h.writeLine(b)
  27.  end
  28.  
  29.  h.writeLine()
  30.  h.writeLine()
  31.  h.writeLine("---End Of File---")
  32.  h.close()
  33.  fs.move(file,directory..file)
  34.  end
Add Comment
Please, Sign In to add comment