Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- serverID = 0
- filename = "adminsuccess.txt"
- cost = 160
- function openPort()
- rednet.open("left")
- end
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local function findEmptySlot()
- for slot = 1, 16 do
- if turtle.getItemDetail(slot) == nil then
- return slot
- end
- end
- return -1
- end
- local function findItem(itemName)
- for slot = 1, 16 do
- local item = turtle.getItemDetail(slot)
- if item and item.name == itemName then
- return slot
- end
- end
- return -1
- end
- function equipItem(gadget, itemname)
- local leftPeripheral = peripheral.getType("left")
- local rightPeripheral = peripheral.getType("right")
- if leftPeripheral == nil then
- leftPeripheral = "N/A"
- slot = findEmptySlot()
- if slot ~= -1 then
- turtle.select(slot)
- turtle.equipLeft()
- local item = turtle.getItemDetail()
- if item == nil then
- leftPeripheral = "N/A"
- else
- leftPeripheral = item.name
- turtle.equipLeft()
- end
- else
- print("No Modem Found\n")
- print("No Empty Slots Found\n")
- print("Please insert Modem and/or empty a slot of the turtle\n")
- print("Restarting...")
- os.sleep(5)
- os.shutdown()
- end
- end
- if rightPeripheral == nil then
- rightPeripheral = "N/A"
- slot = findEmptySlot()
- if slot ~= -1 then
- turtle.select(slot)
- turtle.equipRight()
- local item = turtle.getItemDetail()
- if item == nil then
- rightPeripheral = "N/A"
- else
- rightPeripheral = item.name
- turtle.equipRight()
- end
- else
- print("No Modem Found\n")
- print("No Empty Slots Found\n")
- print("Please insert Modem and/or empty a slot of the turtle\n")
- print("Restarting...")
- os.sleep(5)
- os.shutdown()
- end
- end
- slot = findItem(itemname)
- if slot == -1 then
- print(itemname .. " item not Found")
- os.sleep(5)
- return false
- else
- turtle.select(slot)
- if leftPeripheral == gadget then
- turtle.equipLeft()
- elseif rightPeripheral == gadget then
- turtle.equipRight()
- else
- if leftPeripheral == "N/A" then
- turtle.equipLeft()
- elseif rightPeripheral == "N/A" then
- turtle.equipRight()
- elseif leftPeripheral == "minecraft:diamond_pickaxe" then
- turtle.equipRight()
- elseif rightPeripheral == "minecraft:diamond_pickaxe" then
- turtle.equipLeft()
- else
- print("2 Pickaxes Equiped, restarting...")
- os.sleep(3)
- return false
- end
- end
- end
- return true
- end
- function readAdminPassword()
- local file = fs.open(filename, "r")
- line = file.readLine()
- file.close()
- return line
- end
- function conductTransaction(username, password, ncost)
- message = "buy " .. username .. " " .. password .. " " .. ncost
- rednet.send(serverID, message)
- id, value = rednet.receive(nil, 3)
- os.sleep(1)
- return value
- end
- function checkCredentials(username, password)
- message = "search " .. username .. " " .. password
- rednet.send(serverID, message)
- id, value = rednet.receive(nil, 3)
- os.sleep(1)
- return value
- end
- status, err = pcall(function() openPort() end)
- if not status then
- turtle.select(1)
- if not equipItem("chunky", "computercraft:wireless_modem_normal") then
- os.shutdown()
- end
- status, err = pcall(function() openPort() end)
- if not status then
- print("Modem not found, restarting")
- os.sleep(3)
- os.shutdown()
- else
- print("Fuel Level: " .. math.floor(turtle.getFuelLevel()/200) .. "%")
- print("Fuel Amount: " .. turtle.getFuelLevel())
- buckets = 20-math.floor(turtle.getFuelLevel()/1000)
- print(buckets .. " Lava Buckets for 100%")
- print(" ")
- end
- end
- function paymentCheck(success)
- if success == nil then
- print("Transaction Connection to Server Failed")
- os.sleep(3)
- os.shutdown()
- elseif success == "false" then
- print("Transaction Failed")
- print("Account Value: " .. checkCredentials(username, password))
- os.sleep(5)
- os.shutdown()
- else
- clearScreen()
- print("Success!\n")
- end
- end
- function login(ncost)
- print("Please Login to Rent")
- print("Username: ")
- username = read()
- print("Password: ")
- password = read("*")
- if username == "admin" and password == readAdminPassword() then
- os.exit(1)
- end
- success = conductTransaction(username, password, cost)
- paymentCheck(success)
- end
- print("Please Choose a Option to Rent:")
- print("1: Basic Quarry Miner")
- print("2: Repetitive Quarry Miner")
- print("3: Smart Quarry Miner")
- print("4: Refuel Turtle")
- choice = tonumber(read())
- if choice == 1 then
- os.loadAPI("manualQuarry.lua")
- clearScreen()
- print("Basic Quarry Turtle Rental - $" .. cost)
- login(cost)
- print("Transaction Completed (No going back now)\n")
- print("Do not reach below depth -50\n")
- print("Insert Chunk Loader Now \n")
- print("Press Enter to Continue")
- read()
- equipItem("modem", "advancedperipherals:chunk_controller")
- manualQuarry.mine()
- os.shutdown()
- elseif choice == 2 then
- os.loadAPI("manualQuarryShaft.lua")
- choice2 = 0
- quarries = 0
- while choice2 ~= 1 or quarries < 1 do
- clearScreen()
- print("How many quarries would you like to make? (integers only)")
- quarries = math.ceil(tonumber(read()))
- if quarries < 1 then
- print("\nIncorrect Number of Quarries")
- os.sleep(2)
- else
- print("\nCost would be $" .. quarries*cost)
- print("Proceed? 1 for yes, 2 for no")
- choice2 = tonumber(read())
- end
- end
- clearScreen()
- print("Repetitive Quarry Miner Rental - $" .. cost*quarries)
- login(cost*quarries)
- print("Transaction Completed (No going back now)\n")
- print("Do not reach below depth -50\n")
- print("Insert Chunk Loader Now \n")
- print("Press Enter to Continue")
- read()
- equipItem("modem", "advancedperipherals:chunk_controller")
- clearScreen()
- manualQuarryShaft.quarryGetDimensions(quarries)
- os.shutdown()
- elseif choice == 3 then
- os.loadAPI("smartManualQuarry.lua")
- clearScreen()
- print("Smart Quarry Turtle Rental - $" .. cost)
- --login(cost)
- print("Transaction Completed (No going back now)\n")
- print("Do not reach below depth -50\n")
- print("Insert Chunk Loader Now \n")
- print("Press Enter to Continue")
- read()
- equipItem("modem", "advancedperipherals:chunk_controller")
- smartManualQuarry.smartQuarry()
- os.shutdown()
- elseif choice == 4 then
- clearScreen()
- buckets = 20-math.floor(turtle.getFuelLevel()/1000)
- print("Fuel Level: " .. math.floor(turtle.getFuelLevel()/200) .. "%")
- print("Insert " .. buckets .. " Lava Buckets and Hit Enter")
- read()
- print("Refueling...")
- os.loadAPI("turtleRefuel.lua")
- else
- print("Input not Recognized Resetting")
- end
- os.shutdown()
Add Comment
Please, Sign In to add comment