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

[OpenPeripheral]Open Peripheral Explorer

Started by CMaster, 10 February 2014 - 11:44 AM
CMaster #1
Posted 10 February 2014 - 12:44 PM
Open Peripheral Explorer
Pastebin: v1PZ0jb3

Open Peripheral is an amazing, amazing mod.
But it can be a little difficult to find out how to use any given peripheral.
[edit]Just realised that there already is a basic "docs" program provided with OP. My tool however is menu driven, and produces output that's a little better formatted. So there is still a space for this.[/edit]
This is a little, basic application to help you figure things out.
When run, it can pull down the details on any connected peripheral (direct or via modem) that comes via open peripheral.
It will show you all the methods, and then you can select a method to view the arguments it uses and an explanation of the method.
It's nothing fancy, but it's a lot quicker and easier than faffing with the LUA interpreter.
Note - any inaccuracies are down to the built-in documentation and not this program - OPE simply uses the information already embedded in Open Peripheral by the dev team for the mod.

Known issues:
  • Lots of arguments, or long descriptions for arguments can overflow the screen (although I've not yet seen this actually happen).
  • Layout isn't the clearest.
Future ideas (although I may never work on this again):
  • Better formatting
  • Advanced computer support
  • Showing what would currently be returned (a bit like Sensorview).
License:

Edited on 10 February 2014 - 11:53 AM
awsmazinggenius #2
Posted 10 February 2014 - 02:30 PM
Why the CC-BY-SA? You should give us a version of the license, and CC licenses aren't recommended for code.
CMaster #3
Posted 10 February 2014 - 02:44 PM
Why the CC-BY-SA? You should give us a version of the license, and CC licenses aren't recommended for code.

Hmm, perhaps should have spotted that - just used CC as they tend to be pretty fair.

Will replace it with something else - probably GPL I guess, or something more hand-wavey.

The spirit should be pretty clear:
Mess around with it all you like, but don't try to claim it's entirely your own work, or control what others can do with it (not that I imagine it would ever be an issue, but best to avoid anybody worrying about default copyright)
Edited on 10 February 2014 - 02:00 PM
apoc123 #4
Posted 10 February 2014 - 06:07 PM
what version of OP is this for because the methods for different machines and mods have changed several times.
theoriginalbit #5
Posted 10 February 2014 - 06:21 PM
what version of OP is this for because the methods for different machines and mods have changed several times.
They've changed ONCE between Minecraft 1.5 and 1.6
Edited on 10 February 2014 - 05:21 PM
Bomb Bloke #6
Posted 10 February 2014 - 07:21 PM
… assuming you don't count additions?
theoriginalbit #7
Posted 10 February 2014 - 07:31 PM
… assuming you don't count additions?
which still isn't method name changes.
awsmazinggenius #8
Posted 10 February 2014 - 08:50 PM
I honestly think you could call peripheral.getNames() to look for known OpenP peripherals (and let the users say they want to specify another peripheral to add to the program if needed) and then use peripheral.getMethods().
CMaster #9
Posted 11 February 2014 - 03:00 AM
what version of OP is this for because the methods for different machines and mods have changed several times.
The 1.6.x version. (and hopefully onwards)
As it pulls information straight from the mod, the methods information should be accurate for whatever version you are using. (It's possible there are inaccuracies in the documentation. I'm not aware of any however)

I honestly think you could call peripheral.getNames() to look for known OpenP peripherals (and let the users say they want to specify another peripheral to add to the program if needed) and then use peripheral.getMethods().

It's already using peripheral.getNames() to generate that first menu.
If you mean that is should only offer OpenP peripherals on that menu in the first place, then you're very right. Will make the change soon (and there's a neater way of doing it than what you suggest). Annoyingly means I have to reuse a little less code from commonFunctions though.
Edited on 11 February 2014 - 02:01 AM
Magik6k #10
Posted 11 February 2014 - 08:30 AM
well, you probably missed my program: http://www.computerc...al-api-browser/ . CC Should really have some clear software catalog..
apoc123 #11
Posted 12 February 2014 - 06:48 PM
geese didn't mean to start an issue was just asking i found a small program that lists all methods to any machine in a file so for us noobs, its easy to learn and read methods and argument explanations format whatever. Not all of us have gone to school for lua or even have the ambition to learn (lazy) i didn't mean anything by stating there were changes but its confusing enough for us who are lua noobs to figure out how to code i have to learn how to read/ make a list of methods from a file on the cc directory which only gives a table. but yes i found a short cut with someone else s program that puts documentation in a lei-mans file thx no offense intended to the originalbit thx for your hard work changes are inevitable. lol i wouldnt even play minecraft if changes were an issue….


and to magik6k your program is good but im to lazy lol i found this one that list methods and explains argument format and puts it into a file or gives the option to upload to pastebin

connect any block to a computer run program if it can detect it it will ask you if you want a file and want to upload it to paste
then edit the peripheral file to read the instruction book works awesome its a major time saver. this is not my program or code i make no claims and it is publicly available :)/>

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


http://pastebin.com/NmU8Wwkj


–Does not work for newest version of openperipherals–
Edited on 23 February 2014 - 10:50 AM
theoriginalbit #12
Posted 12 February 2014 - 07:09 PM
CC Should really have some clear software catalog..
why? what is wrong with multiple people making the same (or similar) programs? it inspires more creative and competitive programming; since if you want people to use your one you have to make it better (or more 'stand-out') than the others, which when you do, they'll want to do the same to theirs, etc etc etc.
Magik6k #13
Posted 13 February 2014 - 08:47 AM
Nothing. But imho, the forum is not best place for publishing programs. The worst thing about forum is that, 'big' programs(I mean things like luaide/npaintpro) are 'lost' in shadow of programs that in fact are bunch of 'ifs'. For that a software catalog, with nice category tree and some intelligent rank counter would be good. The algorithm would work like 'temperature cache' - new programs are given some 'temperature' so we can see them on first page of some list, then if algorithm see some interest around program, the program is given the temperature and if not the program is cooled. Depending on the temperature the programs are sorted on the list(the higher temp. the higher position on the list)). I could code something like this, but I think it should be something official.
awsmazinggenius #14
Posted 13 February 2014 - 09:01 AM
oeed is making a CC App Store. It's nothing official, though.
ph1x3r #15
Posted 27 February 2014 - 01:20 PM
Thank you CMaster!

I was just digging through the forums trying to figure out how to list methods and came across this post.

The one possible suggestion for improvement would be to allow the user to manually enter in the arguments for a specific method after they view it and then show the result.

For example, getTankInfo() returns a table. This would be better information to be displayed to the user as they are probably looking for the index for the name of the contents and how much is currently stored.

Just a suggestion. The program is very usefull as-is.


Ph1x3r