SHOW:
|
|
- or go back to the newest paste.
| 1 | - | os.loadAPI("manualQuarry.lua")
|
| 1 | + | |
| 2 | serverID = 0 | |
| 3 | filename = "adminsuccess.txt" | |
| 4 | cost = 160 | |
| 5 | ||
| 6 | - | print("Fuel Level: " .. turtle.getFuelLevel()/20000 .. "%")
|
| 6 | + | |
| 7 | - | print("Fuel Amount: " .. turtle.getFuelLevel())
|
| 7 | + | |
| 8 | end | |
| 9 | ||
| 10 | local function clearScreen() | |
| 11 | term.clear() | |
| 12 | term.setCursorPos(1, 1) | |
| 13 | end | |
| 14 | ||
| 15 | local function findEmptySlot() | |
| 16 | for slot = 1, 16 do | |
| 17 | if turtle.getItemDetail(slot) == nil then | |
| 18 | return slot | |
| 19 | end | |
| 20 | - | function conductTransaction(username, password) |
| 20 | + | end |
| 21 | - | message = "buy " .. username .. " " .. password .. " " .. cost |
| 21 | + | return -1 |
| 22 | end | |
| 23 | ||
| 24 | local function findItem(itemName) | |
| 25 | for slot = 1, 16 do | |
| 26 | local item = turtle.getItemDetail(slot) | |
| 27 | if item and item.name == itemName then | |
| 28 | return slot | |
| 29 | end | |
| 30 | end | |
| 31 | return -1 | |
| 32 | end | |
| 33 | ||
| 34 | function equipItem(gadget, itemname) | |
| 35 | local leftPeripheral = peripheral.getType("left")
| |
| 36 | local rightPeripheral = peripheral.getType("right")
| |
| 37 | if leftPeripheral == nil then | |
| 38 | leftPeripheral = "N/A" | |
| 39 | - | turtle.equipLeft() |
| 39 | + | slot = findEmptySlot() |
| 40 | if slot ~= -1 then | |
| 41 | turtle.select(slot) | |
| 42 | - | print("Modem not found in first slot or left hand, stopping")
|
| 42 | + | turtle.equipLeft() |
| 43 | local item = turtle.getItemDetail() | |
| 44 | if item == nil then | |
| 45 | leftPeripheral = "N/A" | |
| 46 | else | |
| 47 | - | print("Mining Turtle Rental - $" .. cost)
|
| 47 | + | leftPeripheral = item.name |
| 48 | - | print("Please Login to Rent")
|
| 48 | + | turtle.equipLeft() |
| 49 | - | print("Username: ")
|
| 49 | + | end |
| 50 | - | username = read() |
| 50 | + | else |
| 51 | - | print("Password: ")
|
| 51 | + | print("No Modem Found\n")
|
| 52 | - | password = read("*")
|
| 52 | + | print("No Empty Slots Found\n")
|
| 53 | - | if username == "admin" and password == readAdminPassword() then |
| 53 | + | print("Please insert Modem and/or empty a slot of the turtle\n")
|
| 54 | - | os.exit(1) |
| 54 | + | print("Restarting...")
|
| 55 | os.sleep(5) | |
| 56 | - | success = conductTransaction(username, password) |
| 56 | + | os.shutdown() |
| 57 | - | if success == nil then |
| 57 | + | end |
| 58 | - | print("Transaction Connection to Server Failed")
|
| 58 | + | |
| 59 | - | os.sleep(3) |
| 59 | + | if rightPeripheral == nil then |
| 60 | rightPeripheral = "N/A" | |
| 61 | - | elseif success == "false" then |
| 61 | + | slot = findEmptySlot() |
| 62 | - | print("Transaction Failed")
|
| 62 | + | if slot ~= -1 then |
| 63 | - | print("Account Value: " .. checkCredentials(username, password))
|
| 63 | + | turtle.select(slot) |
| 64 | - | os.sleep(5) |
| 64 | + | turtle.equipRight() |
| 65 | local item = turtle.getItemDetail() | |
| 66 | if item == nil then | |
| 67 | - | print("Success!")
|
| 67 | + | rightPeripheral = "N/A" |
| 68 | - | turtle.equipLeft() |
| 68 | + | else |
| 69 | - | print("Warning: Stopping the Turtle Will Complete Current Transaction (also the turtle will slightly break if it cannot break certain blocks in area)")
|
| 69 | + | rightPeripheral = item.name |
| 70 | turtle.equipRight() | |
| 71 | end | |
| 72 | else | |
| 73 | print("No Modem Found\n")
| |
| 74 | print("No Empty Slots Found\n")
| |
| 75 | print("Please insert Modem and/or empty a slot of the turtle\n")
| |
| 76 | print("Restarting...")
| |
| 77 | os.sleep(5) | |
| 78 | os.shutdown() | |
| 79 | end | |
| 80 | end | |
| 81 | slot = findItem(itemname) | |
| 82 | if slot == -1 then | |
| 83 | print(itemname .. " item not Found") | |
| 84 | os.sleep(5) | |
| 85 | return false | |
| 86 | else | |
| 87 | turtle.select(slot) | |
| 88 | if leftPeripheral == gadget then | |
| 89 | turtle.equipLeft() | |
| 90 | elseif rightPeripheral == gadget then | |
| 91 | turtle.equipRight() | |
| 92 | else | |
| 93 | if leftPeripheral == "N/A" then | |
| 94 | turtle.equipLeft() | |
| 95 | elseif rightPeripheral == "N/A" then | |
| 96 | turtle.equipRight() | |
| 97 | elseif leftPeripheral == "minecraft:diamond_pickaxe" then | |
| 98 | turtle.equipRight() | |
| 99 | elseif rightPeripheral == "minecraft:diamond_pickaxe" then | |
| 100 | turtle.equipLeft() | |
| 101 | else | |
| 102 | print("2 Pickaxes Equiped, restarting...")
| |
| 103 | os.sleep(3) | |
| 104 | return false | |
| 105 | end | |
| 106 | end | |
| 107 | end | |
| 108 | return true | |
| 109 | end | |
| 110 | ||
| 111 | function readAdminPassword() | |
| 112 | local file = fs.open(filename, "r") | |
| 113 | line = file.readLine() | |
| 114 | file.close() | |
| 115 | return line | |
| 116 | end | |
| 117 | ||
| 118 | function conductTransaction(username, password, ncost) | |
| 119 | message = "buy " .. username .. " " .. password .. " " .. ncost | |
| 120 | rednet.send(serverID, message) | |
| 121 | id, value = rednet.receive(nil, 3) | |
| 122 | os.sleep(1) | |
| 123 | return value | |
| 124 | end | |
| 125 | ||
| 126 | function checkCredentials(username, password) | |
| 127 | message = "search " .. username .. " " .. password | |
| 128 | rednet.send(serverID, message) | |
| 129 | id, value = rednet.receive(nil, 3) | |
| 130 | os.sleep(1) | |
| 131 | return value | |
| 132 | end | |
| 133 | ||
| 134 | status, err = pcall(function() openPort() end) | |
| 135 | if not status then | |
| 136 | turtle.select(1) | |
| 137 | if not equipItem("chunky", "computercraft:wireless_modem_normal") then
| |
| 138 | os.shutdown() | |
| 139 | end | |
| 140 | status, err = pcall(function() openPort() end) | |
| 141 | if not status then | |
| 142 | print("Modem not found, restarting")
| |
| 143 | os.sleep(3) | |
| 144 | os.shutdown() | |
| 145 | else | |
| 146 | print("Fuel Level: " .. math.floor(turtle.getFuelLevel()/200) .. "%")
| |
| 147 | print("Fuel Amount: " .. turtle.getFuelLevel())
| |
| 148 | buckets = 20-math.floor(turtle.getFuelLevel()/1000) | |
| 149 | print(buckets .. " Lava Buckets for 100%") | |
| 150 | print(" ")
| |
| 151 | end | |
| 152 | end | |
| 153 | ||
| 154 | function paymentCheck(success) | |
| 155 | if success == nil then | |
| 156 | print("Transaction Connection to Server Failed")
| |
| 157 | os.sleep(3) | |
| 158 | os.shutdown() | |
| 159 | elseif success == "false" then | |
| 160 | print("Transaction Failed")
| |
| 161 | print("Account Value: " .. checkCredentials(username, password))
| |
| 162 | os.sleep(5) | |
| 163 | os.shutdown() | |
| 164 | else | |
| 165 | clearScreen() | |
| 166 | print("Success!\n")
| |
| 167 | end | |
| 168 | end | |
| 169 | ||
| 170 | function login(ncost) | |
| 171 | print("Please Login to Rent")
| |
| 172 | print("Username: ")
| |
| 173 | username = read() | |
| 174 | print("Password: ")
| |
| 175 | password = read("*")
| |
| 176 | if username == "admin" and password == readAdminPassword() then | |
| 177 | os.exit(1) | |
| 178 | end | |
| 179 | success = conductTransaction(username, password, cost) | |
| 180 | paymentCheck(success) | |
| 181 | end | |
| 182 | ||
| 183 | print("Please Choose a Option to Rent:")
| |
| 184 | print("1: Basic Quarry Miner")
| |
| 185 | print("2: Repetitive Quarry Miner")
| |
| 186 | print("3: Smart Quarry Miner")
| |
| 187 | print("4: Refuel Turtle")
| |
| 188 | choice = tonumber(read()) | |
| 189 | ||
| 190 | if choice == 1 then | |
| 191 | os.loadAPI("manualQuarry.lua")
| |
| 192 | clearScreen() | |
| 193 | print("Basic Quarry Turtle Rental - $" .. cost)
| |
| 194 | login(cost) | |
| 195 | print("Transaction Completed (No going back now)\n")
| |
| 196 | print("Do not reach below depth -50\n")
| |
| 197 | print("Insert Chunk Loader Now \n")
| |
| 198 | print("Press Enter to Continue")
| |
| 199 | read() | |
| 200 | equipItem("modem", "advancedperipherals:chunk_controller")
| |
| 201 | manualQuarry.mine() | |
| 202 | os.shutdown() | |
| 203 | elseif choice == 2 then | |
| 204 | os.loadAPI("manualQuarryShaft.lua")
| |
| 205 | choice2 = 0 | |
| 206 | quarries = 0 | |
| 207 | while choice2 ~= 1 or quarries < 1 do | |
| 208 | clearScreen() | |
| 209 | print("How many quarries would you like to make? (integers only)")
| |
| 210 | quarries = math.ceil(tonumber(read())) | |
| 211 | if quarries < 1 then | |
| 212 | print("\nIncorrect Number of Quarries")
| |
| 213 | os.sleep(2) | |
| 214 | else | |
| 215 | print("\nCost would be $" .. quarries*cost)
| |
| 216 | print("Proceed? 1 for yes, 2 for no")
| |
| 217 | choice2 = tonumber(read()) | |
| 218 | end | |
| 219 | end | |
| 220 | clearScreen() | |
| 221 | print("Repetitive Quarry Miner Rental - $" .. cost*quarries)
| |
| 222 | login(cost*quarries) | |
| 223 | print("Transaction Completed (No going back now)\n")
| |
| 224 | print("Do not reach below depth -50\n")
| |
| 225 | print("Insert Chunk Loader Now \n")
| |
| 226 | print("Press Enter to Continue")
| |
| 227 | read() | |
| 228 | equipItem("modem", "advancedperipherals:chunk_controller")
| |
| 229 | clearScreen() | |
| 230 | manualQuarryShaft.quarryGetDimensions(quarries) | |
| 231 | os.shutdown() | |
| 232 | elseif choice == 3 then | |
| 233 | os.loadAPI("smartManualQuarry.lua")
| |
| 234 | clearScreen() | |
| 235 | print("Smart Quarry Turtle Rental - $" .. cost)
| |
| 236 | --login(cost) | |
| 237 | print("Transaction Completed (No going back now)\n")
| |
| 238 | print("Do not reach below depth -50\n")
| |
| 239 | print("Insert Chunk Loader Now \n")
| |
| 240 | print("Press Enter to Continue")
| |
| 241 | read() | |
| 242 | equipItem("modem", "advancedperipherals:chunk_controller")
| |
| 243 | smartManualQuarry.smartQuarry() | |
| 244 | os.shutdown() | |
| 245 | elseif choice == 4 then | |
| 246 | clearScreen() | |
| 247 | buckets = 20-math.floor(turtle.getFuelLevel()/1000) | |
| 248 | print("Fuel Level: " .. math.floor(turtle.getFuelLevel()/200) .. "%")
| |
| 249 | print("Insert " .. buckets .. " Lava Buckets and Hit Enter")
| |
| 250 | read() | |
| 251 | print("Refueling...")
| |
| 252 | os.loadAPI("turtleRefuel.lua")
| |
| 253 | else | |
| 254 | print("Input not Recognized Resetting")
| |
| 255 | end | |
| 256 | os.shutdown() | |
| 257 | ||
| 258 | ||
| 259 |