Advertisement
SubTox1c

Clearance Time v3.0

Oct 29th, 2013
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.10 KB | None | 0 0
  1. -- This script is is working progress but if finally out of beta form.
  2.  
  3. -- This script has a left, right and centre function just in case you want you door to be in the middle
  4. --but if you do centre with an even number you will need to manually do the other half of the door.
  5.  
  6. --This script now detects for mobs/gravel/sand.
  7. --he also has an enderches function. not meant for normal chests
  8.  
  9. -- This is my first ever script. I did this as my learning script. I started this when I started learning the day I started scripting turtles and finished about a week later.
  10.  
  11. -- This script is for clearing out rooms mainly for under ground bases.
  12.  
  13. -- Not wise to use it for mining.
  14.  
  15. -- There is no copy right but if you make some good changes that work please let me know.
  16. -- email: subtox1cgaming@gmail.com
  17.  
  18. -- ADDED: normal chest function, enderchest function and press ENTER to start function
  19.  
  20. function textOutput(output_message, x_screen_pos, z_screen_pos, clear_area)
  21.         term.setCursorPos(x_screen_pos,z_screen_pos)
  22.         if clear_area == 0 then
  23.                 clear_area = string.len(output_message)
  24.         end    
  25.         write(output_message..string.rep(" ", (clear_area - string.len(output_message))))
  26. end
  27.  
  28. function uwd()
  29.     while not turtle.up() do
  30.         sleep(0.2)
  31.         turtle.digUp()
  32.         turtle.attackUp()
  33.     end
  34. end
  35.  
  36. function fwd()
  37.     while not turtle.forward() do
  38.         sleep(0,2)
  39.         turtle.dig()
  40.         turtle.attack()
  41.     end
  42. end
  43.  
  44. function dwd()
  45.     while not turtle.down() do
  46.         sleep(0.2)
  47.         turtle.digDown()
  48.         turtle.attackDown()
  49.     end
  50. end
  51.  
  52.  
  53.  
  54.  
  55.  
  56. function echest()
  57.     if v == "e" then
  58.         if turtle.getItemCount(16) > 0 then
  59.             print "unloading"
  60.             turtle.digDown()
  61.             turtle.select(1)
  62.             turtle.placeDown()
  63.             for i = 3,16 do
  64.                 turtle.select(i)
  65.                 turtle.dropDown()
  66.             end
  67.             turtle.select(1)
  68.             turtle.digDown()
  69.             turtle.select(2)
  70.             turtle.placeDown()
  71.             turtle.select(3)
  72.         end
  73.  
  74.         else
  75.             if v == "n" then
  76.                 if turtle.getItemCount(16) > 0 then
  77.                     print "unloading"
  78.                     turtle.turnLeft()
  79.                     turtle.dig()
  80.                     turtle.select(1)
  81.                     turtle.place()
  82.                     for i = 3,16 do
  83.                         turtle.select(i)
  84.                         turtle.drop()
  85.                         turtle.select(3)
  86.                     end
  87.                     turtle.turnRight()
  88.                 end
  89.             end
  90.     end
  91. end
  92.  
  93. function echest1()
  94.     if v == "e" then
  95.         if turtle.getItemCount(16) > 0 then
  96.             print "unloading"
  97.             turtle.digDown()
  98.             turtle.select(1)
  99.             turtle.placeDown()
  100.             for i = 3,16 do
  101.                 turtle.select(i)
  102.                 turtle.dropDown()
  103.             end
  104.             turtle.select(1)
  105.             turtle.digDown()
  106.             turtle.select(2)
  107.             turtle.place()
  108.             turtle.select(3)
  109.         end
  110.  
  111.         else
  112.             if v == "n" then
  113.                 if turtle.getItemCount(16) > 0 then
  114.                     print "unloading"
  115.                     turtle.turnRight()
  116.                     turtle.dig()
  117.                     turtle.select(1)
  118.                     turtle.place()
  119.                     for i = 3,16 do
  120.                         turtle.select(i)
  121.                         turtle.drop()
  122.                         turtle.select(3)
  123.                     end
  124.                     turtle.turnLeft()
  125.                 end
  126.             end
  127.     end
  128. end
  129.  
  130. function echest2()
  131.     if v == "e" then
  132.             print "unloading"
  133.             turtle.digDown()
  134.             turtle.select(1)
  135.             turtle.placeDown()
  136.             for i = 3,16 do
  137.                 turtle.select(i)
  138.                 turtle.dropDown()
  139.             end
  140.             turtle.select(1)
  141.             turtle.digDown()
  142.             turtle.select(2)
  143.             turtle.placeDown()
  144.             turtle.select(3)
  145.  
  146.         else
  147.             if v == "n" then
  148.                     print "unloading"
  149.                     turtle.digDown()
  150.                     turtle.select(1)
  151.                     turtle.placeDown()
  152.                     for i = 3,16 do
  153.                         turtle.select(i)
  154.                         turtle.dropDown()
  155.                         turtle.select(3)
  156.                     end
  157.             end
  158.     end
  159. end
  160.  
  161. function hight()
  162.     for i = 1,h do
  163.         turtle.digUp()
  164.         echest()
  165.         uwd()
  166.     end
  167.         for i = 1,h do
  168.             dwd()
  169.         end
  170.  
  171. end
  172.  
  173. function length()
  174.     for j = 1,l do
  175.         hight()
  176.         turtle.dig()
  177.         echest()
  178.         fwd()
  179.     end
  180.     hight()
  181.     turtle.turnRight()
  182.     turtle.turnRight()
  183.         for j = 1,l do
  184.             fwd()
  185.         end
  186. end
  187.  
  188.  
  189. function typing()
  190.     term.clear()
  191.     term.setCursorPos(1,1)
  192.     print "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
  193.     term.setCursorPos(10,2)
  194.     print "Clearance Time v3.0"
  195.     term.setCursorPos(13,3)
  196.     print "by SubTox1c"
  197.     term.setCursorPos(3,11)
  198.     print "With Help From:"
  199.     term.setCursorPos(25,11)
  200.     print "The_penguin101"
  201.     term.setCursorPos(1,12)
  202.     print "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
  203. end
  204.  
  205. function hwd()
  206.     for m = 1,w*0.5 do
  207.         turtle.dig()
  208.         echest()
  209.         fwd()
  210.     end
  211. end  
  212.  
  213. function width()
  214.     if d == "r" then
  215.         for k = 1,w do
  216.             length()
  217.             turtle.turnLeft()
  218.             turtle.dig()
  219.             echest()
  220.             fwd()
  221.             turtle.turnLeft()
  222.         end
  223.       else
  224.             if d == "l" then
  225.                 for k = 1,w do
  226.                     length()
  227.                     turtle.turnRight()
  228.                     turtle.dig()
  229.                     echest1()
  230.                     fwd()
  231.                     turtle.turnRight()
  232.                 end
  233.                else
  234.                     if d == "c" then
  235.                         if w > 0 then
  236.                             turtle.turnLeft()
  237.                             hwd()
  238.                             turtle.turnRight()
  239.                         end
  240.                         for p = 1,w do
  241.                             length()
  242.                             turtle.turnLeft()
  243.                             turtle.dig()
  244.                             echest()
  245.                             fwd()
  246.                             turtle.turnLeft()
  247.                         end
  248.                     end
  249.             end
  250.     end
  251.     length()
  252.  end
  253.  
  254.  function door()
  255.     for k = 1,a do
  256.         turtle.dig()
  257.         turtle.digUp()
  258.         echest()
  259.         fwd()
  260.     end
  261. end
  262.  
  263. typing()
  264. term.setCursorPos(4,5)
  265. print "How High Would You Like Me To Go?"
  266. term.setCursorPos(18,8)
  267. h=read()
  268. h=h-1
  269.  
  270. typing()
  271. term.setCursorPos(6,5)
  272. print "How Long Would You Like It?"
  273. term.setCursorPos(18,8)
  274. l=read()
  275. l=l-1
  276.  
  277. typing()
  278. term.setCursorPos(6,5)
  279. print "How Wide Would You Like It?"
  280. term.setCursorPos(18,8)
  281. w=read()
  282. w=w-1
  283.  
  284. typing()
  285. term.setCursorPos(6,5)
  286. print "Would You Like Me To Go...."
  287. print "     Left         [l]"
  288. print "     Right        [r]"
  289. print "     Centre       [c]"
  290. term.setCursorPos(18,9)
  291. d=read()
  292.  
  293. typing()
  294. term.setCursorPos(9,5)
  295. print"How Thick For The Door?"
  296. term.setCursorPos(4,6)
  297. print "(i.e. blocks between each room)"
  298. term.setCursorPos(18,9)
  299. a=read()
  300. a=a+1
  301.  
  302. typing()
  303. term.setCursorPos(11,5)
  304. print "Ender Chest   [e]"
  305. term.setCursorPos(17,6)
  306. print "Or"
  307. term.setCursorPos(11,7)
  308. print "Normal Chests [n]"
  309. term.setCursorPos(18,9)
  310. v=read()
  311.  
  312. typing()
  313. term.setCursorPos(1,5)
  314. print "Put Ender Chest/ Normal Chests In Slot 1 and cobble in slot 2"
  315. textOutput("Press enter to start", 1, 9, 0)
  316. while true do
  317.         press, key = os.pullEvent()
  318.         if press == "key" and key == 28 then
  319.                 break
  320.         end    
  321. end
  322.  
  323. typing()
  324. term.setCursorPos(6,6)
  325. print "Clearing Your Space Master!"
  326.  
  327. door()
  328.  
  329. width()
  330.  
  331. echest2()
  332.  
  333. typing()
  334. term.setCursorPos(11,10)
  335. print "All Finished Sir."
  336. term.setCursorPos(1,6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement