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

Help looping OpenP tank reading code.

Started by infizl, 05 July 2013 - 04:28 PM
infizl #1
Posted 05 July 2013 - 06:28 PM
I have coding using openperipherals but i need it to update the amount of liquid thats in the tank endlesly if i take it out or put it in i need it to tell me the amount it has

this is the code i have now


local lava = peripheral.wrap("iron_tank_valve_2")

local lavatank = lava.getTanks("unknown")
if not lavatank[1].amount then
  lavatext = "Lava: Empty"
   else
   lavatext = "Lava: "..tostring(lavatank[1].amount).."/"..tostring(lavatank[1].capacity)
  end
	term.clear()
	term.setCursorPos(1,1)
	 print(lavatext)
  sleep(0.5)

all i want is for the amount in the tank to auto update and i cant figure out how please help

thanks
Lyqyd #2
Posted 05 July 2013 - 08:06 PM
Split into new topic.

You should be able to put a while true do on the line after the peripheral.wrap line and an end at the end, and it should work fine.
infizl #3
Posted 05 July 2013 - 11:00 PM
i did that but it still dosent work it dosent update when more liquid is added or liquid is taken out of the tank no matter how long i wait is there any other way?

Thanks for the help alot i had the while true do part placed in the wrong area its fixed now THANK you so much
Edited on 05 July 2013 - 09:08 PM