[TE] Energy Cell read/displayed?

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Lewis Evelyn

New Member
Jul 29, 2019
25
0
0
I was wondering if anyone had a clever way to display the amount of energy stored inside of a TE energy cell?

Similar to the way Nuclear Control does with a MFE?

I assume you would use misc-peripherals and a CC Monitor?

Any tips/instructions how I would go about this?

~lce123
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
There is only one way I know how for sure - using open peripherals. The method names are different in different versions because lately the support was redone but you can always do the peripheral.getMethods command to get a table of up to date methods. In the latest versions, I have noticed a few people (inlcuding myself) get stuck with some of the methods because they require an argument. Without delving into the ingame documentation which can be a bit difficult to navigate, it is difficult to know what this argument is meant to be, so save yourself the trouble and just put "unknown" as the only argument in methods that don't seem to work properly and you might get lucky.

I made a barchart using information derived from the methods in openperipherals and a monitor. I was pretty happy with it.
 

Lewis Evelyn

New Member
Jul 29, 2019
25
0
0
There is only one way I know how for sure - using open peripherals. The method names are different in different versions because lately the support was redone but you can always do the peripheral.getMethods command to get a table of up to date methods. In the latest versions, I have noticed a few people (inlcuding myself) get stuck with some of the methods because they require an argument. Without delving into the ingame documentation which can be a bit difficult to navigate, it is difficult to know what this argument is meant to be, so save yourself the trouble and just put "unknown" as the only argument in methods that don't seem to work properly and you might get lucky.

I made a barchart using information derived from the methods in openperipherals and a monitor. I was pretty happy with it.


Thanks for the reply but everything you said went completely over my head >< guess I have some learning to do :p
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Sorry about that - I didn't explain anything because I didn't know how much you know, but it is not too hard anyway.

My advice is go into a creative world in with open peripherals (I am pretty sure it is on the new FTB packs like Direwolf20 and monster). Get a computer, an REC and if you want to, a monitor as well.
Open peripherals basically makes a huge amount of blocks (both vanilla and modded) computer craft peripherals and depending on the type of block, different methods become available. If you place the cell next to the computer you can wrap it as a peripheral using the peripheral api that comes with vanilla computercraft just like any other peripheral (e.g a monitor). (Peripheral API documentation here: http://computercraft.info/wiki/Peripheral_(API))

Once wrapped you can program your computer to obtain information about the cell, including max energy storage, current energy storage, energy storage remaining etc. You can get a table of the names of all methods by doing using the peripheral.getMethods(side) command where side is the side of the computer that the cell is on. It returns a table which you can iterate through to print out each method name. I am only suggesting you do this because I don't remember all of them. When you have done this select the method that sounds appropriate and use it. There is a good chance that if you are querying the RF data of the cell you will need an argument or parameter. Just put "unknown" in the brackets and it should work - like this local energy = getEnergyStored("unknown"). That is not necessarily a real method btw it is just an example.
 

Lewis Evelyn

New Member
Jul 29, 2019
25
0
0
Right I'm a little confused (I havent done much with computer craft) when i do the wrap it returns 'table: 83hnd93' or whatever and same with the getMethods.

Let me explain what I want to achieve, so my control room where my ME is, is pretty far away from where my energy is stored, so I want to getEnergyStored then get the computer to send it to a monitor in the control room so I know when the power is running low, I also plan to do this with a harvester (to see if its running) and a few other things and then hopefully gather all the information and display it all on one big monitor, is this possible?

I assume it is just how hard is it to do :p
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
I don't know about the harvester (depending on exactly what you want to do) but the stuff with the energy cell is definitely possible.

Getting the information is moderately easy especially if you know how tables work. Depending on how fancy you want the monitor display to be, and how many different things you want to display, making a monitor display goes from easy to hard. If all you want to do is display energy storage as a percentage or something like that then it is easy.

I don't have time to go into it in too much detail but tables and iterating through tables seems to be where most people stumble when they are new to computer craft (I am thinking of starting a thread to help generally with this sort of thing).

Tables are like supervariables which contain any number of subvariables. A table is a normal variable of type "table" (all variables have types, i.e the name of a class of variable - in Lua these include "number", "string", "boolean", "function", and "table"). The values stored within a table can be of different types. Each value in a table is referred to by a key. By default, numeric keys are assigned starting at 1. You don't have to use these keys though and you can assign any number or any string to be the key for a particular value.

In lua there is a loop called the generic for loop which can do many different things based on an iterator function - in this case the iteration function I will mention is called, in pairs. in pairs allows you to cycle through key,value pairs in a table.

peripheral.getMethods returns a table which you can store in a variable of any name you wish. You can't just print this table though (I think when you get table:4wfewf4 it is referring to its point in memory). To print out the stuff in side it you need the generic for loop and it goes roughly like this

Code:
local myTable = methodThatReturnsTable() -- replace this whatever you are doing

for k,v in pairs(myTable) do
   --For each point in the table k stores the name of the key and v stores the value. You can always print k out and so long as v is not of type "table" or        --type "function" you can print that out too
    print(k)
    print(v)
end

When you get the hang of it, I promise you it is not too bad.
I am not entirely sure what your problem with the peripheral wrapping is but I have an idea. It sounds like you don't have much experience with wrapping peripherals so I will tell you about that too.

When you wrap a peripheral you end up with a handle to that variable which you can store as a variable and you can use that variable to tell the peripheral to do stuff.

Like this

local monitor = peripheral.wrap("left") -- assuming the monitor is on the left hand side

The variable monitor is the handle on the monitor now. To test this, go into a creative world and spawn in a computer and a monitor and then look through the term api on the CC wiki - http://computercraft.info/wiki/Term_(API)

For pretty much every method in that api you can remove the word term and replace it with the handle you assigned to your monitor peripheral.

Code:
local monitor = peripheral.wrap("left")

term.write("Hello World") -- prints Hello World to the computer console
monitor.write("Hello World") -- prints Hello World to the monitor

The same principle applies to every peripheral, including redstone energy cells (at least in 1.6.4 - sensors from openccsensors worked a bit differently before but that has changed now and it is the only exception that I am aware of). You do not need to wrap a peripheral to do the getMethods command but you do need to wrap it if you want to do anything else with it. When wrapping make sure to provide the side the peripheral is on, or if you are connecting via wired modem, use the string that appears in game chat when you click the modem to turn it red.

This is pretty much all the information I will offer in this thread because I am starting to repeat myself in several threads. It is only because I am so enthusiastic about this mod and I am happy to help where I can. I think I am going to start a thread of my own in the next few days which might clear this sort of thing up for more people.
 

Lewis Evelyn

New Member
Jul 29, 2019
25
0
0
One thing

Code:
modem = peripheral.wrap("back")

methods = modem.callRemote("cofh_thermalexpansion_energycell_0", "getAdvancedMethodsData")

for k, v in paris(methods) do
print(k)
print(v)
end

this is my code to get the methods displayed, (i done getAdvancedMethodsData because 'listMethods' only returned "listMethods() getAdvancedMethodsData()")

but when i do the code above I get,

1
table: 7cebe4c0
2
table: 62f73952

Am I meant to for loop these too :S where does it end D: haha
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0

First of all thank you, and
Secondly

You are meant to iterate through those tables too (and there are even some more tables after that:)) However, I can all but guarantee you that when you open up those tables they will be giving advanced data about listMethods() and getAdvancedMethodsData().That function you are using is basically open peripheral's in game documentation but there are like a billion nested tables inside it and it can be a bit difficult to read, but I am working on something to make it a bit easier which you might see on these forums soon.

