Advertisement
RigorMortis

test

Jul 1st, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. -- call function(s)
  2. input()
  3. wrap()
  4. send()
  5.  
  6.  
  7. -- predefined variables
  8.  
  9.  
  10. -- input
  11. function input()
  12.     print("Frequency ?")
  13.     local event, key = os.pullEvent(key)
  14.     local sf = key
  15.     print("complex number ?")
  16.     local event, key = os.pullEvent(key)
  17.     local complexnumber = key
  18. end
  19.  
  20. -- wrap modem and drums
  21. function wrap()
  22. local modem = peripheral.wrap("left")
  23. local sides = {}
  24. sides[1] = "front"
  25. sides[2] = "right"
  26. sides[3] = "back"
  27. sides[4] = "bottom"
  28. sides[5] = "top"
  29.     for k,_ in pairs(sides) do
  30.         if peripheral.isPresent(sides[k]) then
  31.             print(peripheral.getType(sides[k])," on ",sides[k]," found")
  32.             drum = peripheral.wrap(sides[k])
  33.             Tankinfo = drum.getTankInfo("down")
  34.             -- checks if there is a fluid in the drum to avoid a nil value
  35.             if Tankinfo[1].contents then
  36.                 if peripheral.getType(sides[k]) == "drum" then
  37.                     print(Tankinfo[1].contents.name," in drum ",sides[k])
  38.                 end
  39.             else
  40.                 print("no fluid in drum ",sides[k])
  41.             end
  42.         else
  43.             print("no item found on side ",sides[k])
  44.         end
  45.     end
  46. sleep(2)
  47. term.clear()
  48. term.setCursorPos(1,1)
  49. print("automation active")
  50. end
  51.  
  52.  
  53. function send()
  54. modem.closeAll()
  55. modem.open(sf)
  56. local drumcounter = 0
  57. for k,_ in pairs(sides) do
  58.         if peripheral.isPresent(sides[k]) then
  59.             drum = peripheral.wrap(sides[k])
  60.             Tankinfo = drum.getTankInfo("down")
  61.             -- checks if there is a fluid in the drum to avoid a nil value
  62.             if peripheral.getType(sides[k]) == "drum" then
  63.                 if Tankinfo[1].contents then
  64.                     local drumcounter = drumcounter+1
  65.                     transmit(sf,1,complexnumber)
  66.                     transmit(sf,1,Tankinfo[1].content.name)
  67.                     transmit(sf,1,Tankinfo[1].content.amount)              
  68.                     print("drumcounter: ",drumcounter," nonemptydrum"")
  69.                 else   
  70.                     local drumcounter = drumcounter+1
  71.                     transmit(sf,1,complexnumber)
  72.                     tramsmit(sf,1,"empty")
  73.                     transmit(sf,1,0)
  74.                     print("drumcounter: ",drumcounter," emptydrum")
  75.                 end
  76.             end
  77.         end
  78. transmit(sf,1,drumcounter)
  79. tramsmit(sf,1,"done")
  80. print("end send")
  81. end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement