Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local spawners = {"Cow", "Evoker", "Witch", "Blaze", "Enderman", "Spider", "Ghast"}
- local controlColors = {
- colors.white,
- colors.orange,
- colors.magenta,
- colors.lightBlue,
- colors.yellow,
- colors.lime,
- colors.pink,
- colors.gray
- }
- local activeMap = {}
- for i=1, #spawners+1 do
- activeMap[i] = false
- end
- activeMap[#spawners+1] = true
- local monitor = peripheral.wrap("right")
- function check(active)
- if active then return "[O]" else return "[ ]" end
- end
- function checkAllActive()
- local aa = true
- for i=1, #spawners do
- aa = aa and activeMap[i]
- end
- return aa
- end
- function updateUi()
- monitor.clear()
- monitor.setTextScale(0.5)
- monitor.setCursorPos(1,1)
- monitor.write(" Spawn Control")
- monitor.setCursorPos(1,3)
- monitor.write(check(activeMap[#spawners+1]) .. " Grinders")
- for i, monster in ipairs(spawners) do
- monitor.setCursorPos(1, i*2+6)
- monitor.write(check(activeMap[i]) .. " " .. monster)
- end
- monitor.setCursorPos(1, 6)
- monitor.write(check(checkAllActive()) .. " All")
- end
- function handleAllClick()
- local isAllActive = not checkAllActive()
- for i=1, #spawners do
- activeMap[i] = isAllActive
- end
- end
- function updateOutput()
- local activeColors = {}
- for i, active in ipairs(activeMap) do
- if active then table.insert(activeColors, controlColors[i]) end
- end
- rs.setBundledOutput("left", colors.combine(unpack(activeColors)))
- end
- updateUi()
- updateOutput()
- while true do
- local _, _, _, y = os.pullEvent("monitor_touch")
- if y == 3 then activeMap[#spawners+1] = not activeMap[#spawners+1] end
- if y == 6 then handleAllClick() end
- local item = (y - 6) / 2
- if math.floor(item) == item and item <= #spawners then activeMap[item] = not activeMap[item] end
- updateUi()
- updateOutput()
- end
Advertisement
Add Comment
Please, Sign In to add comment