Zatilla7

Another version of Tanks

Nov 7th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. --[[ Tank Monitor ]]--
  2. local fluidTank -- tank
  3. local mon -- monitor
  4. for _,side in pairs(rs.getSides()) do -- this calls redstone.getSides() to look at each side of the computer
  5. if peripheral.isPresent(side) then -- if we find a perhiperal, we then try to identify if it's one of the peripherals we're looking for...
  6. if peripheral.getType(side) == "monitor" then -- if we find a monitor...
  7. mon = peripheral.wrap(side) -- ...we wrap it
  8. elseif peripheral.getType(side) == "openblocks_tank" then -- if we find an openblocks tank...
  9. fluidTank = peripheral.wrap(side) -- ...wrap it
  10. elseif peripheral.getType(side) == "rcirontankvalvetile" then -- if we find a railcraft iron tank...
  11. fluidTank = peripheral.wrap(side) -- ...wrap it
  12. elseif peripheral.getType(side) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a buildcraft tank...
  13. fluidTank = peripheral.wrap(side) -- ...wrap it
  14. elseif peripheral.getType(side) == "modem" then -- if we find a modem, we...
  15. if not peripheral.call(side,"isWireless") then -- ...eliminate wireless modems and...
  16. for _,device in pairs(peripheral.call(side,"getNamesRemote")) do -- ...look for network attached peripherals
  17. if string.sub(device,1,15) == "openblocks_tank" or string.sub(device,1,19) == "rcirontankvalvetile" or string.sub(device,1,45) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a tank...
  18. fluidTank = peripheral.wrap(device) -- ...wrap it
  19. elseif string.sub(device,1,7) == "monitor" then -- if we find a monitor...
  20. mon = peripheral.wrap(device) -- ...wrap it
  21. end
  22. end
  23. end
  24. end
  25. end
  26. end
  27. mon.setTextScale(2) -- valid text scales are 0.5, 1, 2, 3, 4, 5
  28. mon.clear()
  29. mon.setCursorPos(1,1)
  30. mon.write("Tank 1:")
  31. repeat -- do the following repeatedly until we match the 'until' parameter
  32. local tankInfo = fluidTank.getTankInfo("unknown") -- get tank's info
  33. local tankStats = tankInfo[1] -- take just the table of info we want from the info returned by the tank
  34. local yPos = 2 -- set cursor Y position variable
  35. for k,v in pairs(tankStats) do -- start parsing the tank's information table
  36. mon.setCursorPos(1,yPos) -- set cursor position
  37. mon.write(tostring(k) .. ": " .. tostring(v) .. " ") -- display key and value information for tank
  38. yPos = yPos + 1 -- increment cursor Y position variable
  39. end
  40. sleep(1) -- sleep for 1 second before refreshing the tank info
  41. until yPos == 1000 -- if our cursor Y position variable ever == 1000 we end
Advertisement
Add Comment
Please, Sign In to add comment