Daniel_Kerman

SmallRefuelProgram

Aug 17th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1. -- REFUEL PROGRAM --
  2.  
  3. -- Config
  4.  
  5. local areaRefuel = false -- Refuels in an area (useful for lava lakes)
  6.  
  7.  
  8.  
  9. -- Variables
  10.  
  11. local lenghtCount = 0;
  12. local widthCount = 0;
  13. local bucket = false;
  14.  
  15. -- Functions
  16.  
  17. local function clc(x,y,bc,tc)
  18.     x = x or 1;
  19.     y = y or 1;
  20.     bc = bc or colors.black;
  21.     tc = tc or colors.white;
  22.     term.setCursorPos(x,y);
  23.     term.setBackgroundColor(bc);
  24.     term.setTextColor(tc);
  25.     term.clear();
  26. end
  27.  
  28. -- STARTUP
  29.  
  30. textutils.slowPrint("Welcome to the refueler program by TheDarkray",40);
  31. sleep(0.4);
  32.  
  33. while (bucket == false) do
  34.     clc(1,1,colors.white,colors.black);
  35.     print("Please insert an empty bucket in slot 1 (top left)");
  36.     local item = turtle.getItemDetail(1);
  37.     print("If you inserted the bucket press enter to continue.");
  38.     io.read();
  39.     if (item.name == "minecraft:bucket") then
  40.         break;
  41.     end
  42. end
  43.  
  44. clc(1,1,colors.white,colors.black);
  45.     print("Please insert the distance to cover: ");
  46.     local length = io.read();
  47.     length = tonumber(length);
  48.     if (areaRefuel) then
  49.         print("Please insert the width to cover: ");
  50.         local width = io.read();
  51.         length = tonumber(width);
  52.     end
  53.  
  54.  
  55.  
  56. -- MAIN PROGRAM
  57. turtle.forward();
  58. turtle.select(1);
  59. if (areaRefuel) then
  60.     for i = 0, math.ceil(width/2) do
  61.         for i = 0, length do
  62.             turtle.attack();
  63.             turtle.placeDown();
  64.             turtle.refuel();
  65.             turtle.forward();
  66.             turtle.dig();
  67.         end
  68.         turtle.turnLeft(); turtle.back(); turtle.turnLeft();
  69.         for i = 0, length do
  70.             turtle.attack();
  71.             turtle.placeDown();
  72.             turtle.refuel();
  73.             turtle.forward();
  74.             turtle.dig();
  75.         end
  76.         turtle.turnLeft();
  77.         turtle.forward();
  78.         turtle.turnLeft();
  79.     end
  80.     turtle.turnLeft();
  81.     for i = 0, width do
  82.         turtle.placeDown();
  83.         turtle.refuel();
  84.         turtle.forward();
  85.         turtle.dig();
  86.     end
  87.     turtle.turnRight();
  88. else
  89.     for i = 0, length do
  90.         turtle.attack();
  91.         turtle.dig();
  92.         turtle.forward();
  93.         turtle.placeDown();
  94.         turtle.refuel();
  95.     end
  96.     turtle.turnLeft(); turtle.back(); turtle.turnLeft();
  97.     for i = 0, length do
  98.         turtle.attack();
  99.         turtle.placeDown();
  100.         turtle.refuel();
  101.         turtle.forward();
  102.         turtle.dig();
  103.     end
  104.         turtle.turnRight();
  105.         turtle.placeDown();
  106.         turtle.refuel();
  107.         turtle.forward();
  108.         turtle.dig();
  109.     turtle.turnRight();
  110. end
  111. turtle.back();
  112. clc(1,1,colors.white,colors.black);
  113. print("REFUELING COMPLETE");
  114. print("FUEL LEVEL: "..turtle.getFuelLevel().."/"..turtle.getFuelLimit());
  115. sleep(1);
  116. clc();
Advertisement
Add Comment
Please, Sign In to add comment