Advertisement
camarajohnny

Fire_Drop_V2

Feb 23rd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.61 KB | None | 0 0
  1. function os.pullEvent() --- disable ctrl T
  2. local event, p1, p2, p3, p4, p5 = os.pullEventRaw()
  3. local code = "0okm"
  4. local inputs = ""
  5. if event == "terminate" then
  6. print ("Enter Admin code")
  7. inputs = read()
  8. if inputs == code then
  9. exit()
  10. end
  11. sleep(2)
  12. end
  13. return event, p1, p2, p3, p4, p5
  14. end
  15.  
  16. function pickEnder(enderNumber,enderChest) --enderNumber is between 0 and 4096, enderChest is the wrapped chest
  17. b1 = math.floor(enderNumber/ 256) -- find first colour code
  18. b2 = math.floor((enderNumber - (256 *b1)) / 16)
  19. b3 = enderNumber % 16
  20. error = enderChest.setColors(2^b1,2^b2,2^b3)
  21. return error
  22. end -- ends pickEnder()
  23.  
  24. function invSort()
  25. for i = 1,16 do
  26. if turtle.getItemCount(i) > 0 and turtle.getItemCount(i) < 64 then
  27. turtle.select(i)
  28. for j = i+1,16 do
  29. if turtle.compareTo(j) then
  30. turtle.select(j)
  31. turtle.transferTo(i)
  32. turtle.select(i)
  33. end
  34. end
  35. end
  36. end
  37. end
  38.  
  39. function unload()
  40. -- local isSeed = false
  41. local outPutChest = 128-- chest combo to output inv
  42. local isBlock
  43. local blockDetail
  44. isBlock, blockDetail = turtle.inspectUp()
  45. if (blockDetail.name == "EnderStorage:enderChest") then
  46. chest = peripheral.wrap("top")
  47. pickEnder(outPutChest,chest)
  48.  
  49. end
  50. turtle.select(1)
  51. while turtle.suckUp() == true do
  52. end
  53. end
  54.  
  55. function isTurn()
  56. signalBlock = {right = "minecraft:log", left = "chisel:redstone_block", up = "minecraft:cobblestone", down = "minecraft:netherrack", chest = "EnderStorage:enderChest"} -- this table holds values for the signal block the turtle uses to decide what way to turn
  57. local isBlock = true
  58. local infoBlock -- checks if and what type of block is in front of it
  59. while (isBlock == true) do
  60. isBlock, infoBlock = turtle.inspect()
  61. if (isBlock == true) then
  62. if (infoBlock.name == signalBlock.left) then
  63. turtle.turnLeft()
  64. unload()
  65. elseif (infoBlock.name == signalBlock.right) then
  66. turtle.turnRight()
  67. unload()
  68. elseif (infoBlock.name == signalBlock.up) then
  69. turtle.up()
  70. elseif (infoBlock.name == signalBlock.down) then
  71. turtle.down()
  72. elseif (infoBlock.name == signalBlock.chest) then
  73. unload()
  74. turtle.turnLeft()
  75. -- else
  76. -- print("path blocked. remove object and hit enter")
  77. -- read()
  78. end
  79. end
  80. end
  81. end
  82.  
  83. function menu ()
  84. while true do
  85. local keyPress
  86. term.clear()
  87. term.setCursorPos(1,1)
  88. print("press p to pause")
  89. keyPress = read()
  90.  
  91. if keyPress == "p" then
  92. isPause = true
  93. term.clear()
  94. term.setCursorPos(1,1)
  95. while isPause == true do
  96. print("press r to resume, e to edit")
  97. keyPress = read()
  98. if keyPress == "r" then
  99. hasSeeds = true
  100. isPause = false
  101. elseif keyPress == "e" then
  102. --edit()
  103. print("edit no worko")
  104. end
  105. end
  106. end
  107. end
  108. end
  109.  
  110. function forward()
  111. local isObject
  112. local isFound = false
  113. local objId
  114. print("Do I turn?")
  115. isTurn()
  116. -- turtle.select(1)
  117. while isFound == false do
  118. isObject, objId = turtle.inspectDown()
  119. if isObject == false then
  120. turtle.forward()
  121. isTurn()
  122. else
  123. if objId.name == "Botania:specialFlower" then
  124. isFound = true
  125. --turtle.forward()
  126. isTurn()
  127. else
  128. turtle.forward()
  129. isTurn()
  130.  
  131. end
  132. end
  133. end
  134. end
  135. function dropItem()
  136. local itemsCount = 0
  137. local slot = turtle.getSelectedSlot()
  138. local count = 0
  139. local isFound = false
  140. while isFound == false do
  141. itemsCount = turtle.getItemCount(slot)
  142. if itemsCount > 0 then
  143. isFound = true
  144. turtle.select(slot)
  145. else
  146. slot = slot + 1
  147. if slot == 17 then
  148. slot = 1
  149. end
  150. end
  151. end
  152. turtle.dropDown(1)
  153. end
  154.  
  155. function go() -- main farm function
  156. while true do
  157. print("Forward")
  158. forward()
  159. print("dropping")
  160. dropItem()
  161. turtle.forward()
  162. while (isPause) do
  163. sleep(1)
  164. end
  165. end
  166. end
  167.  
  168. local isPause = false
  169. parallel.waitForAll(menu, go)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement