Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local chests = 0
- local barrels = 0
- local modems = 0
- local computers = 0
- local enderModems = 0
- local craftingTables = 0
- function checklistItem(text, currentAmount, amountNeeded)
- local check = "[ ] "
- if (currentAmount >= amountNeeded) then
- check = "[x] "
- end
- print(check..text..": "..currentAmount.."/"..amountNeeded)
- return currentAmount >= amountNeeded
- end
- term.clear()
- term.setCursorPos(1,1)
- print("=== Auto setup ===")
- print("")
- 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.")
- print("")
- print("The ATM contraption itself requires a specific setup which I can build for you. I just need some items in my inventory.")
- print("")
- print("Press any key to continue...")
- os.pullEvent("key")
- local requiredFuel = 8
- while (turtle.getFuelLevel() < requiredFuel) do
- term.clear()
- term.setCursorPos(1,1)
- print("First I'm going to need a bit of fuel.")
- print("")
- print("Fuel level: "..turtle.getFuelLevel().."/"..requiredFuel)
- print("Press any key to consume fuel...")
- os.pullEvent("key")
- print("")
- print("Refuelling...")
- for i=1, 16 do
- if (turtle.getFuelLevel() < requiredFuel) then
- while (turtle.getItemCount(i) > 0) do
- turtle.select(i)
- if (turtle.refuel(1)) then
- if (turtle.getFuelLevel() >= requiredFuel) then
- break
- end
- end
- end
- end
- end
- sleep(0.1)
- if (turtle.getFuelLevel() < requiredFuel) then
- print("I still don't have enough fuel...")
- sleep(2)
- else
- print("All fueled up!")
- sleep(1)
- end
- end
- while (true) do
- chests = 0
- barrels = 0
- modems = 0
- computers = 0
- enderModems = 0
- craftingTables = 0
- for i=1, 16 do
- local item = turtle.getItemDetail(i)
- if (item ~= nil) then
- if (item.name == "minecraft:chest") then chests = chests + item.count
- elseif (item.name == "minecraft:barrel") then barrels = barrels + item.count
- elseif (item.name == "computercraft:wireless_modem_normal") then modems = modems + item.count
- elseif (item.name == "computercraft:wireless_modem_advanced") then enderModems = enderModems + item.count
- elseif (item.name == "computercraft:computer_advanced") then computers = computers + item.count
- elseif (item.name == "minecraft:crafting_table") then craftingTables = craftingTables + item.count
- end
- end
- end
- local leftEquipment = peripheral.getType("left")
- local rightEquipment = peripheral.getType("right")
- if (leftEquipment == "workbench" or rightEquipment == "workbench") then
- craftingTables = craftingTables + 1
- end
- if (leftEquipment == "modem" or rightEquipment == "modem") then
- modems = modems + 1
- end
- term.clear()
- term.setCursorPos(1,1)
- print("What I need:")
- print("")
- local ready = true
- if (not checklistItem("4 chests", chests, 4)) then ready = false end
- if (not checklistItem("A barrel", barrels, 1)) then ready = false end
- if (not checklistItem("A regular modem", modems, 1)) then ready = false end
- if (not checklistItem("An ender modem", enderModems, 1)) then ready = false end
- if (not checklistItem("An advanced computer", computers, 1)) then ready = false end
- if (not checklistItem("A crafting table", craftingTables, 1)) then ready = false end
- if (ready) then
- print("")
- print("All ready! Press any key to continue...")
- os.pullEvent("key")
- break
- end
- while true do
- local event = os.pullEvent()
- if event == "turtle_inventory" or event == "peripheral" or event == "peripheral_detach" then
- break
- end
- end
- end
- while (not fs.exists("disk")) do
- term.clear()
- term.setCursorPos(1,1)
- 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.")
- print("Insert installer disk to continue...")
- os.pullEvent("disk")
- end
- function selectItem(itemName)
- while (true) do
- for i=1, 16 do
- local item = turtle.getItemDetail(i)
- if (item ~= nil) then
- if (item.name == itemName) then
- turtle.select(i)
- return true
- end
- end
- end
- print("Missing item... please insert a '"..itemName.."' in my inventory to continue.")
- os.pullEvent("turtle_inventory")
- end
- end
- function place()
- while (not turtle.place()) do
- print("Something is blocking the way in front of me")
- sleep(1)
- end
- end
- function placeUp()
- while (not turtle.placeUp()) do
- print("Something is blocking the way above me")
- sleep(1)
- end
- end
- function placeDown()
- while (not turtle.placeDown()) do
- print("Something is blocking the way below me")
- sleep(1)
- end
- end
- function forward()
- while (not turtle.forward()) do
- print("Something is blocking the way in front of me")
- sleep(1)
- end
- end
- function up()
- while (not turtle.up()) do
- print("Something is blocking the way above me")
- sleep(1)
- end
- end
- function down()
- while (not turtle.down()) do
- print("Something is blocking the way below me")
- sleep(1)
- end
- end
- function back()
- while (not turtle.back()) do
- print("Something is blocking the way behind me")
- sleep(1)
- end
- end
- -- Building sequence
- term.clear()
- term.setCursorPos(1,1)
- print("Lets begin!")
- -- Equip upgrades
- ---- Equip modem
- local leftEquipment = peripheral.getType("left")
- local rightEquipment = peripheral.getType("right")
- local hasModem = leftEquipment == "modem" or rightEquipment == "modem"
- if (not hasModem) then
- selectItem("computercraft:wireless_modem_normal")
- turtle.equipLeft()
- end
- ---- Equip workbench
- leftEquipment = peripheral.getType("left")
- rightEquipment = peripheral.getType("right")
- local hasWorkbench = leftEquipment == "workbench" or rightEquipment == "workbench"
- if (not hasWorkbench) then
- selectItem("minecraft:crafting_table")
- turtle.equipRight()
- end
- local f = fs.open("disk/installATMPlease.txt", "w")
- f.writeLine("What are you looking at?")
- f.close()
- back()
- selectItem("computercraft:computer_advanced")
- place()
- sleep(1)
- peripheral.call("front", "turnOn")
- sleep(1)
- up()
- forward()
- forward()
- down()
- turtle.turnRight()
- turtle.turnRight()
- selectItem("minecraft:chest")
- placeDown()
- selectItem("minecraft:chest")
- placeUp()
- back()
- selectItem("computercraft:wireless_modem_advanced")
- place()
- turtle.turnLeft()
- forward()
- turtle.turnRight()
- forward()
- selectItem("minecraft:chest")
- placeDown()
- selectItem("minecraft:chest")
- placeUp()
- selectItem("minecraft:barrel")
- place()
- print("Installing Mermegold ATM Assistant ...")
- fs.delete("bankapi.lua")
- shell.run("pastebin get wSKUaGG0 bankapi.lua") -- Bank API
- fs.delete("startup.lua")
- shell.run("pastebin get 32EJUy53 startup.lua") -- ATM Assistant
- print("Dropping leftover items...")
- for i=1, 16 do
- if (turtle.getItemCount(i) > 0) then
- turtle.select(i)
- turtle.drop()
- end
- end
- print("All done!")
- sleep(1)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement