ravneravn

serum

Nov 17th, 2013
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. r = peripheral.wrap("front")
  2. t = peripheral.wrap("top")
  3. serum = {}
  4.  
  5. function writeFile()
  6. handle = fs.open("serums", "w")
  7. handle.write(textutils.serialize(serum))
  8. handle.close()
  9. end
  10.  
  11. function loadFile()
  12. handle = fs.open("serums", "r")
  13. serum = textutils.unserialize(handle.readLine())
  14. handle.close()
  15. end
  16.  
  17. function furnace()
  18. r.push("east", 0, 1)
  19. end
  20.  
  21.  
  22. function store()
  23. r.push("up", 0, 1)
  24. end
  25.  
  26. function checkSerum(serumName)
  27. for i = 1, #serum do
  28. if currSerum.name == serum[i] then
  29. return "match"
  30. end
  31. end
  32. end
  33.  
  34. function moveSerum()
  35. r.condense()
  36. if r.getStackInSlot(0) then
  37. currSerum = r.getStackInSlot(0)
  38. if checkSerum(currSerum.name) == "match" then
  39. --print("furnace")
  40. furnace()
  41. else
  42. print("####################################")
  43. print(currSerum.name)
  44. store()
  45. table.insert(serum, currSerum.name)
  46. writeFile()
  47. sendFile()
  48. end
  49. end
  50. end
  51.  
  52.  
  53.  
  54. function sendID()
  55. rednet.open("right")
  56. event, sid, mes, dis = os.pullEvent("rednet_message")
  57. if mes == "id2" then
  58. rednet.broadcast("id2")
  59. screen = sid
  60. print(smelter)
  61. end
  62. end
  63.  
  64. function sendFile()
  65. rednet.send(screen, textutils.serialize(serum))
  66. end
  67.  
  68.  
  69. --------------
  70.  
  71.  
  72. sendID()
  73. loadFile()
  74. sendFile()
  75. print("starting")
  76. while true do
  77. moveSerum()
  78. sleep(10)
  79. end
RAW Paste Data