Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Mob Control Panel
- --]]
- local mon = peripheral.wrap("top")
- mon.setTextScale(1)
- mon.setTextColor(colors.white)
- local button={}
- mon.setBackgroundColor(colors.black)
- rednet.open("bottom")
- wireside = "back"
- rs.setBundledOutput(wireside,0)
- function setInvertTable(name, func, xmin, xmax, ymin, ymax)
- button[name] = {}
- button[name]["func"] = func
- button[name]["active"] = true
- button[name]["xmin"] = xmin
- button[name]["ymin"] = ymin
- button[name]["xmax"] = xmax
- button[name]["ymax"] = ymax
- end
- function setTable(name, func, xmin, xmax, ymin, ymax)
- button[name] = {}
- button[name]["func"] = func
- button[name]["active"] = false
- button[name]["xmin"] = xmin
- button[name]["ymin"] = ymin
- button[name]["xmax"] = xmax
- button[name]["ymax"] = ymax
- end
- --setwire
- function setwire (side, nColors, value)
- current = redstone.getBundledOutput(side)
- if onoff then
- rs.setBundledOutput(side, colors.subtract(current, nColors))
- else
- rs.setBundledOutput(side, colors.combine(current, nColors))
- end
- end
- -- ====== WIRES ======
- function white()
- setwire(wireside, colors.white, onoff)
- end
- function orange()
- setwire(wireside, colors.orange, onoff)
- end
- function magenta()
- setwire(wireside, colors.magenta, onoff)
- end
- function lightblue()
- setwire(wireside, colors.lightBlue, onoff)
- end
- function yellow()
- setwire(wireside, colors.yellow, onoff)
- end
- function lime()
- setwire(wireside, colors.lime, onoff)
- end
- function pink()
- setwire(wireside, colors.pink, onoff)
- end
- function gray()
- setwire(wireside, colors.gray, onoff)
- end
- function lightgray()
- setwire(wireside, colors.lightGray, onoff)
- end
- function cyan()
- setwire(wireside, colors.cyan, onoff)
- end
- function purple()
- setwire(wireside, colors.purple, onoff)
- end
- function blue()
- setwire(wireside, colors.blue, onoff)
- end
- function brown()
- setwire(wireside, colors.brown, onoff)
- end
- function green()
- setwire(wireside, colors.green, onoff)
- end
- function red()
- setwire(wireside, colors.red, onoff)
- end
- function black()
- setwire(wireside, colors.black, onoff)
- end
- --[[ Button layout Map
- A, B, C, D
- A B
- | |
- C----+-------+----C
- | |
- D-----------------D
- | |
- A B
- --]]
- --Current layout requires a 5x3 advanced monitor setup
- function fillTable()
- setInvertTable("Enderman", white, 5, 23, 3, 5)
- setInvertTable("Enderman2", orange, 5, 23, 7, 9)
- setInvertTable("WitherSkelly", magenta, 5, 23, 11, 13)
- setInvertTable("Pigman", lightblue, 5, 23, 15, 17)
- --[[ Not enough room with a 5x3 setup
- setTable("Yellow", yellow, 5, 23, 19, 21)
- setTable("Lime", lime, 5, 23, 23, 25)
- setTable("Pink", pink, 5, 23, 27, 29)
- setTable("Gray", gray, 5, 23, 31, 33)
- --]]
- setTable("Lightgray", lightgray, 28, 46, 3, 5)
- setTable("Cyan", cyan, 28, 46, 7, 9)
- setTable("Refill Mob Essence", purple, 28, 46, 11, 13)
- setTable("Toggle Floor", blue, 28, 46, 15, 17)
- --[[Not enough room with a 5x3 setup
- setTable("Brown", brown, 28, 46, 19, 21)
- setTable("Green", green, 28, 46, 23, 25)
- setTable("Red", red, 28, 46, 27, 29)
- setTable("Black", black, 28, 46, 31, 33)
- --]]
- end
- function fill(text, color, bData)
- mon.setBackgroundColor(color)
- local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
- local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
- for j = bData["ymin"], bData["ymax"] do
- mon.setCursorPos(bData["xmin"], j)
- if j == yspot then
- for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
- if k == xspot then
- mon.write(text)
- else
- mon.write(" ")
- end
- end
- else
- for i = bData["xmin"], bData["xmax"] do
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function screen()
- local currColor
- for name,data in pairs(button) do
- local on = data["active"]
- if on == true
- then currColor = colors.lime
- rednet.broadcast("ON")
- else currColor = colors.red
- rednet.broadcast("OFF")
- end
- fill(name, currColor, data)
- end
- end
- function checkxy(x, y)
- for name, data in pairs(button) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- -- print(data["active"])
- onoff = data["active"]
- data["func"]()
- data["active"] = not data["active"]
- onoff = data["active"]
- -- print(data["active"])
- -- print(name)
- end
- end
- end
- end
- function heading(text)
- w, h = mon.getSize()
- mon.setCursorPos((w-string.len(text))/2+1, 1)
- mon.write(text)
- end
- fillTable()
- while true do
- mon.clear()
- heading("Stravides Mob Farm Control Panel")
- screen()
- local e,side,x,y = os.pullEvent("monitor_touch")
- print(x..":"..y)
- checkxy(x,y)
- sleep(.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment