bigtwisty

Enchanter

Apr 11th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. --name Enchanter
  2. --version 1.0
  3. version = "1.0a"
  4.  
  5. local side = {}
  6. side.enchanter = 0
  7. side.books = 5
  8. side.enBooks = 1
  9.  
  10. local bookId = 340
  11. local bookCount
  12. local enchanter
  13. local enBookId
  14. local loopTime = 0.1
  15.  
  16. sorter = peripheral.wrap("back")
  17.  
  18. while true do
  19. local x = sorter.list(side.books)
  20. if x == nil then
  21. bookCount = -1
  22. else
  23. bookCount = 0
  24. for id,cnt in pairs(x) do
  25. if id == bookId then
  26. bookCount = cnt
  27. end
  28. end
  29. end
  30.  
  31. x = sorter.list(side.enchanter)
  32. if x == nil then
  33. enchanter = -1
  34. else
  35. enchanter = 0
  36. for id,cnt in pairs(x) do
  37. if id == bookId then
  38. enchanter = 1
  39. else
  40. enchanter = 2
  41. enBookId = id
  42. end
  43. end
  44. end
  45.  
  46. x = sorter.list(side.enBooks)
  47. if x == nil then
  48. enBooks = -1
  49. else
  50. enBooks = 1
  51. end
  52.  
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. print("Enchanter (v", version, ")")
  56. print("------------------------\n")
  57. print("| Blank books: " .. ((bookCount == -1) and "Not connected" or tostring(bookCount)))
  58. write("| Enchanter: ")
  59. if (enchanter == -1) then
  60. print("Not connected.")
  61. elseif (enchanter == 0) then
  62. print("Empty")
  63. sorter.extract(side.books, bookId, side.enchanter, 1)
  64. elseif (enchanter == 1) then
  65. print("Ready")
  66. elseif (enchanter == 2) then
  67. print("Done")
  68. sorter.extract(side.enchanter, enBookId, 1, 1)
  69. end
  70. os.sleep(loopTime)
  71. end
Advertisement
Add Comment
Please, Sign In to add comment