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

Peripheral API browser

Started by Magik6k, 02 February 2014 - 08:35 PM
Magik6k #1
Posted 02 February 2014 - 09:35 PM
Today I was creating something based on OpenPeripheral, and I could not reach documentation of it, so I looked at 'getAdvancedMethodsData' function. After few minuets I have created small program that makes the data readable.

Install:

Pastebin way:

pastebin get yDLNKM1g perihelp

CCPT way:

ccpt ppa add sysx
ccpt install perihelp

Usage:


perihelp [side]
ex. 'perihelp right'

Navigating:

Up, Down arrow - move up/down one line
Left,Right arrow - move up/down one 'page'
mouse scroll - also move
'q' - quit

Screenies:





Enjoy!
surferpup #2
Posted 02 February 2014 - 09:39 PM
This looks pretty cool. If I understand correctly – it only works with peripherals that have implemented getAdvancedMethods() – yes?
ingie #3
Posted 02 February 2014 - 10:43 PM
nice work

further to this and the OpenPeripheral's thread discussion on the same, I was looking at this: http://regex.info/blog/lua/json

using that, i've tested its use on the getAdvancedMethodsData call - my current hacking of this is simply

local JSON = (loadfile "disk/JSON.lua")()  -- replace this with wherever you save the above linked JSON.lua utility

local chest = peripheral.wrap("left")

local ed = chest.getAdvancedMethodsData()

local myTableJSON = JSON:encode_pretty(ed)

print(myTableJSON)

which seems to do the job nicely…

my thoughts on this are that this JSON data is simple to pass via a HTTP request to some javascript to auto-generate a webpage as suggested in the OpenPeripherals thread by NeverCast.

all that is needed to be done now is write the javascript decoding at the other end to make it readable - which should be trivial in JQuery - and an advanced function would be for the page to cache already defined methods, but it'd need to make some checksum etc - probably pass the CC version or something too…



i also found this on the FTB forums

http://forum.feed-th...-support.39460/

which dumps the method docs to a file for later reading… which is a nice idea
Edited on 02 February 2014 - 09:44 PM