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

RailCraft Iron Tanks problem

Started by Superadam051, 03 September 2013 - 01:16 PM
Superadam051 #1
Posted 03 September 2013 - 03:16 PM
RailCraft Iron Tanks problem

I've no idea how to code this part. I'v followed the documentation from here http://www.openperipheral.info/openperipheral/documentation/railcraft/iron-tank-valve
and looked at various forum posts. I've copied word for word what they wrote and what worked for them, hasn't worked for me.
It happened to a password lock I created too. It wasn't working and then the next day it started working. No changes AT ALL were made to the code but it started working…
I'm basically trying read the getTanks() function from the OpenPeripherals mod but I don't know how to use it. Can someone provide an example of a working code where when I run it it will display the information of the tank.

Thanks in advance
apemanzilla #2
Posted 06 October 2013 - 08:46 PM
(Sorry if this counts as a necro)

First of all make sure youre wrapping the valve - the gauge and walls wont work.
Second, there is an argument in the function "getTanks(side)" - To the best of my knowedge, this is the side the tank is on (north/east/west/south/up/down)
It will return a table which you should save.

local a = getTanks("north")
Then the table is formatted as such:
a[1] is the first tank - if you use a for loop to list this you will see values such as the name of the liquid, the current stored, the capacity, etc.
a[2] is the second tank - this is noticeable on blocks such as boilers where there are two liquid bars, one for steam and another for water.
And so on.

Like this, I was able to properly read the data.
Inumel #3
Posted 06 October 2013 - 08:54 PM
Heres some actual code that should work


local tank = peripheral.wrap("change to your tanks valve")
local tableInfo = tank.getTanks("unknown")
for k,v in pairs(tableInfo) do
  for x,y in pairs(v) do
	 print(x..": "..y)
   end
end
again, should work.. It's a slightly modified version of the code I use
DerKoch #4
Posted 06 October 2013 - 10:51 PM
Hmmm, I only used getTanks() with Steam Boilers (Computer next to Liquid Fueled Firebox), but I never used any of the valid arguments at all. And it still worked somehow :o/>
Like this:

boilerTanks = highPressureBoiler.getTanks("")
Nonetheless, Elgirtons snippet should pretty much help you with figuring out the data you get.
theoriginalbit #5
Posted 07 October 2013 - 12:53 AM
I never used any of the valid arguments at all.
This is because people don't like to validate things, there are lots of validation problems all through OpenPeripheral.