I have never seen the modem.callRemote method before but I think I can make out what it is doing, actually it looks just like the peripheral.call() method.

There are three possible reasons why you are only getting those two methods (they appear on seemingly every block when Open peripherals is installed).

1. The block type is not supported full stop - e.g a dirt block has no methods]
2. The block type is not supported in your version - I can only confirm that up to date Resonant Rise packs have open peripherals versions which support the new Thermal expansion. To be honest though, I would be surprised if the main current FTB packs didn't also. I am pretty sure that unleashed also had an open peripherals version that supported the old Thermal expansion
3. The connection has not been made properly - If the peripheral is on the side, make sure it is using the correct side. If you are connecting with wires, after ensuring that there are no gaps in the cable, make sure that the wired modem on the peripheral is showing a red band on it. This shows that it is connected to the network.

If it is none of these problems then I am very confused. What modpack are you using btw?

Finally, you can interact with the peripheral directly using the handle you made with peripheral.wrap without even wrapping the modems. You just need to make sure the wired modems are showing the red band.
 

Lewis Evelyn

New Member
Jul 29, 2019
25
0
0
Ahh! I think I know what I am doing am I wrapping the wired modem on the back instead of the cell (which is only two blocks away with and with the red bands on)

I am using the current Direwolf pack on ftb so I assume that thermal expansion should be supported otherwise mikeymoo needs to hurry up :p

the connection should be working as I was getting errors whilst trying when i realised they were in disconnected mode
 

casilleroatr

New Member
Jul 29, 2019
1,360
0
0
Well, based on that it should work just fine if you do the ordinary peripheral.wrap() stuff that I described (it looks like DW20 and resonant rise are using the roughly the same version of open peripherals so the support should be in place for you). Good luck and have fun
 

Bomb Bloke

New Member
Jul 29, 2019
612
0
0
To my understanding, the later OpenPeripheral snapshots have supported the new TE systems for a while now, but for whatever reason they haven't been added to Direwolf (or a number of other packs, for that matter).

So if the support is missing you should be able to install a new snapshot yourself.
 

Lewis Evelyn

New Member
Jul 29, 2019
25
0
0
Oh right I see, thats why I couldn't get the getEnergyStored, if I install it will this be effective on a server too or only in single-player?
 

Bomb Bloke

New Member
Jul 29, 2019
612
0
0
The Lua stuff runs on the server side of things, so the snapshots need to be set up on the servers you play if you wish to use them there. By extension, I'd assume everyone else playing on that server would also need to update to the same versions.
 
Last edited: