Advertisement
ceed24

Wither Boss Builder Computercraft

Nov 12th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.06 KB | None | 0 0
  1. -- Minecraft Wither Boss Builder (left to right).
  2. -- Requires:
  3. -- 5x5x5 area
  4. -- chest (Place the chest next(Left side) the turtle)
  5. -- Slot 1, Soul Sand
  6. -- Slot 2, Wither Skeleton Skull (if you wanna test it first ,use a regular Skeleton Skull instead )
  7. -- Slot 3, Coal
  8.  
  9.  
  10.  
  11.  
  12. local td ={ name = {"minecraft:soul_sand","minecraft:skull","minecraft:coal"}, min = {5,3,1} }
  13. local chestSide =0
  14.  
  15.  
  16. function NeedFuel()
  17.     if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1  then
  18.  
  19.     turtle.select(3)
  20.             if turtle.refuel() then
  21.                 print("Fuel level is: ", ( turtle.getFuelLevel() / turtle.getFuelLimit() ) * 100, "%")
  22.             else
  23.                 print("Can't refuel ,Place some Coal in the 1st Slot")
  24.             end
  25.     else print("Fuel level is: ", ( turtle.getFuelLevel() / turtle.getFuelLimit() ) * 100, "%","We can still move", turtle.getFuelLevel(), "blocks")
  26. end
  27. end
  28.  
  29.  
  30. function findchest()
  31. local ChestEx
  32. local EnderChestEx
  33.  
  34.     for i=1 , 4 do
  35.         local success, data = turtle.inspect()
  36.             if success then
  37.                     ChestEx= string.find(data.name, "chest")
  38.                     EnderChestEx= string.find(data.name, "Chest")
  39.                
  40.                     if ChestEx or EnderChestEx then
  41.                         for i=1 , 3 do
  42.                         turtle.select(i)
  43.                         turtle.drop()
  44.                         end
  45.                         chestSide=i
  46.                         getItems()
  47.                         return true
  48.                     else
  49.                         turtle.turnRight()
  50.                     end
  51.             else
  52.                 turtle.turnRight()
  53.             end
  54.     end
  55.         --shell.run("clear")
  56.         print("Place the chest next(L) the turtle then add at last soul sand(5),skulls(3),coal(1) into it")
  57.     return false
  58. end
  59.  
  60.  
  61. function SortItem(s)
  62.     ItemDatastack=turtle.getItemDetail(s)
  63.    
  64.     if ItemDatastack then
  65.  
  66.                 turtle.select(s)
  67.         if (ItemDatastack.name==td.name[1] )  then
  68.                 turtle.transferTo(1)
  69.             elseif  (ItemDatastack.name==td.name[2]) then
  70.                 turtle.transferTo(2)
  71.             elseif  (ItemDatastack.name==td.name[3]) then
  72.                 turtle.transferTo(3)
  73.             else
  74.                 turtle.drop()
  75.         end                    
  76.     end                    
  77. end
  78.  
  79.  
  80. function getItems()
  81. turtle.select(4)
  82.     while true do
  83.         local Item = turtle.suck()
  84.         if not Item then
  85.             for i=1 , 16 do
  86.                 SortItem(i)
  87.             end
  88.             return false
  89.         end
  90.         -- for i=4 , 16 do
  91.         -- turtle.select(i)
  92.         -- turtle.drop()
  93.         -- end
  94.     end
  95. end
  96.  
  97.  
  98. function CountItem()
  99. local count =true
  100. local ItemDatastack={}
  101. for i=1 , 2 do
  102. turtle.select(i)
  103. ItemDatastack=turtle.getItemDetail(i)
  104.     if  ItemDatastack then
  105.         if (ItemDatastack.count<td.min[i]) then
  106.         print("---------------------------------------")      
  107.         print("add more: ",string.sub(ItemDatastack.name, 11))
  108.         print("---------------------------------------")
  109.         count=false
  110.         end
  111.         else
  112.         print("---------------------------------------")      
  113.         print("add : ",string.sub(td.name[i], 11)," to chest")
  114.         print("---------------------------------------")
  115.         count=false
  116.     end
  117. end
  118. if not count then
  119. return false
  120. else
  121. return true
  122. end
  123. turtle.select(1)
  124. end
  125.  
  126.  
  127. function PreBuild()
  128. for i=4 , 16 do
  129. turtle.select(i)
  130. turtle.drop()
  131. end
  132. for i=1, chestSide+1 do
  133. turtle.turnRight()
  134. end
  135. end
  136.  
  137.  
  138. function BuildWither()
  139. turtle.forward()
  140. turtle.up()
  141. turtle.select(1)
  142. turtle.place()
  143. PlaceWitherHead()
  144. MoveToNext()
  145. PlaceWitherHead()
  146. turtle.down()
  147. turtle.place()
  148. turtle.up()
  149. MoveToNext()
  150. PlaceWitherHead()
  151. end
  152.  
  153.  
  154. function MoveToNext()
  155. turtle.turnRight()
  156. turtle.forward()
  157. turtle.turnLeft()
  158. turtle.place()
  159. end
  160.  
  161.  
  162. function PlaceWitherHead()
  163. turtle.select(2)
  164. turtle.up()
  165. turtle.place()
  166. turtle.down()
  167. turtle.select(1)
  168. end
  169.  
  170.  
  171. function BackToFirst()
  172. turtle.turnLeft()
  173. turtle.forward()
  174. turtle.forward()
  175. turtle.turnRight()
  176. turtle.down()
  177. turtle.back()
  178. end
  179.  
  180.  
  181. if findchest()   then
  182. PreBuild()
  183. while CountItem() do
  184. NeedFuel()
  185. BuildWither()
  186. BackToFirst()
  187. sleep(15)
  188. end
  189. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement