Advertisement
gravitowl

wall tunnel builder

Mar 20th, 2023
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. local TUNNEL_HEIGHT = 5;
  2. local TUNNEL_BLOCK = "minecraft:stone";
  3. local TUNNEL_CORNER = "minecraft:stone_stairs";
  4. local USE_CORNER = false;
  5. local CORNER_IS_STAIR = false;
  6.  
  7. local function findItem(itemName)
  8. for i = 1, 16, 1 do
  9. local item = turtle.getItemDetail(i);
  10.  
  11. if item.name == itemName then return i end;
  12. end
  13.  
  14. return -1;
  15. end
  16.  
  17. local function refuel()
  18.  
  19. end
  20.  
  21. local function splashScreen()
  22. term.clear();
  23. term.setCursorPos(0,0);
  24. term.write(string.rep("-", 39, ""));
  25.  
  26. for i = 1, 5, 1 do
  27. term.setCursorPos(1, i);
  28. term.setCursorPos(38, i);
  29. end
  30.  
  31. term.write("| |")
  32. term.write("| TUNNEL WALL BUILDER |")
  33. term.write("| |")
  34. term.write("| |")
  35. term.write("| |")
  36.  
  37.  
  38. term.write(string.rep("-", 39, ""));
  39. end
  40.  
  41. local function getTunnelInfo()
  42. local done = false;
  43.  
  44. while not done do
  45. term.write("What height does your tunnel wall have? (leave empty for default)");
  46. local input = read();
  47.  
  48. if input == "" then
  49. done = true;
  50. goto continue;
  51. end
  52.  
  53. local numberInput = tonumber(input);
  54. if numberInput == nil or numberInput < 3 then
  55. term.write("Please use a valid integer of 3 and above, i have no use for this!");
  56. goto continue;
  57. end
  58.  
  59. TUNNEL_HEIGHT = math.floor(numberInput);
  60. done = true;
  61.  
  62. ::continue::
  63. end
  64. term.write("Great! Using " .. TUNNEL_HEIGHT .. " as the tunnel height!");
  65.  
  66. while not done do
  67. term.write("What block should i use for the wall?");
  68. local input = read();
  69.  
  70. if input ~= "" then
  71. TUNNEL_BLOCK = input;
  72. end
  73.  
  74.  
  75. local foundItem = findItem(TUNNEL_BLOCK);
  76. if foundItem == -1 then
  77. term.write("I can't find this block, could you please insert the specified block? " .. TUNNEL_BLOCK .. ".");
  78. goto continue;
  79. else
  80. done = true;
  81. goto continue;
  82. end
  83.  
  84. ::continue::
  85. end
  86. term.write("Great! Using " .. TUNNEL_BLOCK .. " as the wall block.")
  87.  
  88. term.write("Do you want to use a corner block? (Y/n)");
  89. local input = read();
  90. if string.lower(input) == "y" or string.lower(input) == "yes" then
  91. USE_CORNER = true;
  92. else
  93. term.write("I'll make the tunnel as square as possible!");
  94. goto skip_corner;
  95. end
  96.  
  97. term.write("Now i'll need some more information about the corner block.");
  98.  
  99. while not done do
  100. term.write("What block should i used for the corner?");
  101. local input = read();
  102.  
  103. if input ~= "" then
  104. TUNNEL_CORNER = input;
  105. end
  106.  
  107.  
  108. local foundItem = findItem(TUNNEL_CORNER);
  109. if foundItem == -1 then
  110. term.write("I can't find this block, could you please insert the specified block? " .. TUNNEL_CORNER .. ".");
  111. goto continue;
  112. else
  113. done = true;
  114. goto continue;
  115. end
  116.  
  117. ::continue::
  118. end
  119. term.write("I'll place " .. TUNNEL_CORNER .. " in the corners! ");
  120.  
  121. term.write("Is this block a stair, or should it be treated as one? (Y/n)");
  122. local input = read();
  123. if string.lower(input) == "y" or string.lower(input) == "yes" then
  124. CORNER_IS_STAIR = true;
  125. term.write("I'll treat the corner block as a stair, and turn it around!");
  126. else
  127. term.write("Less work for me!");
  128. goto skip_corner;
  129. end
  130.  
  131. ::skip_corner::
  132.  
  133. term.write("I have all the information i need to get started working on this wall, thanks!");
  134. end
  135.  
  136. local function main()
  137. splashScreen();
  138. end
  139.  
  140. main();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement