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

Help: how to create a tank capacity monitoring program.

Started by CrookedSpine, 28 December 2015 - 01:06 AM
CrookedSpine #1
Posted 28 December 2015 - 02:06 AM
I'm new to computercraft (using it for a week, now). I know the basics: how to make loops, conditional statements and tables. What I really want is to create a program that tells me the amount of liquid remaining on a tank (Buildcraft and Openblocks ones), for a Galacticraft space station, if that's possible.
HPWebcamAble #2
Posted 28 December 2015 - 03:38 AM
First, you'll need a way for the computer to get the amount liquid remaining in the tank.

If the tanks can output redstone (which I doubt but I haven't used either of those mods for a bit), you can read that with a computer.
Or, the more precise method, wrap the tank(s) as a peripheral and directly get the liquid left (as a number)

You can use my Get Methods program to figure out if a block is a peripheral, and what functions it has:
http://pastebin.com/sKLqTGrM


Anyway, here's how you would write the program:

--# Wrap the tank as a peripheral (if you will be using the tank as a peripheral)

while true do --# Infinite loop

  --# Read the level of the tank
  --# Display the level
  sleep( 2 ) --# Make sure you sleep for a second or two, it doesn't need to update too often

end

That's the basic structure
If you need help reading or displaying stuff, just ask :)/>