Advertisement
TechManDylan

CharcoalMan

Jan 28th, 2023 (edited)
774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.38 KB | None | 0 0
  1. -- Start name setting section
  2. function checkLabel()
  3.   label = os.getComputerLabel()
  4.     if label then
  5.       print("Already has the name : "..label)
  6.     else
  7.       print("Does not have name")
  8.       print("Setting name to CoalMan")
  9.       os.setComputerLabel("CoalMan")
  10.   end
  11. end
  12. -- End name setting section
  13.  
  14.  
  15. -- Start Find Item function
  16.  
  17. function findItem(name)
  18.   for i=1,16 do
  19.     if turtle.getItemCount(i) > 0 then
  20.       local data = turtle.getItemDetail(i)
  21.       if data and data.name == name then
  22.         return i
  23.       end
  24.     end
  25.   end
  26.   return nil
  27. end
  28.  
  29. -- End Find Item Function
  30.  
  31. -- Start Place block function
  32.  
  33. function placeBlock(name)
  34.   local slot = findItem(name)
  35.   if slot then
  36.     turtle.select(slot)
  37.     turtle.placeDown()
  38.     return true
  39.   else
  40.     print("Error: block not found in inventory.")
  41.     return false
  42.   end
  43. end
  44.  
  45.  
  46. -- End Place block function
  47.  
  48. -- Start moveTo() function
  49.  
  50. local currX, currZ = 0, 0
  51.  
  52. function moveTo(x, z)
  53.   local facing = 0  -- 0 = north, 1 = east, 2 = south, 3 = west
  54.  
  55.   -- turn to face the positive X direction
  56.   while facing ~= 1 do
  57.     turtle.turnRight()
  58.     facing = (facing + 1) % 4
  59.   end
  60.  
  61.   -- move the turtle along the positive X axis until it reaches the target X coordinate
  62.   while currX ~= x do
  63.     if x > currX then
  64.       turtle.forward()
  65.       currX = currX + 1
  66.     else
  67.       turtle.back()
  68.       currX = currX - 1
  69.     end
  70.   end
  71.  
  72.   -- turn to face the positive Z direction
  73.   while facing ~= 0 do
  74.     turtle.turnRight()
  75.     facing = (facing + 1) % 4
  76.   end
  77.  
  78.   -- move the turtle along the positive Z axis until it reaches the target Z coordinate
  79.   while currZ ~= z do
  80.     if z > currZ then
  81.       turtle.forward()
  82.       currZ = currZ + 1
  83.     else
  84.       turtle.back()
  85.       currZ = currZ - 1
  86.     end
  87.   end
  88. end
  89.  
  90. -- End moveTo() function
  91.  
  92.  
  93.  
  94. -- Start requests materials for build.  
  95.  
  96. checkLabel()
  97.  
  98. -- Start Build code
  99.  
  100. turtle.up()
  101. moveTo(9, 9)
  102. placeBlock("minecraft:cobblestone")
  103. moveTo(8, 9)
  104. placeBlock("minecraft:cobblestone")
  105. moveTo(7, 9)
  106. placeBlock("minecraft:cobblestone")
  107. moveTo(6, 9)
  108. placeBlock("minecraft:cobblestone")
  109. moveTo(5, 9)
  110. placeBlock("minecraft:cobblestone")
  111. moveTo(5, 8)
  112. placeBlock("minecraft:cobblestone")
  113. moveTo(6, 8)
  114. placeBlock("minecraft:cobblestone")
  115. moveTo(7, 8)
  116. placeBlock("minecraft:cobblestone")
  117. moveTo(8, 8)
  118. placeBlock("minecraft:cobblestone")
  119. moveTo(9, 8)
  120. placeBlock("minecraft:cobblestone")
  121. moveTo(9, 7)
  122. redstone.setOutput("bottom", true)
  123. placeBlock("minecraft:hopper")
  124. moveTo(8, 7)
  125. redstone.setOutput("bottom", false)
  126. placeBlock("minecraft:cobblestone")
  127. moveTo(7, 7)
  128. placeBlock("minecraft:cobblestone")
  129. moveTo(6, 7)
  130. placeBlock("minecraft:cobblestone")
  131. moveTo(5, 7)
  132. placeBlock("minecraft:cobblestone")
  133. moveTo(5, 6)
  134. placeBlock("minecraft:cobblestone")
  135. moveTo(6, 6)
  136. placeBlock("minecraft:cobblestone")
  137. moveTo(7, 6)
  138. placeBlock("minecraft:cobblestone")
  139. moveTo(8, 6)
  140. placeBlock("minecraft:cobblestone")
  141. moveTo(9, 6)
  142. placeBlock("minecraft:cobblestone")
  143. moveTo(9, 5)
  144. placeBlock("minecraft:cobblestone")
  145. moveTo(8, 5)
  146. placeBlock("minecraft:cobblestone")
  147. moveTo(7, 5)
  148. placeBlock("minecraft:cobblestone")
  149. moveTo(6, 5)
  150. placeBlock("minecraft:cobblestone")
  151. moveTo(5, 5)
  152. placeBlock("minecraft:cobblestone")
  153. turtle.up()
  154. moveTo(4, 5)
  155. placeBlock("minecraft:cobblestone")
  156. moveTo(4, 6)
  157. placeBlock("minecraft:cobblestone")
  158. moveTo(4, 7)
  159. placeBlock("minecraft:cobblestone")
  160. moveTo(4, 8)
  161. placeBlock("minecraft:cobblestone")
  162. moveTo(4, 9)
  163. placeBlock("minecraft:cobblestone")
  164. moveTo(5, 10)
  165. placeBlock("minecraft:cobblestone")
  166. moveTo(6, 10)
  167. placeBlock("minecraft:cobblestone")
  168. moveTo(7, 10)
  169. placeBlock("minecraft:cobblestone")
  170. moveTo(8, 10)
  171. placeBlock("minecraft:cobblestone")
  172. moveTo(9, 10)
  173. placeBlock("minecraft:cobblestone")
  174. moveTo(10, 9)
  175. placeBlock("minecraft:cobblestone")
  176. moveTo(10, 8)
  177. placeBlock("minecraft:cobblestone")
  178. moveTo(10, 7)
  179. placeBlock("minecraft:cobblestone")
  180. moveTo(10, 6)
  181. placeBlock("minecraft:cobblestone")
  182. moveTo(10, 5)
  183. placeBlock("minecraft:cobblestone")
  184. moveTo(9, 4)
  185. placeBlock("minecraft:cobblestone")
  186. moveTo(8, 4)
  187. placeBlock("minecraft:cobblestone")
  188. moveTo(7, 4)
  189. placeBlock("minecraft:cobblestone")
  190. moveTo(6, 4)
  191. placeBlock("minecraft:cobblestone")
  192. moveTo(5, 4)
  193. placeBlock("minecraft:cobblestone")
  194. turtle.up()
  195. moveTo(7, 7)
  196. placeBlock("minecraft:dirt")
  197. turtle.up()
  198. placeBlock("minecraft:spruce_sapling")
  199.  
  200. -- End build code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement