This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Elrond1369's profile picture

Peripheral methods program (PMp) now works with cables

Started by Elrond1369, 28 June 2012 - 01:40 PM
Elrond1369 #1
Posted 28 June 2012 - 03:40 PM
Peripheral methods program lets you easily getMethods right from the command line. It also will get the names of networked peripherals as well as their methods. You can copy and paste this code or download it using my in game Package Downloader.
methods:
Spoiler

tArgs = { ... }
side = tArgs[1]
prop = tArgs[2]
if tArgs[1]==nil then
print("Help for methods")
print("'methods <side>' get methods for peripheral")
print("'methods <side> names' get names of networked perpherals")
print("'methods <side> <peripheral name>' get methods for networked peripheral")
return
end
if side~="top" and side~="bottom" and side~="left" and side~="right" and side~="front" and side~="back" then
print("Invalid side. Valid sides are: top, bottom, right, left, front and back")
return
end
if  peripheral.getType(side)==nil then
print("No peripheral on "..side.." side")
return
end
if prop==nil then
print("Methods for "..peripheral.getType(side))
for i, p in pairs(peripheral.getMethods(side)) do
print(p.."()")
end
return
end
if peripheral.getType(side)~="modem" then
print("Peripheral "..side.." is not a modem")
return
end
if prop=="names" then
print("Peripherals on "..side.." modem:")
local modem = peripheral.wrap(side)
for i,p in pairs(modem.getNamesRemote()) do
print(p)
end
return
end
local modem = peripheral.wrap(side)
for i, p in pairs(modem.getMethodsRemote(prop)) do
print(p.."()")
end
eddieo #2
Posted 30 June 2012 - 03:05 PM
Very nice Thanks much
Wolvan #3
Posted 01 July 2012 - 03:14 PM
good work