Advertisement
Bunny_bt

Liquid Transfer

Sep 23rd, 2022 (edited)
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. while true do
  2.     term.clear()
  3.     term.setCursorPos(1,1)
  4.     local fuelReservoir = {}
  5.     table.insert(fuelReservoir, peripheral.wrap('railcraft:tank_iron_valve_12'))
  6.     table.insert(fuelReservoir, peripheral.wrap('railcraft:tank_iron_valve_10'))
  7.     local fuelBuffer = peripheral.wrap('irontanks:tank_6')
  8.    
  9.     print('Press 1 to fill with', fuelReservoir[1].getTanks()[1].name)
  10.     print('Press 2 to fill with', fuelReservoir[2].getTanks()[1].name)
  11.     print('Press F to flush buffer')
  12.     print('Press R to autorefill')
  13.    
  14.     local evt = {os.pullEvent('char')}
  15.     if evt[2] == '1' or evt[2] == '2' or evt[2] == 'f' or evt[2] == 'r' then
  16.         for k,v in pairs(fuelReservoir) do
  17.             if fuelBuffer.getTanks()[1].name == v.getTanks()[1].name then
  18.                 if evt[2] == 'r' then
  19.                     term.clear()
  20.                     term.setCursorPos(1,1)
  21.                     print('Running Automatic Mode')
  22.                     while true do
  23.                         fuelBuffer.pullFluid(peripheral.getName(v))
  24.                         sleep(60)
  25.                     end
  26.                 else
  27.                     v.pullFluid(peripheral.getName(fuelBuffer))
  28.                 end
  29.             end
  30.         end
  31.         if evt[2] == '1' then
  32.             fuelBuffer.pullFluid(peripheral.getName(fuelReservoir[1]))
  33.         elseif evt[2] == '2' then
  34.             fuelBuffer.pullFluid(peripheral.getName(fuelReservoir[2]))
  35.         elseif evt[2] == 'f' then
  36.             for k,v in pairs(fuelReservoir) do
  37.                 if fuelBuffer.getTanks()[1].name == v.getTanks()[1].name then
  38.                     v.pullFluid(peripheral.getname(fuelBuffer))
  39.                 end
  40.             end
  41.         end
  42.     end
  43.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement