Advertisement
Marum

Mermegold V4 ATM turtle autosetup

Mar 25th, 2025 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.49 KB | None | 0 0
  1. local chests = 0
  2. local barrels = 0
  3. local modems = 0
  4. local computers = 0
  5. local enderModems = 0
  6. local craftingTables = 0
  7.  
  8. function checklistItem(text, currentAmount, amountNeeded)
  9. local check = "[ ] "
  10. if (currentAmount >= amountNeeded) then
  11. check = "[x] "
  12. end
  13. print(check..text..": "..currentAmount.."/"..amountNeeded)
  14. return currentAmount >= amountNeeded
  15. end
  16.  
  17. term.clear()
  18. term.setCursorPos(1,1)
  19. print("=== Auto setup ===")
  20. print("")
  21. print("Hello! I am an ATM Assistant. I'm not the one that does customer service, but I help move and manage the stored money in an ATM. I can be a normal turtle, no need for an Advanced one.")
  22. print("")
  23. print("The ATM contraption itself requires a specific setup which I can build for you. I just need some items in my inventory.")
  24. print("")
  25. print("Press any key to continue...")
  26. os.pullEvent("key")
  27.  
  28. local requiredFuel = 8
  29. while (turtle.getFuelLevel() < requiredFuel) do
  30. term.clear()
  31. term.setCursorPos(1,1)
  32. print("First I'm going to need a bit of fuel.")
  33. print("")
  34. print("Fuel level: "..turtle.getFuelLevel().."/"..requiredFuel)
  35. print("Press any key to consume fuel...")
  36. os.pullEvent("key")
  37. print("")
  38. print("Refuelling...")
  39. for i=1, 16 do
  40. if (turtle.getFuelLevel() < requiredFuel) then
  41. while (turtle.getItemCount(i) > 0) do
  42. turtle.select(i)
  43. if (turtle.refuel(1)) then
  44. if (turtle.getFuelLevel() >= requiredFuel) then
  45. break
  46. end
  47. end
  48. end
  49. end
  50. end
  51. sleep(0.1)
  52. if (turtle.getFuelLevel() < requiredFuel) then
  53. print("I still don't have enough fuel...")
  54. sleep(2)
  55. else
  56. print("All fueled up!")
  57. sleep(1)
  58. end
  59. end
  60.  
  61. while (true) do
  62. chests = 0
  63. barrels = 0
  64. modems = 0
  65. computers = 0
  66. enderModems = 0
  67. craftingTables = 0
  68. for i=1, 16 do
  69. local item = turtle.getItemDetail(i)
  70. if (item ~= nil) then
  71. if (item.name == "minecraft:chest") then chests = chests + item.count
  72. elseif (item.name == "minecraft:barrel") then barrels = barrels + item.count
  73. elseif (item.name == "computercraft:wireless_modem_normal") then modems = modems + item.count
  74. elseif (item.name == "computercraft:wireless_modem_advanced") then enderModems = enderModems + item.count
  75. elseif (item.name == "computercraft:computer_advanced") then computers = computers + item.count
  76. elseif (item.name == "minecraft:crafting_table") then craftingTables = craftingTables + item.count
  77. end
  78. end
  79. end
  80.  
  81. local leftEquipment = peripheral.getType("left")
  82. local rightEquipment = peripheral.getType("right")
  83. if (leftEquipment == "workbench" or rightEquipment == "workbench") then
  84. craftingTables = craftingTables + 1
  85. end
  86. if (leftEquipment == "modem" or rightEquipment == "modem") then
  87. modems = modems + 1
  88. end
  89.  
  90. term.clear()
  91. term.setCursorPos(1,1)
  92.  
  93. print("What I need:")
  94. print("")
  95. local ready = true
  96. if (not checklistItem("4 chests", chests, 4)) then ready = false end
  97. if (not checklistItem("A barrel", barrels, 1)) then ready = false end
  98. if (not checklistItem("A regular modem", modems, 1)) then ready = false end
  99. if (not checklistItem("An ender modem", enderModems, 1)) then ready = false end
  100. if (not checklistItem("An advanced computer", computers, 1)) then ready = false end
  101. if (not checklistItem("A crafting table", craftingTables, 1)) then ready = false end
  102.  
  103. if (ready) then
  104. print("")
  105. print("All ready! Press any key to continue...")
  106. os.pullEvent("key")
  107. break
  108. end
  109.  
  110. while true do
  111. local event = os.pullEvent()
  112. if event == "turtle_inventory" or event == "peripheral" or event == "peripheral_detach" then
  113. break
  114. end
  115. end
  116. end
  117.  
  118. while (not fs.exists("disk")) do
  119. term.clear()
  120. term.setCursorPos(1,1)
  121. print("Please insert the installer disk into the disk drive. I need it to install a program into the computer I'm about to place.")
  122. print("Insert installer disk to continue...")
  123. os.pullEvent("disk")
  124. end
  125.  
  126. function selectItem(itemName)
  127. while (true) do
  128. for i=1, 16 do
  129. local item = turtle.getItemDetail(i)
  130. if (item ~= nil) then
  131. if (item.name == itemName) then
  132. turtle.select(i)
  133. return true
  134. end
  135. end
  136. end
  137. print("Missing item... please insert a '"..itemName.."' in my inventory to continue.")
  138. os.pullEvent("turtle_inventory")
  139. end
  140. end
  141.  
  142. function place()
  143. while (not turtle.place()) do
  144. print("Something is blocking the way in front of me")
  145. sleep(1)
  146. end
  147. end
  148.  
  149. function placeUp()
  150. while (not turtle.placeUp()) do
  151. print("Something is blocking the way above me")
  152. sleep(1)
  153. end
  154. end
  155.  
  156. function placeDown()
  157. while (not turtle.placeDown()) do
  158. print("Something is blocking the way below me")
  159. sleep(1)
  160. end
  161. end
  162.  
  163. function forward()
  164. while (not turtle.forward()) do
  165. print("Something is blocking the way in front of me")
  166. sleep(1)
  167. end
  168. end
  169.  
  170. function up()
  171. while (not turtle.up()) do
  172. print("Something is blocking the way above me")
  173. sleep(1)
  174. end
  175. end
  176.  
  177. function down()
  178. while (not turtle.down()) do
  179. print("Something is blocking the way below me")
  180. sleep(1)
  181. end
  182. end
  183.  
  184. function back()
  185. while (not turtle.back()) do
  186. print("Something is blocking the way behind me")
  187. sleep(1)
  188. end
  189. end
  190.  
  191. -- Building sequence
  192. term.clear()
  193. term.setCursorPos(1,1)
  194. print("Lets begin!")
  195.  
  196. -- Equip upgrades
  197. ---- Equip modem
  198. local leftEquipment = peripheral.getType("left")
  199. local rightEquipment = peripheral.getType("right")
  200. local hasModem = leftEquipment == "modem" or rightEquipment == "modem"
  201. if (not hasModem) then
  202. selectItem("computercraft:wireless_modem_normal")
  203. turtle.equipLeft()
  204. end
  205. ---- Equip workbench
  206. leftEquipment = peripheral.getType("left")
  207. rightEquipment = peripheral.getType("right")
  208. local hasWorkbench = leftEquipment == "workbench" or rightEquipment == "workbench"
  209. if (not hasWorkbench) then
  210. selectItem("minecraft:crafting_table")
  211. turtle.equipRight()
  212. end
  213.  
  214. local f = fs.open("disk/installATMPlease.txt", "w")
  215. f.writeLine("What are you looking at?")
  216. f.close()
  217.  
  218. back()
  219. selectItem("computercraft:computer_advanced")
  220. place()
  221. sleep(1)
  222. peripheral.call("front", "turnOn")
  223. sleep(1)
  224. up()
  225. forward()
  226. forward()
  227. down()
  228. turtle.turnRight()
  229. turtle.turnRight()
  230.  
  231. selectItem("minecraft:chest")
  232. placeDown()
  233. selectItem("minecraft:chest")
  234. placeUp()
  235.  
  236. back()
  237. selectItem("computercraft:wireless_modem_advanced")
  238. place()
  239. turtle.turnLeft()
  240. forward()
  241. turtle.turnRight()
  242. forward()
  243.  
  244. selectItem("minecraft:chest")
  245. placeDown()
  246. selectItem("minecraft:chest")
  247. placeUp()
  248. selectItem("minecraft:barrel")
  249. place()
  250.  
  251. print("Installing Mermegold ATM Assistant ...")
  252. fs.delete("bankapi.lua")
  253. shell.run("pastebin get wSKUaGG0 bankapi.lua") -- Bank API
  254. fs.delete("startup.lua")
  255. shell.run("pastebin get 32EJUy53 startup.lua") -- ATM Assistant
  256.  
  257. print("Dropping leftover items...")
  258. for i=1, 16 do
  259. if (turtle.getItemCount(i) > 0) then
  260. turtle.select(i)
  261. turtle.drop()
  262. end
  263. end
  264.  
  265. print("All done!")
  266. sleep(1)
  267. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement