In game documentation for computercraft peripherals (special open peripheral support)

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
PSA: Computercraft updated recently which is nice. It was a really cool update too with plenty of awesome new toys (and an excellent new Windowing API). That along with the updates to Openperipherals may have broken this program so be warned. I haven't had a chance to test it myself though but if it is broken I will try and fix it soon.

Methodman: In game documentation for CC peripherals


I happen to be a big fan of computercraft and I adore all of the extra goodies that come with its addons, especially open peripherals. The open peripherals website (which seems to be down right now anyway) is mostly out of date and the in game documentation is a myriad of convoluted nested tables. The information is difficult to read on the in game monitors anyway.

So I made this program which uses the fs api to make little reports of all the in game information that I know about for lots of different peripherals. The program will make a file (he files name will be the same as what is returned by peripheral.getType) in the same place it puts ordinary program files. You can also pastebin the reports if you like, or read them by typing edit (whatever the file is called) just like any other program, although the formatting is not good for this.

I have tested it on a variety of different peripherals, including vanilla computer craft stuff like monitors, logistics pipes and the big reactor computer peripheral. There is also a special method in open peripherals that gives extra information about the methods it creates. My program works with that too.

Enough talk, here are a few examples I cooked up

Code:
METHODMAN: Practical display for in game documentation of computercraft + addons

Peripheral found
    Side: right
    Type: container_chest

container_chest method list:

    swapStacks
    pushToComputer
    getInventoryName
    destroyStack
    pushItem
    getAdvancedMethodsData
    getInventorySize
    pushItemIntoSlot
    getStackInSlot
    getAllStacks
    pullFromComputer
    listMethods
    pullItem
    condenseItems
    pullItemIntoSlot

Open Peripherals Advanced Method Data

1. swapStacks

Return Type: BOOLEAN
Description: Swap two slots in the inventory

    Arguments: swapStacks(from, to)

        1. from
        Description: The first slot
        Type: NUMBER
        2. to
        Description: The other slot
        Type: NUMBER

2. pushToComputer

Return Type: BOOLEAN
Description: Push an item from a slot to the computer buffer

    Arguments: pushToComputer(slot, maxAmount)

        1. slot
        Description: The slot in the inventory that you're pushing from
        Type: NUMBER
        2. maxAmount
        Description: Max amount of items to push into the computer
        Type: NUMBER

3. getInventoryName

Return Type: STRING
Description: Get the name of this inventory

    Arguments: getInventoryName()
    No Arguments

4. destroyStack

Return Type: VOID
Description: Destroy a stack

    Arguments: destroyStack(slotNumber)

        1. slotNumber
        Description: The slot number, from 1 to the max amount of slots
        Type: NUMBER

5. pushItem

Return Type: NUMBER
Description: Push an item from the current inventory into any slot on the other one. Returns the amount of items moved

    Arguments: pushItem(direction, slot, maxAmount)

        1. direction
        Description: The direction of the other inventory. (north, south, east, west, up or down)
        Type: STRING
        2. slot
        Description: The slot in the current inventory that you're pushing from
        Type: NUMBER
        3. maxAmount
        Description: The maximum amount of items you want to push
        Type: NUMBER

6. getAdvancedMethodsData

Return Type: TABLE
Description: Get a complete table of information about all available methods

    Arguments: getAdvancedMethodsData()
    No Arguments

7. getInventorySize

Return Type: NUMBER
Description: Get the size of this inventory

    Arguments: getInventorySize()
    No Arguments

8. pushItemIntoSlot

Return Type: NUMBER
Description: Push an item from the current inventory into a specific slot in the other one. Returns the amount of items moved

    Arguments: pushItemIntoSlot(direction, slot, intoSlotmaxAmount, )

        1. direction
        Description: The direction of the other inventory. (north, south, east, west, up or down)
        Type: STRING
        2. slot
        Description: The slot in the current inventory that you're pushing from
        Type: NUMBER
        4. intoSlot
        Description: The slot in the other inventory that you want to push into
        Type: NUMBER
        3. maxAmount
        Description: The maximum amount of items you want to push
        Type: NUMBER

9. getStackInSlot

Return Type: TABLE
Description: Get details of an item in a particular slot

    Arguments: getStackInSlot(slotNumber)

        1. slotNumber
        Description: The slot number, from 1 to the max amount of slots
        Type: NUMBER

10. getAllStacks

Return Type: TABLE
Description: Get a table with all the items of the chest

    Arguments: getAllStacks()
    No Arguments

11. pullFromComputer

Return Type: BOOLEAN
Description: Pull an item from the computer buffer to a slot

    Arguments: pullFromComputer(slot)

        1. slot
        Description: The slot in the inventory that you're pulling to
        Type: NUMBER

12. listMethods

Return Type: STRING
Description: List all the methods available

    Arguments: listMethods()
    No Arguments

13. pullItem

Return Type: NUMBER
Description: Pull an item from the target inventory into any slot in the current one. Returns the amount of items moved

    Arguments: pullItem(direction, slot, maxAmount)

        1. direction
        Description: The direction of the other inventory. (north, south, east, west, up or down)
        Type: STRING
        2. slot
        Description: The slot in the other inventory that you're pulling from
        Type: NUMBER
        3. maxAmount
        Description: The maximum amount of items you want to pull
        Type: NUMBER

14. condenseItems

Return Type: VOID
Description: Condense and tidy the stacks in an inventory

    Arguments: condenseItems()
    No Arguments

15. pullItemIntoSlot

Return Type: NUMBER
Description: Pull an item from a slot in another inventory into a specific slot in this one. Returns the amount of items moved

    Arguments: pullItemIntoSlot(direction, slot, intoSlotmaxAmount, )

        1. direction
        Description: The direction of the other inventory. (north, south, east, west, up or down)
        Type: STRING
        2. slot
        Description: The slot in the OTHER inventory that you're pulling from
        Type: NUMBER
        4. intoSlot
        Description: The slot in the current inventory that you want to pull into
        Type: NUMBER
        3. maxAmount
        Description: The maximum amount of items you want to pull
        Type: NUMBER


--------------------

All actual documentation is written by the mod developer who made the peripheral, not me. I just displayed it - happy computercrafting

ME Controller - http://pastebin.com/Dub0aMsH
Buildcraft Tank - http://pastebin.com/wUMZWbUX

You can download the program here:
New version - http://pastebin.com/tZbCWSBe
Old version - http://pastebin.com/NmU8Wwkj

Recent changes to the way open peripherals organised there ingame documentation forced me to make a larger than normal update. Normally I would have just modified the old program and used the same link but the changes were big enough that I was worried I might break compatibility for older versions of open peripherals so I left the old link unchanged and made a completely new one for methodman 2.0. The old version will no longer be updated, while the new one will continue to get new features (as appropriate) and bug fixes.

If anyone finds any problems with this program, or if there is another wealth if ingame documentation that I can add support for, please let me know.

I just want to clarify that I didn't write any of the documentation my self, I just arranged it.

P.S. While looking through what I am posting, I have noticed a bug where the arguments are being displayed in the wrong order sometimes. Each argument comes with a number though so it should hopefully be obvious what the correct order is. I will work on a fix.

EDIT: I think I fixed this bug I found faster than the time it took for a single person to look at this thread, not bad for first thing after a terrible night's sleep.

Anyway, for methods that had at least 4 arguments the arguments were getting their order mixed up. I was under the impression that when you loop through a table with numeric keys it would do so numerically. Maybe my computer just can't count. Well, I replaced the generic for loops with numeric for loops so hopefully there won't be any major issues. I updated the pastebin.
 
Last edited:

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
When I finally was able to get some sleep, I settled down and realised I gave no instructions about how to use the program. Dope.

Fortunately, it is really simple. Just get the program onto a computer and put the peripheral you are interested next to the computer(it should also work for peripherals connected via wired modem but I haven't tested that myself). It detects all peripherals that it is connected to so you don't need to mess about with telling the program what side anything is on. You can do more than one peripheral at once as well.
 

kaovalin

New Member
Jul 29, 2019
782
0
0
I've been wanting to get into CC for a while. I will definitely need this when I get started.
 

EliRyurei

New Member
Jul 29, 2019
5
0
0
I ran into a problem, the problem occurred every time after testing things like the mass fabricator, energy cells, and a vanilla chest:

line 12: attempt to concatenate string and nil

Edit: i should probably also mention i'm using the FTB monster pack v1.0.5, with all mods enabled
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
I ran into a problem, the problem occurred every time after testing things like the mass fabricator, energy cells, and a vanilla chest:

line 12: attempt to concatenate string and nil

Edit: i should probably also mention i'm using the FTB monster pack v1.0.5, with all mods enabled

I have checked the version numbers of open peripherals between Monster and Resonant Rise and monster uses 0.2.1 s114 while I am on 0.2.1 s112.

I have just downloaded a fresh copy of my program onto a computer and tested it with the blocks you mentioned and it worked fine. What I suspect has happened is that the name of the key that I need to reference a specific part of a table has been changed between s112 and s114 which is a bit odd. According to your report the problem key is the returnType key. Try commenting out line 12 by putting a double hyphen at the beginning of that line. The rest of the program might work. When I get a chance I will test the program myself on s114 and see if I can work out what the problem is and provide a real fix.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
The method list should be written in new file. Type dir into your computer and you should see a file called mfe. The method list is in there. You can pastebin this list or find it in your save file directory if you have access to that, so it is easier to read.
 
  • Like
Reactions: Pyure

jokermatt999

New Member
Jul 29, 2019
250
0
0
This is exactly what I've been wanting to help me get into ComputerCraft. This, combined with dan200's recent reveal of Pocket Computers (built in modems! run in your inventory! :eek:), have definitely made me decide to jump into it. Thanks!
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
UPDATE:

@EliRyurei

I have addressed the bug you told me about. My guess as to what was causing it turned out to be correct. In the version of open peripherals used in monster the returnType key had its name changed to returnTypes to reflect that fact that a method can return more than one variable. The value in the key is now a table as well so it can store multiple values. I have modified the program to account for this and it should work almost exactly as it did before for anyone using the program on s112 and it should work as intended on s114 as well. I also added a bit of information that appears at the beginning of the program to make it clear where the new reports will be stored.

You can redownload the program using the same pastebin link found below. The link in the OP works as well.

http://pastebin.com/NmU8Wwkj
 

VikeStep

New Member
Jul 29, 2019
1,117
0
0
So i wrote something like this for it over a month ago, but it pastebins the result instead and it only works if the peripheral is on the left, but it is easily alterable

here is the code: http://pastebin.com/623WbaWC
here is an example for the terminal glasses: http://pastebin.com/b4Fux1PY

I did rewrite the code to save it to a file, have a chosen side and some error handling about 2 weeks later though and pushed it to be a default feature in openperipherals, but it was rejected.

here is that code: http://pastebin.com/vT0i6Abz
and it is the same output as the previous one.

I must say though, that yours is much better than mine haha.
 
  • Like
Reactions: casilleroatr

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
So i wrote something like this for it over a month ago, but it pastebins the result instead and it only works if the peripheral is on the left, but it is easily alterable

here is the code: http://pastebin.com/623WbaWC
here is an example for the terminal glasses: http://pastebin.com/b4Fux1PY

I did rewrite the code to save it to a file, have a chosen side and some error handling about 2 weeks later though and pushed it to be a default feature in openperipherals, but it was rejected.

here is that code: http://pastebin.com/vT0i6Abz
and it is the same output as the previous one.

I must say though, that yours is much better than mine haha.
I just had a look through your code and I liked the bit at the end where you say where the file was saved. I should implement something similar.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Been getting into Logistics pipes again and worked on updating this program to display the extra logistics pipes documentation that the LP devs kindly put in the mod. I also added a couple of extra features.

1: Added a simple yes or no question function so that you can influence the program a bit while it is running
2: Added table of all new files generated so you can easily see what new files where made
3: Added option to automatically upload all new files to pastebin@
4: Added option to abort the program if you decide you don't want it to make all the files after you have run it - it will also time itself out if you don't give an answer, closing the program
5: If the a filename for a peripheral already exists, you get the option to overwrite the original file or make a new filename. It will be the original filename with a number appended to it.
6: Added Logistics pipes support*

*I can't guarantee that this will work in every version of Logistics pipes. If it does work then it will use the logistics pipes help command to give some extra details about the pipe's functions. Information is provided in a long string so I didn't format it myself. If anyone finds that the logistics pipes bit doesn't work then I will be happy to look into it. Do note however that not every logistics pipe is a peripheral. Also if there are any other mods out there that add extra help methods to any peripherals they add, I would love to hear about them so I might be able to add support for them too.

@I am using shell.run to use the native pastebin program to upload files. I don't like doing this and I hope one day to be able to access pastebin using the HTTP api directly. When I tried doing this before (a long time ago now) it didn't go so well but I am more experienced now so I might be able to get it to work. I will be able to present the pastebin codes better then.

I am still using the same pastebin code that you can find in the OP

I will put it here as well.

http://pastebin.com/NmU8Wwkj
 
  • Like
Reactions: jokermatt999

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
I have just done another tiny update to fix a small issue I found.
Wired modems and Wireless modems have the same name according to peripheral.getType so I added a check to see if the the modem is wireless or not so I can name the report file accordingly. This is important because it removes any chance of overwriting a report for a wireless modem with a report for a wired modem or vice versa.

As always, you can use the same pastebin code (NmU8Wwkj) to get the updated version of the program as of this post.
 

tedyhere

New Member
Jul 29, 2019
1,286
0
0
Excellent. I am going to grab this now as I am wanting to do alot of CC automation in my base
 

Arkandos

New Member
Jul 29, 2019
349
0
0
The newer versions of open peripheral contains a built-in documentation program as the devs thought it was too much work to update the wiki.
Although, that lp support sounds really nifty
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
The LP support isn't much and it doesn't go into anything like the detail that the open peripherals one does. Do you know how the program that the open peripheral guys have put in works? Only so I can decide whether its worth maintaining this little project or not.
 

Arkandos

New Member
Jul 29, 2019
349
0
0
The built-in OpenPeripheral documentation program (openp/docs) displays all available functions for the peripheral on the specified side, along with any parameters that function needs.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Thanks for the reply. I have tried to find the program on the latest versions of Monster and Resonant Rise exp but no luck. Do you know where to find a changelog for open peripherals? There main website just has download links now.

Besides, from your initial description it seems like there are enough features differentiating my program so if I ever have anything else to add I think I will.
 

Arkandos

New Member
Jul 29, 2019
349
0
0
You must have an openperipheral next to the computer to access the program. Try placing a chest next to it.