Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- local m = peripheral.wrap("right")
- local rsOut = {}
- local c = peripheral.wrap("ender_chest_1")
- local s = peripheral.wrap("auto_spawner_1")
- m.clear()
- local mobArray = {}
- local buttonColors = {}
- local page = 1
- local pages = 0
- local currMob = ""
- function fillMainTable()
- getCurrMob()
- checkExact()
- m.clear()
- button.clearTable()
- button.setTable("Top Lights", tLights, "", 4, 17, 2, 4)
- button.setTable("Bottom Lights", bLights, "", 20, 33, 2, 4)
- button.setTable("Top Grinder", tGrinder, "", 4, 17, 6, 8)
- button.setTable("Main Grinders", mGrinders, "", 20, 33, 6, 8)
- button.setTable("Spawner", spawner, "", 4, 17, 10, 12)
- button.setTable("Mob Selector", mobSelect, "", 20, 33, 10, 12)
- --button.setTable("Refresh", refresh, "", 15, 35, 19, 19)
- print("Filled")
- button.screen()
- for i,j in pairs(buttonColors) do
- if not rsOut[j] then button.toggleButton(i) end
- end
- button.label(1, 19, "Current Mob: "..currMob)
- button.label(30, 19, "Exact: "..currExact)
- end
- function fillTable()
- checkMobs()
- checkExact()
- getCurrMob()
- m.clear()
- button.clearTable()
- local totalrows = 0
- local npp = 12 --names per page
- local numNames = 0
- local col = 2
- local row = 12
- local countRow = 1
- local currName = 0
- for i,j in pairs(mobArray) do
- totalrows = totalrows+1
- end
- pages = math.ceil(totalrows/npp)
- print(totalrows)
- for name,slot in pairs(mobArray) do
- currName = currName + 1
- if currName > npp*(page-1) and currName < npp*page+1 then
- row = 4+(countRow)
- button.setTable(string.sub(name, 0, 17), insertMob, slot, col, col+17 , row, row)
- if col == 21 then
- col = 2
- countRow = countRow + 2
- else
- col = col+19
- end
- end
- end
- button.setTable("Next Page", nextPage, "", 27, 38, 1, 1)
- button.setTable("Prev Page", prevPage, "", 2, 13, 1, 1)
- button.setTable("Main Menu", goMainMenu, "", 15, 25, 1, 1)
- button.setTable("Exact: "..currExact, switchExact, "", 21, 38, 18, 19)
- button.setTable("Remove Mob", removeMob, "", 2, 19, 18, 19)
- button.screen()
- button.label(15,3, "Page: "..tostring(page).." of "..tostring(pages))
- button.label(12, 16, "Current Mob: "..currMob)
- end
- function getCurrMob()
- data = s.getStackInSlot(1)
- if data then
- currMob = data.display_name
- else
- currMob = "None"
- end
- end
- function goMainMenu()
- fillMainTable()
- -- refresh()
- end
- function checkExact()
- if s.getSpawnExact() then
- currExact = "Yes"
- else
- currExact = "No"
- end
- end
- function switchExact()
- s.setSpawnExact(not s.getSpawnExact())
- fillTable()
- end
- function nextPage()
- if page+1 <= pages then
- page = page+1
- end
- fillTable()
- sleep(0.25)
- end
- function prevPage()
- if page-1 >= 1 then page = page-1 end
- fillTable()
- sleep(0.25)
- end
- function getMobs()
- mobArray = {}
- for i = 1,27 do
- if c.getStackInSlot(i) then
- data = c.getStackInSlot(i)
- --print(i..":"..data.display_name)
- mobArray[data.display_name] = i
- end
- end
- end
- function findEmptySlot()
- for i = 1,27 do
- if not c.getStackInSlot(i) then
- return(i)
- end
- end
- end
- function removeMob()
- local slot = findEmptySlot()
- c.pullItem("up", 1, 1, slot)
- end
- function insertMob(info)
- removeMob()
- c.pushItem("up", info, 1, 1)
- fillTable()
- end
- function checkMobs()
- getMobs()
- --fillTable()
- end
- function initRS()
- rsOut[colors.white] = true
- rsOut[colors.orange] = true
- rsOut[colors.magenta] = false
- rsOut[colors.lightBlue] = false
- rsOut[colors.yellow] = false
- buttonColors["Top Lights"] = colors.white
- buttonColors["Bottom Lights"] = colors.orange
- buttonColors["Top Grinder"] = colors.magenta
- buttonColors["Main Grinders"] = colors.lightBlue
- buttonColors["Spawner"] = colors.yellow
- end
- function setRS()
- local colorOutput = 0
- for i,j in pairs(rsOut) do
- if j then colorOutput = colorOutput + i end
- end
- rs.setBundledOutput("back", colorOutput)
- end
- function tLights()
- button.toggleButton("Top Lights")
- rsOut[colors.white] = not rsOut[colors.white]
- setRS()
- end
- function bLights()
- button.toggleButton("Bottom Lights")
- rsOut[colors.orange] = not rsOut[colors.orange]
- setRS()
- end
- function tGrinder()
- button.toggleButton("Top Grinder")
- rsOut[colors.magenta] = not rsOut[colors.magenta]
- setRS()
- end
- function mGrinders()
- button.toggleButton("Main Grinders")
- rsOut[colors.lightBlue] = not rsOut[colors.lightBlue]
- setRS()
- end
- function spawner()
- button.toggleButton("Spawner")
- rsOut[colors.yellow] = not rsOut[colors.yellow]
- setRS()
- end
- function mobSelect()
- fillTable()
- refresh()
- -- getClick()
- end
- function getClick()
- local event,side,x,y = os.pullEvent()
- if event=="monitor_touch" then
- button.checkxy(x,y)
- end
- end
- function refresh()
- m.clear()
- print("Refreshed")
- button.screen()
- end
- initRS()
- setRS()
- fillMainTable()
- --refresh()
- while true do getClick() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement