ComputerCraft Archive

EasyMethod - Simple program to list methods of peripherals

computer utility unknown forum

Description

Simple Program to list Methods for Peripheral's

Installation

Copy one of these commands into your ComputerCraft terminal:

Pastebin:pastebin get qGiXZrTc easymethod_-_simple_program_to_list_methods_of_peripherals
wget:wget https://pastebin.com/raw/qGiXZrTc easymethod_-_simple_program_to_list_methods_of_peripherals
Archive:wget https://cc.shobie.xyz/cc/get/pb-qGiXZrTc easymethod_-_simple_program_to_list_methods_of_peripherals
Quick Install: wget https://cc.shobie.xyz/cc/get/pb-qGiXZrTc EasyMethod - Simple program to list methods of peripherals

Usage

Run the program after downloading

Tags

forumapis-and-utilities

Source

View Original Source

Code Preview

--Simple Program to list Methods for Peripheral's


print("Making a file for each peripheral currently available")

 directory ="methods/" --directory where files will be stored
 if fs.isDir(directory) then fs.delete(directory) end
 fs.makeDir(directory)
 
for i,v in pairs(peripheral.getNames()) do
 local file = peripheral.getType(v)
 local h = fs.open(file, "w")

 h.writeLine("--PeripheralType:")
 h.writeLine(peripheral.getType(v))
 h.writeLine()
 h.writeLine("--PeripheralName:")
 h.writeLine(v)
 h.writeLine()
 h.writeLine("--Methods:")
 
 local methods = peripheral.getMethods(v)
 table.sort(methods)
 
 for o,b in pairs(methods) do 
  h.writeLine(b)
 end
 
 h.writeLine()
 h.writeLine()
 h.writeLine("---End Of File---")
 h.close()
 fs.move(file,directory..file)
 end