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

Tanks and Open Peripherals

Started by westloar, 21 June 2015 - 08:49 PM
westloar #1
Posted 21 June 2015 - 10:49 PM
So I have seen quite a few fluid monitoring programs that use Railcraft Iron Tanks along with openperipherals to monitor everything about a tank and being stubborn I felt like making my own using a deep tank from TiC

I have tried the following code:


tank= peripheral.wrap("back")
tableTank = tank.getTankInfo("unknown")
contents = tableTank[1].contents

When trying to run the third line of code I get the following error:


lua:1: attempt to index ? (a nil value)

What's happening here?

Any guidance as to what I might be doing wrong here would be appreciated!
KingofGamesYami #2
Posted 21 June 2015 - 11:12 PM
What does this show you?


if not peripheral.isPresent( "back" ) then
  error( "No such tank on side back", 0 )
end
local tank = peripheral.wrap( "back" )
print( peripheral.getType( "back" ) )
local tableTank = tank.getTankInfo( "unknown" )
if not tableTank then
  error( "getTankInfo failed to return a table!", 0 )
end
if not tableTank[ 1 ] then
  print( "tableTank doesn't have an index of 1" )
  print( "tableTank contains the following indexes" )
  for k, v in pairs( tableTank ) do
    print( k )
  end
end
westloar #3
Posted 22 June 2015 - 08:04 PM
Thank for the debugging code I have no idea why I didn't consider this myself (maybe it's because it has been far too long since I have done any coding :P/>)

tableTank fails to return a table, although the code does show that it is a peripheral:

tsteelworks_highovendrain

any further ideas where I can find information on how to use the drain as a peripheral i.e. methods and data types etc? I've tried googling, to no avail!

Thanks again for your reply.
jerimo #4
Posted 23 June 2015 - 05:30 PM
If you use peripheral.getMethods(side) then it will give you a clear text list of all the methods you can use on it.
For example in a computer it would return a list in which is included reboot and the such
westloar #5
Posted 23 June 2015 - 07:53 PM
Unfortunately, that's the problem, when using peripheral.getMethods(side) it returns the same methods that a railcraft tank would return, however, it seems like it either does not behave like a railcraft tank or it just plain doesn't work.

I wondered if there is perhaps somewhere within configs or the like or any documentation available so I can clear this up.

I could use a railcraft tank, however I really would prefer to use the deep tank from TiC.

Any ideas?
KingofGamesYami #6
Posted 23 June 2015 - 08:31 PM
I'd try

openp/docs back

The in game documentation is pretty much the only documentation for OpenPeripherals, because it changes so much. It may be that the version of TiC isn't the one they added support for, and TiC changed something about the peripheral that makes their peripheral integration do weird things.
westloar #7
Posted 24 June 2015 - 09:44 PM
Thanks for the swift reply, I'll have a delve and see what I can unearth, I'll report back if I find anything interesting, thanks for you help @kingofgamesyami and @jerimo :)/>