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

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
I used my method program to help me a bit while I was writing a new program but discovered a new bug. It has happened because the open mods team have re-done the table structure of the getAdvancedMethods return again.

Last time this happened it was really easy to make the same function work for new and older versions of open peripherals and I just updated the same pastebin link. This time though the changes are too great and changing the existing function while maintaining backwards compatibility is getting tricky (especially since I don't know when these changes to open peripherals were made). I am currently modifying the program in a way that should work with current versions and might work with older versions, but I am focusing on new versions now. I will make a new pastebin link for the update so people using older versions of the mod will still have access to the program that definitely works. However, along with updating the program to work with new versions of open peripherals I am also adding a couple of convenience features. More details and a finished product coming later today
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
The fix was a lot easier than I anticipated and I am confident that the program will work as intended for old versions and new versions of open peripherals. I am still going to link a new pastebin though just in case. I have taken the opportunity to clean up the code a bit and add in some extra features to make the program better. Here is a changelog:
  1. Added support for new table structure for openperipherals getAdvancedMethodsData
  2. Cleaned up some of the text feedback that you see on the monitor
  3. Added function to prevent the deletion or automatic overwriting of files that aren't recognised as reports*. If you had a program called tank and there was also a peripheral called tank then this program might accidently delete it before. When presented with this conflict now, the program will read the file and check that it is a report. It does this by comparing the first line with the expected title. This should ensure that you never accidently delete another program with this program.
  4. Resolved bug where if the you had several of the same type of peripheral attached at the same time, it would think that, even if you overwrote the files it had created a new file for each one. As a result if you activated the pastebin it would pastebin the same file multiple times. Now this program will only pastebin files once.
  5. Added support for some arguments to allow the user to change the programs behaviour.
  6. Added help section. Run the program with the argument "help" to access this.
  7. Added delete argument. Run the program with the argument "delete" to force this. There is an optional safe mode which you can run by passing the word "safe" as the second argument. Delete mode searches the directory and if it finds a report it will delete it. If you run it in safe mode it will ask you if you want to delete the reports one by one. It uses the same checker function that I described above so it won't accidently delete any programs.
  8. Added two normal running modes, pastebinEnabled and fastMode. Both are disabled by default. The program will no longer automatically pastebin your reports. You can enable both of these modes directly by editing the program. The pertinent variables are near the top of the program and have obvious comments. You can also enable them temporarily by using arguments. You can put these arguments in any order, and you can put one, both or none of them.
  9. "pastebin". This argument enables pastebin mode which makes the program run just like it used to. You will be given the option to pastebin all your new reports at the end.
  10. "fast". This argument enables fast mode. This basically skips over the bulk of the yes or no questions in the program meaning that you can just run it. In this mode the program will always overwrite a file of the same name as a peripheral unless if it is not a report. It will still generate a new file name if the existing file is not a report.
*Reports are defined as any file with the following string on its first line.
"METHODMAN: Practical display for in game documentation of computercraft + addons"

You can get the new and improved methodman through this pastebin link: http://pastebin.com/tZbCWSBe or type in pastebin get tZbCWSBe <filename> into a computer.
 

MTF_Adam

New Member
Jul 29, 2019
14
0
0
Forgive my stupidity. How do I get the code into the Computer? Copy and Paste doesn't work.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Forgive my stupidity. How do I get the code into the Computer? Copy and Paste doesn't work.
There are two methods that you can use. The most straightforward one is to use the pastebin program that is built into computercraft. To do this you must type into the computer the following

pastebin get <pastebin code> <file name>

The pastebin code is the unique code that you see on the end of the url I linked to. You just need the code and not the whole url. The filename tells the pastebin program the name of the file you want to save the download to. So to get the latest version of my program you would type this

pastebin get tZbCWSBe methods

and you will get my program saved in a file called methods. You can copy and paste that single line into the computer (copy and paste only works for single lines in computercraft).

The alternative method is only doable if you have access to the save file for your game. Go to the computer you want to install the program on and make a new program and immediately save and exit. Make a not of the id of the computer. To find out the id just type id into the computer. At this point, you might want to close minecraft completely and backup your save. The process I am about to describe is straightforward but I don't want you to ruin your world by accident.

Find the folder where your instance is installed and open the saves folder. Then open the world folder and there should be a folder called computer. Open that folder and there will be a folder for every computer that has a saved program on it. These folders will be named for the id of the computer they represent. The path will look something like this.

FTB\Monster\minecraft\saves\FTB Monster Test\computer\0 (Guide purposes only)

Find the right folder and inside you should find your empty program. Open it using a text editor. I like to use Notepad++ but notepad should be fine. You can copy and paste the entire program into the text editor and save the file. Close the folder and when you go back into minecraft the program will be there where you put it. You don't have to close minecraft when you edit the files in the computercraft save section, but it might be wise to until you are comfortable navigating the directory. As a bit of extra advice, writing programs this way is much easier than using the in game editor. Obviously for your own programs you wouldn't be copying and pasting it all but the rest of its the same. Make the file in game and write it out using a real text editor.

By the way, if you are using the latest version of the program, I will be interested to hear what you think of the changes I made lately, thanks.
 

MTF_Adam

New Member
Jul 29, 2019
14
0
0
Thanks, that worked great. However for my RedstoneEnergyCell is only lists 3 functions (besides listMethods) and they're all getMethods and it doesn't look like there is any setMethods, like there used to be. Is this intentional by the mod, I can on longer set the I/O of the cell, only read it?

How do I use the functions too? I used to know this, now it's changed it feels so different.

I inserted
Lua
Reactor = peripheral.wrap('right')
Reactor.getHeat()

this gives me an error, attempt to call nil. How would I go about doing it?

Aren't there any tutorials for the new version of OpenPeripherals?
 
Last edited:

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Glad its working for you. I have used this program to find redstone energy cell methods and your findings are consistent with my own. The only methods available for redstone energy cells (excluding listMethods etc) are the getEnergyLevel one and the getMaxEnergyLevel (perhaps with different names). That is just the way it is I'm afraid and its not a problem with my program. This may change in the future, but with the changes to Thermal Expansion lately, it is no surprise that the the openperipherals support had to be rebuilt.

Have you tried out any of the new features that were outlined in this post

The fix was a lot easier than I anticipated and I am confident that the program will work as intended for old versions and new versions of open peripherals. I am still going to link a new pastebin though just in case. I have taken the opportunity to clean up the code a bit and add in some extra features to make the program better. Here is a changelog:
  1. Added support for new table structure for openperipherals getAdvancedMethodsData
  2. Cleaned up some of the text feedback that you see on the monitor
  3. Added function to prevent the deletion or automatic overwriting of files that aren't recognised as reports*. If you had a program called tank and there was also a peripheral called tank then this program might accidently delete it before. When presented with this conflict now, the program will read the file and check that it is a report. It does this by comparing the first line with the expected title. This should ensure that you never accidently delete another program with this program.
  4. Resolved bug where if the you had several of the same type of peripheral attached at the same time, it would think that, even if you overwrote the files it had created a new file for each one. As a result if you activated the pastebin it would pastebin the same file multiple times. Now this program will only pastebin files once.
  5. Added support for some arguments to allow the user to change the programs behaviour.
  6. Added help section. Run the program with the argument "help" to access this.
  7. Added delete argument. Run the program with the argument "delete" to force this. There is an optional safe mode which you can run by passing the word "safe" as the second argument. Delete mode searches the directory and if it finds a report it will delete it. If you run it in safe mode it will ask you if you want to delete the reports one by one. It uses the same checker function that I described above so it won't accidently delete any programs.
  8. Added two normal running modes, pastebinEnabled and fastMode. Both are disabled by default. The program will no longer automatically pastebin your reports. You can enable both of these modes directly by editing the program. The pertinent variables are near the top of the program and have obvious comments. You can also enable them temporarily by using arguments. You can put these arguments in any order, and you can put one, both or none of them.
  9. "pastebin". This argument enables pastebin mode which makes the program run just like it used to. You will be given the option to pastebin all your new reports at the end.
  10. "fast". This argument enables fast mode. This basically skips over the bulk of the yes or no questions in the program meaning that you can just run it. In this mode the program will always overwrite a file of the same name as a peripheral unless if it is not a report. It will still generate a new file name if the existing file is not a report.
Sorry to ask you, but I would really appreciate some feedback if you are willing to test it.
 

MTF_Adam

New Member
Jul 29, 2019
14
0
0
Number 2 didn't seem so bad, the text was easily readable and clear.
I tried out number 3, that seems to work fine. It gave me the option to overwrite the file, and when I didn't it created a new one with the number 2 after it. e.g. cofh_thermalexpansion_energycell_2 instead of cofh_thermalexpansion_energycell
Number 6 went fine, nice explanation.
Number 7 worked fine. Asked me if I wanted to delete each file separately with delete safe, deleted them all automatically with delete
Number 8 was pointed out in the help file, I went in and the options to disable /enable them were clear

I don't think I'm that clever or experienced to try the other ones. Hope I helped

However I still need to ask the question. How would I call the methods I find from the listMethods() ? the one I used in previous versions is giving me the error
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Thanks for the feedback I appreciate it.

If you tell me what error you are getting and if you show me the erroring code I will look into it.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
That sounds like the function you are trying to call is a nil value. If the function exists and your spelling is correct you shouldn't have this problem based on what you wrote up there.

What is the reactor supposed to be by the way?
 

MTF_Adam

New Member
Jul 29, 2019
14
0
0
It's still throwing me that error, I was using modems so I could try without them? (Using Wired not Wireless ones). It's a Nuclear Reactor from IC2 btw
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
In that case the peripheral hasn't been wrapped properly. I didn't know this before because I didn't know that you connected via modem.

When you place the wired modem on a peripheral of any type you can right click the modem to connect it. You should get a chat message saying something like this ""reactor_ic2_1" connected". The reactor_ic2_1 string stands in for the side when you wrap peripherals by modem. Its a bit misleading I know, when in the computercraft wiki it says that you provide the side that the peripheral is on as the parameter for peripheral.wrap. I think that was written before wired modems were a thing.

Think of instead as if you are providing the location of the peripheral. If the peripheral is directly adjacent then you still provide the side as normal. If it is connected via modem you pass the string that you get in the chat message that provides the name of the peripheral with a unique number appended to make sure it is the right one. My method program does exactly the same thing.

Your code should do something like this
Code:
local reactor = peripheral.wrap("reactor_ic2_1")
Obviously you will need to check exactly what the name of the peripheral is (make sure the reactor is still connected after you leave it, shown by a red ring on the modem).
 

colonelhomer815

New Member
Jul 29, 2019
20
0
0
does anyone have any tips on how to use the AE methods in OP, particularly insertItem, extractItem and getAvailableItems, I've tried using openp/docs but it hasn't really helped. I don't really get lua tables.
 

colonelhomer815

New Member
Jul 29, 2019
20
0
0
I've looked at the pastebin. it's not really what I need. It's the table representing representing item stack I don't get.
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
What is your problem with Lua tables? I might not answer you here but I had a project to do with common computercraft goals a couple of months ago that I abandoned due to time constraints but I hope to pick up again. Lua tables are easy when you get over the initial learning curve and I hope to elucidate on them with that project.
 

colonelhomer815

New Member
Jul 29, 2019
20
0
0
Firstly I am not sure how to read the tables, and secondly I am not sure what data is being stored in the table representing itemstack.