SHOW:
|
|
- or go back to the newest paste.
| 1 | ------------------------------- | |
| 2 | -- MurderBot -- | |
| 3 | -- by improvshark -- | |
| 4 | -- -- | |
| 5 | ------------------------------- | |
| 6 | ||
| 7 | enableMonitor = peripheral.isPresent("bottom")
| |
| 8 | ||
| 9 | local xp = peripheral.wrap("right")
| |
| 10 | ||
| 11 | local monitor = peripheral.wrap("bottom")
| |
| 12 | ||
| 13 | ||
| 14 | ||
| 15 | done = false | |
| 16 | autoEnchant = false | |
| 17 | ||
| 18 | if enableMonitor == true then | |
| 19 | print(monitor.getSize()) | |
| 20 | end | |
| 21 | ||
| 22 | function full() | |
| 23 | for i=1, 16 do | |
| 24 | if turtle.getItemCount(i) < 1 then | |
| 25 | return false | |
| 26 | end | |
| 27 | end | |
| 28 | return true | |
| 29 | end | |
| 30 | ||
| 31 | function drop() | |
| 32 | for i=1, 15 do | |
| 33 | turtle.select(i) | |
| 34 | turtle.drop() | |
| 35 | end | |
| 36 | end | |
| 37 | ||
| 38 | function read() | |
| 39 | local timeout = os.startTimer(2) | |
| 40 | local sEvent, param = os.pullEvent() | |
| 41 | if sEvent == 'timer' and param == timeout then | |
| 42 | -- do nothing | |
| 43 | elseif sEvent == "key" then | |
| 44 | return param | |
| 45 | end | |
| 46 | end | |
| 47 | ||
| 48 | function printFarm() | |
| 49 | --terminal | |
| 50 | term.clear() | |
| 51 | term.setCursorPos(1,1) | |
| 52 | print("---------------------------------------")
| |
| 53 | print(" _ ")
| |
| 54 | print(" |V| __ _| _ __ o __ (_| ")
| |
| 55 | print(" | ||_| | (_|(/_ | | | |__| ")
| |
| 56 | print(" ")
| |
| 57 | print(" ")
| |
| 58 | print(" lv: " .. xp.getLevels())
| |
| 59 | print(" ")
| |
| 60 | if autoEnchant == false then | |
| 61 | print(" ")
| |
| 62 | else | |
| 63 | print(" Auto Enchant Enabled ")
| |
| 64 | end | |
| 65 | print(" ")
| |
| 66 | print("---------------------------------------")
| |
| 67 | print(" Press M To Switch Modes or E for auto ")
| |
| 68 | if enableMonitor == true then | |
| 69 | --monitor | |
| 70 | monitor.clear() | |
| 71 | monitor.setCursorPos(1,3) | |
| 72 | monitor.write("lv: "..xp.getLevels())
| |
| 73 | if autoEnchant == true then | |
| 74 | --monitor | |
| 75 | monitor.setCursorPos(2,4) | |
| 76 | monitor.write("Auto")
| |
| 77 | end | |
| 78 | end | |
| 79 | ||
| 80 | end | |
| 81 | ||
| 82 | function printEnchant() | |
| 83 | --terminal | |
| 84 | term.clear() | |
| 85 | term.setCursorPos(1,1) | |
| 86 | print("---------------------------------------")
| |
| 87 | print(" __ _ ")
| |
| 88 | print(" |_ __ _ |_ _ __ _|_ o __ (_| ")
| |
| 89 | print(" |__| |(_ | |(_|| | |_ | | |__| ")
| |
| 90 | print(" ")
| |
| 91 | print(" ")
| |
| 92 | print(" lv:" .. limit)
| |
| 93 | print(" Enchant item lv:" ..selection)
| |
| 94 | print(" ")
| |
| 95 | print("-------------key-Bindings--------------")
| |
| 96 | print("change level: arrowkeys ")
| |
| 97 | print("enchant: enter ")
| |
| 98 | ||
| 99 | if enableMonitor == true then | |
| 100 | --monitor | |
| 101 | monitor.clear() | |
| 102 | monitor.setCursorPos(1,3) | |
| 103 | monitor.write("ENCHANT")
| |
| 104 | end | |
| 105 | ||
| 106 | end | |
| 107 | ||
| 108 | function dropLoot() | |
| 109 | if full() then | |
| 110 | turtle.turnRight() | |
| 111 | drop() | |
| 112 | turtle.turnLeft() | |
| 113 | end | |
| 114 | end | |
| 115 | ||
| 116 | function enchant() | |
| 117 | done = false | |
| 118 | turtle.turnRight() | |
| 119 | drop() | |
| 120 | turtle.select(1) | |
| 121 | turtle.turnLeft() | |
| 122 | limit = xp.getLevels() | |
| 123 | selection = limit | |
| 124 | ||
| 125 | while done == false do | |
| 126 | printEnchant() | |
| 127 | button = read() | |
| 128 | --up arrow | |
| 129 | if button == 200 then | |
| 130 | if selection < limit then | |
| 131 | selection = selection + 1 | |
| 132 | end | |
| 133 | end | |
| 134 | ||
| 135 | --down arrow | |
| 136 | if button == 208 then | |
| 137 | if selection > 1 then | |
| 138 | selection = selection - 1 | |
| 139 | end | |
| 140 | end | |
| 141 | ||
| 142 | --enter | |
| 143 | if button == 28 then | |
| 144 | -- shell.run("enchant", selection)
| |
| 145 | xp.enchant(selection) | |
| 146 | limit = xp.getLevels() | |
| 147 | print("lv: " .. xp.getLevels())
| |
| 148 | turtle.drop() | |
| 149 | print("done")
| |
| 150 | os.sleep(1) | |
| 151 | end | |
| 152 | ||
| 153 | --m | |
| 154 | if button == 50 then | |
| 155 | term.clear() | |
| 156 | term.setCursorPos(1,1) | |
| 157 | print("---------------------------------------")
| |
| 158 | print(" _ ")
| |
| 159 | print(" |V| __ _| _ __ o __ (_| ")
| |
| 160 | print(" | ||_| | (_|(/_ | | | |__| ")
| |
| 161 | done = true | |
| 162 | end | |
| 163 | ||
| 164 | end | |
| 165 | end | |
| 166 | ||
| 167 | function farm() | |
| 168 | button = read() | |
| 169 | --e | |
| 170 | if button == 18 then | |
| 171 | if autoEnchant == false then | |
| 172 | autoEnchant = true | |
| 173 | printFarm() | |
| 174 | elseif autoEnchant == true then | |
| 175 | autoEnchant = false | |
| 176 | printFarm() | |
| 177 | end | |
| 178 | end | |
| 179 | ||
| 180 | if button == 50 then | |
| 181 | term.clear() | |
| 182 | term.setCursorPos(1,1) | |
| 183 | print("---------------------------------------")
| |
| 184 | print(" __ _ ")
| |
| 185 | print(" |_ __ _ |_ _ __ _|_ o __ (_| ")
| |
| 186 | print(" |__| |(_ | |(_|| | |_ | | |__| ")
| |
| 187 | enchant() | |
| 188 | end | |
| 189 | ||
| 190 | if autoEnchant == false then | |
| 191 | turtle.attackUp() | |
| 192 | turtle.attack() | |
| 193 | -- os.sleep(1) | |
| 194 | xp.collect() | |
| 195 | printFarm() | |
| 196 | dropLoot() | |
| 197 | xp.collect() | |
| 198 | elseif autoEnchant == true then | |
| 199 | turtle.attackUp() | |
| 200 | turtle.attack() | |
| 201 | -- os.sleep(1) | |
| 202 | xp.collect() | |
| 203 | printFarm() | |
| 204 | dropLoot() | |
| 205 | xp.collect() | |
| 206 | if (xp.getLevels() >= 30) then | |
| 207 | turtle.turnRight() | |
| 208 | drop() | |
| 209 | turtle.select(16) | |
| 210 | turtle.transferTo(1, 1) | |
| 211 | turtle.select(1) | |
| 212 | --shell.run("enchant", 30)
| |
| 213 | xp.enchant(30) | |
| 214 | turtle.drop() | |
| 215 | turtle.turnLeft() | |
| 216 | ||
| 217 | end | |
| 218 | end | |
| 219 | end | |
| 220 | ||
| 221 | ||
| 222 | function main() | |
| 223 | while true do | |
| 224 | farm() | |
| 225 | end | |
| 226 | end | |
| 227 | ||
| 228 | main() |