Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Edit]]--
- local mon = peripheral.find("monitor") --Name of monitor as peripheral
- local spawner = peripheral.find("auto_spawner") --Name of spawner as peripheral
- local chest = peripheral.find("diamond") --Name of chest as peripheral
- local header = "Currently Spawning: " --Appears at the top of the screen
- local chestDirection = "south" --From spawner: north, south, east, west, up, down
- local spawnerDirection = "north" --From chest: north, south, east, west, up, down
- local witherSkeletonEggName = "WitherS" --Whatever you name your wither skeleton safari net, this automatically activates exact mode when inserted into the spawner
- local showWarning = true --Shows the warning while loading
- local lightsOnDefault = true --if true, turns the lights on when restarted
- local grinderOnDefault = true --if true, turns the grinders on when restarted
- local spawnOnDefault = false --if true, begins spawning immediately after a restart
- local beginAgain = true --if true when showing the mob list, will revert to page 1 rather than resuming from the last page open --[[DOESNT affect a restart]]--
- local config = "config" --Name of the configuration file, used when saving/loading options
- local configAutoload = true
- local useRednetAPI = true
- if useRednetAPI then
- rednetSide = "left"
- lightsColor = colors.red --Redstone control for lights: colors api names
- grinderColor = colors.green --Redstone control for grinder: colors api names
- spawnerColor = colors.brown --Redstone control for spawner: colors api names
- else
- lightsSide = "right" --Redstone control for lights: front, left, back, right, up, down
- grinderSide = "top" --Redstone control for grinders: front, left, back, right, up, down
- spawnerSide = "back" --Redstone control for spawner: front, left, back, right, up, down
- end
- --[[Debug]]--
- local showFound = false --Print to the computer what has been found in the chest inventory
- local showSetup = true
- --[[Do no edit unless you know what you are doing]]--
- local mobPos = {}
- local totalCount = 0
- local npp = 12
- local pages = 0
- local pageNum = 1
- function APILoader(apiName, apiPastebin)
- os.unloadAPI(apiName)
- if fs.exists(apiName) then
- os.loadAPI(apiName)
- else
- shell.run("pastebin","get",apiPastebin,apiName)
- os.loadAPI(apiName)
- end
- end
- function clear()
- mon.clear()
- mon.setCursorPos(1, 1)
- button.clearTable()
- end
- function heading(page)
- if page == "main" then
- if spawner.getStackInSlot(1) == nil then
- button.heading(header)
- else
- button.heading(header..spawner.getStackInSlot(1).display_name)
- end
- end
- if page == "options" then
- button.heading("Options: Green - True, Red - False")
- end
- end
- function setupMainMenu()
- heading("main")
- if useRednetAPI then
- --button.setTable("Exact", toggleExact, "", "", spawner.getSpawnExact(), 3, 13, 7, 9)
- button.setTable("Mob List", list, "yes", "", false, 15, 25, 3, 5)
- button.setTable("Remove", removeEgg, "", "", false, 27, 37, 3, 5)
- button.setTable("Exact", toggleExact, "", "", spawner.getSpawnExact(), 3, 13, 7, 9)
- button.setTable("Grinders", redstone, "grinder", "", not colors.test(rs.getBundledOutput(rednetSide), grinderColor), 15, 25, 7, 9)
- button.setTable("Lights", redstone, "lights", "", colors.test(rs.getBundledOutput(rednetSide), lightsColor), 27, 37, 7, 9)
- --button.setTable("Exact", toggleExact, "", "", spawner.getSpawnExact(), 3, 13, 11, 13)
- button.setTable("Tank", tankInfo, "", "", false, 15, 25, 11, 13)
- --button.setTable("Lights", redstone, "lights", "", colors.test(rs.getBundledOutput(rednetSide), lightsColor), 27, 37, 11, 13)
- button.setTable("Spawn", redstone, "spawn", "", not colors.test(rs.getBundledOutput(rednetSide), spawnerColor), 3, 13, 15, 17)
- button.setTable("Options", setupOptionsMenu, "yes", "", false, 15, 25, 15, 17)
- button.setTable("Reboot", os.reboot, "", "", false, 27, 37, 15, 17)
- else
- --button.setTable("Exact", toggleExact, "", "", spawner.getSpawnExact(), 3, 13, 7, 9)
- button.setTable("Mob List", list, "yes", "", false, 15, 25, 3, 5)
- button.setTable("Remove", removeEgg, "", "", false, 27, 37, 3, 5)
- button.setTable("Exact", toggleExact, "", "", spawner.getSpawnExact(), 3, 13, 7, 9)
- button.setTable("Grinders", redstone, "grinder", "", not rs.getOutput(grinderSide), 15, 25, 7, 9)
- button.setTable("Lights", redstone, "lights", "", rs.getOutput(lightsSide), 27, 37, 7, 9)
- --button.setTable("Exact", toggleExact, "", "", spawner.getSpawnExact(), 3, 13, 11, 13)
- button.setTable("Tank", tank, "", "", false, 15, 25, 11, 13)
- --button.setTable("Lights", redstone, "lights", "", colors.test(rs.getBundledOutput(rednetSide), lightsColor), 27, 37, 11, 13)
- button.setTable("Spawn", redstone, "spawn", "", not rs.getOutput(spawnerSide), 3, 13, 15, 17)
- button.setTable("Options", setupOptionsMenu, "yes", "", false, 15, 25, 15, 17)
- button.setTable("Reboot", os.reboot, "", "", false, 27, 37, 15, 17)
- end
- button.screen()
- end
- function setupOptionsMenu(answer)
- if answer == "yes" then button.flash("Options") end
- clear()
- heading("options")
- button.setTable("Warning", options, "warning", "", showWarning, 3, 13, 3, 5)
- button.setTable("Lights", options, "lights", "", lightsOnDefault, 15, 25, 3, 5)
- button.setTable("Grinders", options, "grinder", "", grinderOnDefault, 27, 37, 3, 5)
- button.setTable("Spawning", options, "spawner", "", spawnOnDefault, 3, 13, 7, 9)
- button.setTable("Begin Again", options, "again", "", beginAgain, 15, 25, 7, 9)
- button.setTable("Del Config", options, "delconfig", "", false, 15, 25, 11, 13)
- button.setTable("Save", gamestate, "save", "options", false, 3, 13, 15, 17)
- button.setTable("Load", gamestate, "load", "options", false, 27, 37, 15, 17)
- button.setTable("Return", back, "", "", false, 15, 25, 15, 17)
- button.screen()
- end
- function tankInfo()
- button.flash("Tank")
- clear()
- tank = spawner.getTankInfo()
- button.heading(tank[1].contents.amount.."mBs of "..tank[1].contents.rawName.." out of "..tank[1].capacity.."mBs.")
- button.screen()
- sleep(2)
- clear()
- setupMainMenu()
- end
- function gamestate(state, menu)
- clear()
- if state == "save" then
- file = fs.open(config, "w")
- button.label(5, 5, "Saving: ")
- sleep(0.4)
- file.writeLine(showWarning)
- button.label(5, 7, "Show Warning: Done")
- sleep(0.4)
- file.writeLine(lightsOnDefault)
- button.label(5, 9, "Lights On by Default: Done")
- sleep(0.4)
- file.writeLine(grinderOnDefault)
- button.label(5, 11, "Grinder On by Default: Done")
- sleep(0.4)
- file.writeLine(spawnOnDefault)
- button.label(5, 13, "Start Spawning by Default: Done")
- sleep(0.4)
- file.writeLine(beginAgain)
- button.label(5, 15, "Begin Again: Done")
- sleep(0.4)
- button.label(5, 17, "Done! Saved as "..config)
- file.close()
- sleep(1)
- end
- if state == "load" and fs.exists(config) then
- file = fs.open(config, "r")
- button.label(5, 5, "Loading: ")
- sleep(0.4)
- if file.readLine() == "true" then showWarning = true else showWarning = false end
- if showSetup then print("Show warning: "..tostring(showWarning)) end
- button.label(5, 7, "Show Warning: Done")
- sleep(0.4)
- if useRednetAPI then
- --Lights
- if file.readLine() == "true" then
- lightsOnDefault = true
- rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), lightsColor))
- else
- lightsOnDefault = false
- rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), lightsColor))
- end
- if showSetup then print("Lights Default: "..tostring(lightsOnDefault)) end
- button.label(5, 9, "Lights On by Default: Done")
- sleep(0.4)
- --Grinder
- if file.readLine() == "true" then
- grinderOnDefault = true
- rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), grinderColor))
- else
- grinderOnDefault = false
- rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), grinderColor))
- end
- if showSetup then print("Grinder Default: "..tostring(grinderOnDefault)) end
- button.label(5, 11, "Grinder On by Default: Done")
- sleep(0.4)
- --Spawner
- if file.readLine() == "true" then
- spawnOnDefault = true
- rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), spawnerColor))
- else
- spawnOnDefault = false
- rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), spawnerColor))
- end
- if showSetup then print("Spawning Default: "..tostring(spawnOnDefault)) end
- button.label(5, 13, "Start Spawning by Default: Done")
- sleep(0.4)
- else
- --Lights
- if file.readLine() == "true" then lightsOnDefault = true else lightsOnDefault = false end
- rs.setOutput(lightsSide, lightsOnDefault)
- if showSetup then print("Lights Default: "..tostring(lightsOnDefault)) end
- button.label(5, 9, "Lights On by Default: Done")
- sleep(0.4)
- --Grinder
- if file.readLine() == "true" then grinderOnDefault = true else grinderOnDefault = false end
- rs.setOutput(grinderSide, not grinderOnDefault)
- if showSetup then print("Grinder Default: "..tostring(grinderOnDefault)) end
- button.label(5, 11, "Grinder On by Default: Done")
- sleep(0.4)
- --Spawner
- if file.readLine() == "true" then spawnOnDefault = true else spawnOnDefault = false end
- rs.setOutput(spawnerSide, not spawnOnDefault)
- if showSetup then print("Spawning Default: "..tostring(spawnOnDefault)) end
- button.label(5, 13, "Start Spawning by Default: Done")
- sleep(0.4)
- end
- if file.readLine() == "true" then beginAgain = true else beginAgain = false end
- if showSetup then print("Begin again: "..tostring(beginAgain)) end
- button.label(5, 15, "Begin Again: Done")
- sleep(0.4)
- button.label(5, 17, "Done! "..config.." loaded!")
- file.close()
- sleep(1)
- end
- if menu == "options" then setupOptionsMenu() end
- if menu == "main" then setupMainMenu() end
- if menu == "check" then button.heading("Checking mobs...") end
- end
- function options(option)
- if option == "warning" then
- showWarning = not showWarning
- end
- if option == "lights" then
- lightsOnDefault = not lightsOnDefault
- end
- if option == "grinder" then
- grinderOnDefault = not grinderOnDefault
- end
- if option == "spawner" then
- spawnOnDefault = not spawnOnDefault
- end
- if option == "again" then
- beginAgain = not beginAgain
- end
- if option == "delconfig" then
- button.flash("Del Config")
- if fs.exists(config) then fs.delete(config) end
- end
- sleep(0.2)
- setupOptionsMenu()
- end
- function redstone(object)
- if useRednetAPI then
- if object == "lights" then
- if colors.test(rs.getBundledOutput(rednetSide), lightsColor) then
- rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), lightsColor))
- else
- rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), lightsColor))
- end
- end
- if object == "grinder" then
- if colors.test(rs.getBundledOutput(rednetSide), grinderColor) then
- rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), grinderColor))
- else
- rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), grinderColor))
- end
- end
- if object == "spawn" then
- if colors.test(rs.getBundledOutput(rednetSide), spawnerColor) then
- rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), spawnerColor))
- else
- rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), spawnerColor))
- end
- end
- else
- if object == "lights" then
- rs.setOutput(lightsSide, not rs.getOutput(lightsSide))
- end
- if object == "grinder" then
- rs.setOutput(grinderSide, not rs.getOutput(grinderSide))
- end
- if object == "spawn" then
- rs.setOutput(spawnerSide, not rs.getOutput(spawnerSide))
- end
- end
- sleep(0.2)
- --clear()
- setupMainMenu()
- end
- function clearNreset()
- clear()
- setupMainMenu()
- end
- function toggleExact()
- spawner.setSpawnExact(not spawner.getSpawnExact())
- clear()
- setupMainMenu()
- end
- function removeEgg()
- button.flash("Remove")
- if spawner.getStackInSlot(1).display_name == witherSkeletonEggName then
- spawner.setSpawnExact(false)
- end
- chest.pullItemIntoSlot(spawnerDirection, 1)
- clear()
- button.heading("Re-checking mobs...")
- checkMobs()
- clear()
- setupMainMenu()
- end
- function insert(slot)
- if chest.getStackInSlot(slot).display_name == witherSkeletonEggName then
- spawner.setSpawnExact(true)
- else
- spawner.setSpawnExact(false)
- end
- chest.pullItemIntoSlot(spawnerDirection, 1)
- spawner.pullItemIntoSlot(chestDirection, slot)
- clear()
- setupMainMenu()
- end
- function back(answer)
- button.flash("Return")
- clear()
- setupMainMenu()
- if beginAgain == true and answer == "yes" then pageNum = 1 end
- end
- function page(dir)
- if dir == "prev" then
- button.flash("<")
- if pageNum - 1 >= 1 then
- pageNum = pageNum - 1
- end
- end
- if dir == "next" then
- button.flash(">")
- if pageNum + 1 <= pages then
- pageNum = pageNum + 1
- end
- end
- clear()
- list()
- end
- function loading()
- clear()
- button.heading("Loading...")
- button.screen()
- end
- function list(answer)
- if answer == "yes" then button.flash("Mob List") end
- loading()
- checkMobs()
- clear()
- heading("main")
- if pageNum == 1 then
- k = 0
- j = 0
- for i = 1, 12 do
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 2 then
- k = 0
- j = 0
- for i = 13, 24 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 3 then
- k = 0
- j = 0
- for i = 25, 16 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 4 then
- k = 0
- j = 0
- for i = 37, 48 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 5 then
- k = 0
- j = 0
- for i = 49, 60 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 6 then
- k = 0
- j = 0
- for i = 61, 72 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 7 then
- k = 0
- j = 0
- for i = 73, 84 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 8 then
- k = 0
- j = 0
- for i = 85, 96 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 9 then
- k = 0
- j = 0
- for i = 97, 100 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- if pageNum == 10 then
- k = 0
- j = 0
- for i = 101, 112 do
- next(mobPos, 11)
- if k == 16 and j == 0 then
- j = 12
- k = 0
- end
- if k == 16 and j == 12 then
- j = 24
- k = 0
- end
- if k == 16 and j == 24 then
- break
- end
- button.setTable(mobPos[i].mob, insert, i, "", false, 3+j, 13+j, 3+k, 5+k)
- k = k + 4
- end
- end
- button.remTable("Empty")
- button.setTable("<", page, "prev", "", false, 15, 19, 19, 20)
- button.setTable(">", page, "next", "", false, 21, 25, 19, 20)
- button.setTable("Return", back, "yes", "", false, 3, 13, 19, 20)
- button.label(28, 19, "Page "..pageNum.." of "..pages)
- button.screen()
- end
- function warn()
- button.label(5, 5, "The more slots an inventory has,")
- button.label(5, 7, "the longer it will take to load!")
- button.label(5, 10, "Every safari net needs to be")
- button.label(5, 12, "renamed in an Anvil to show up!")
- end
- function checkMobs()
- u = 0
- for i = 1, chest.getInventorySize() do
- mobPos[i] = {}
- u = u + 1
- if chest.getStackInSlot(i) == nil then
- mobPos[i]["mob"] = "Empty"
- u = u - 1
- else
- mobPos[i]["mob"] = chest.getStackInSlot(i).display_name
- end
- if showFound == true then
- for name, data in pairs(mobPos) do
- print("Found: "..data.mob)
- end
- end
- end
- totalRows = u
- pages = math.ceil(totalRows/npp)
- end
- function checkPress()
- event, side, x, y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- APILoader("button","S8x0K3ui")
- clear()
- if showWarning == true then warn() end
- if useRednetAPI == true then
- if lightsOnDefault == true then rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), lightsColor)) else rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), lightsColor)) end
- if grinderOnDefault == true then rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), grinderColor)) else rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), grinderColor)) end
- if spawnOnDefault == true then rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), spawnerColor)) else rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), spawnerColor)) end
- else
- if lightsOnDefault == true then rs.setOutput(lightsSide, true) else rs.setOutput(lightsSide, false) end
- if grinderOnDefault == true then rs.setOutput(grinderSide, false) else rs.setOutput(grinderSide, true) end
- if spawnOnDefault == true then rs.setOutput(spawnerSide, false) else rs.setOutput(spawnerSide, true) end
- end
- if configAutoload == true and fs.exists(config) == true then gamestate("load", "check") else button.label(5, 16, "To enable autoload you must have a") button.label(5, 18, "config saved! *Enable in file*") end
- checkMobs()
- clear()
- setupMainMenu()
- while true do
- checkPress()
- end
Advertisement
Add Comment
Please, Sign In to add comment