Hiranus

Tank manager

Aug 24th, 2014
505
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.39 KB | None | 0 0
  1. local _redstone_site = "right"
  2.  
  3. function search(perToFind)
  4.         local printMode = false
  5.         if perToFind == "print" then
  6.                 printMode=true
  7.         end
  8.         if printMode == true then
  9.                 term.clear()
  10.                 term.setCursorPos(1,1)
  11.         end
  12.         local sides = { "top", "bottom", "left", "right", "front", "back" }
  13.         for i = 1, #sides do
  14.                 if peripheral.isPresent(sides[i]) then
  15.                         if peripheral.getType(sides[i]) == "modem" then
  16.                                 local modem = peripheral.wrap(sides[i])
  17.                                 local methods = peripheral.getMethods(sides[i])
  18.                                 local wired = false
  19.                                 for j = 1, #methods do
  20.                                         if methods[j] == "getNamesRemote" then
  21.                                                 wired=true
  22.                                         end
  23.                                 end
  24.                                 if wired == true then
  25.                                         if printMode == true then
  26.                                                 print("There is " ..peripheral.getType(sides[i]).." on the "..sides[i] )
  27.                                         else
  28.                                                 if perToFind==peripheral.getType(sides[i]) then
  29.                                                         return sides[i]
  30.                                                 end
  31.                                         ----------------------------------------------------------------
  32.                                         end
  33.                                         local net = modem.getNamesRemote()
  34.                                         for j = 1, #net do
  35.                                                 if printMode == true then              
  36.                                                         print("   ".. peripheral.getType(net[j]))
  37.                                                 else
  38.                                                         if perToFind==peripheral.getType(net[j]) then
  39.                                                                 return net[j]
  40.                                                         end    
  41.                                                 ---------------------------------
  42.                                                 end
  43.                                         end
  44.                                 else
  45.                                         if printMode == true then
  46.                                                 print("There is wireless modem on the "..sides[i] )
  47.                                         else
  48.                                                 if perToFind==peripheral.getType(sides[i]) then
  49.                                                         return sides[i]
  50.                                                 end
  51.                                        
  52.                                         ---------------------------------
  53.                                         end
  54.                                 end
  55.                         else
  56.                                 if printMode == true then
  57.                                         print("There is " ..peripheral.getType(sides[i]).." on the "..sides[i] )
  58.                                 else
  59.                                         if perToFind==peripheral.getType(sides[i]) then
  60.                                                         return sides[i]
  61.                                                 end
  62.                                 -----------------------
  63.                                 end    
  64.                         end
  65.                 else
  66.                 if printMode == true then
  67.                         print("There is nothing on the "..sides[i] )
  68.                 end
  69.                 end
  70.         end
  71. end
  72. local filling = false
  73. rs.setOutput(_redstone_site,false)
  74. local fill=0
  75. while true do
  76.     os.sleep (1)
  77.     local _tank_info = peripheral.call(search("net_minecraft_src_buildcraft_factory_tiletank"),"getTankInfo","")[1]
  78.     if _tank_info.amount then
  79.         fill=(_tank_info.amount/_tank_info.capacity*100)
  80.     else
  81.         fill=0
  82.     end
  83.     print(fill)
  84.     if filling == false then
  85.         if fill <= 10 then
  86.             filling = true
  87.             rs.setOutput(_redstone_site,true)
  88.         end
  89.     else
  90.         if fill >= 90 then
  91.             filling = false
  92.             rs.setOutput(_redstone_site,false)
  93.         end
  94.     end
  95. end
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment