Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Tank Monitor ]]--
- local fluidTank -- tank
- local mon -- monitor
- for _,side in pairs(rs.getSides()) do -- this calls redstone.getSides() to look at each side of the computer
- 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...
- if peripheral.getType(side) == "monitor" then -- if we find a monitor...
- mon = peripheral.wrap(side) -- ...we wrap it
- elseif peripheral.getType(side) == "openblocks_tank" then -- if we find an openblocks tank...
- fluidTank = peripheral.wrap(side) -- ...wrap it
- elseif peripheral.getType(side) == "rcirontankvalvetile" then -- if we find a railcraft iron tank...
- fluidTank = peripheral.wrap(side) -- ...wrap it
- elseif peripheral.getType(side) == "net_minecraft_src_buildcraft_factory_tiletank" then -- if we find a buildcraft tank...
- fluidTank = peripheral.wrap(side) -- ...wrap it
- elseif peripheral.getType(side) == "modem" then -- if we find a modem, we...
- if not peripheral.call(side,"isWireless") then -- ...eliminate wireless modems and...
- for _,device in pairs(peripheral.call(side,"getNamesRemote")) do -- ...look for network attached peripherals
- 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...
- fluidTank = peripheral.wrap(device) -- ...wrap it
- elseif string.sub(device,1,7) == "monitor" then -- if we find a monitor...
- mon = peripheral.wrap(device) -- ...wrap it
- end
- end
- end
- end
- end
- end
- mon.setTextScale(2) -- valid text scales are 0.5, 1, 2, 3, 4, 5
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write("Tank 1:")
- repeat -- do the following repeatedly until we match the 'until' parameter
- local tankInfo = fluidTank.getTankInfo("unknown") -- get tank's info
- local tankStats = tankInfo[1] -- take just the table of info we want from the info returned by the tank
- local yPos = 2 -- set cursor Y position variable
- for k,v in pairs(tankStats) do -- start parsing the tank's information table
- mon.setCursorPos(1,yPos) -- set cursor position
- mon.write(tostring(k) .. ": " .. tostring(v) .. " ") -- display key and value information for tank
- yPos = yPos + 1 -- increment cursor Y position variable
- end
- sleep(1) -- sleep for 1 second before refreshing the tank info
- until yPos == 1000 -- if our cursor Y position variable ever == 1000 we end
Advertisement
Add Comment
Please, Sign In to add comment