Jump to content




Tank Read And Redstone.setoutput Problem


  • You cannot reply to this topic
2 replies to this topic

#1 Pjevser

  • Members
  • 9 posts

Posted 11 September 2013 - 12:01 PM

So i'm trying to make my code change redstone.setOutput on or off depening if my tank is full or not.
When i start my program and my tank is full it will keep redstone off, but if i take some liquid out of my tank it still says it's full with 720000 inside it.
Not sure what i'm doing wrong so i hope someone can help me spot the problem. I'm new to computercraft. :)

local valve = peripheral.wrap("left")
local tableInfo = valve.getTanks("unknown")
while true do

  for k, v in pairs(tableInfo) do
    for x, y in pairs(v) do
      if x == "amount" then
        if (y == 720000) then
          redstone.setOutput("right", false)
        elseif (y < 720000) then
          redstone.setOutput("right", true)
        end
      end
    end
  end
  os.sleep(10)
end

So my code is there, but whenever my liquid gets below 720000 it doesn't turn on redstone signal, and if i stop the program and start it again it will fine actiave the redstone signal, but then when the tank is full it wont turn it off again :(

#2 OmegaVest

  • Members
  • 436 posts

Posted 11 September 2013 - 02:45 PM

You initialize tableInfo outside the while loop. So it will always check the same result, instead of getting a new result. Move tableInfo = valve.getTanks("unknown") in to the while loop.

#3 Pjevser

  • Members
  • 9 posts

Posted 11 September 2013 - 02:54 PM

View PostOmegaVest, on 11 September 2013 - 02:45 PM, said:

You initialize tableInfo outside the while loop. So it will always check the same result, instead of getting a new result. Move tableInfo = valve.getTanks("unknown") in to the while loop.
Ah :) Ty didnt know that haha. But now i do know till next time :D





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users