Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = peripheral.wrap("top")
- term.setTextScale(1.5)
- local mob={}
- function setTable(name, freq, xmin, xmax, ymin, ymax)
- mob[name] = {}
- mob[name]["freq"] = freq
- mob[name]["active"] = false
- mob[name]["xmin"] = xmin
- mob[name]["ymin"] = ymin
- mob[name]["xmax"] = xmax
- mob[name]["ymax"] = ymax
- end
- function fillTable()
- setTable("Chicken", colors.red, 17, 24, 2, 3)
- setTable("Cow", colors.white, 17, 20, 6, 7)
- setTable("Pig", colors.yellow, 17, 20, 4, 5)
- end
- function fill(x,y,color,text)
- term.setBackgroundColor(color)
- term.setCursorPos(x,y)
- term.write(text)
- term.setBackgroundColor(colors.black)
- end
- function screen()
- local y = 2
- local currColor
- for name,data in pairs(mob) do
- local on = data["active"]
- if on == true then currColor = colors.lime else currColor = colors.red end
- fill(17,y,currColor, name)
- y = y+2
- end
- end
- function checkxy(x, y)
- for name, data in pairs(mob) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- data["active"] = not data["active"]
- print(name)
- end
- end
- end
- end
- function setWire()
- local wire = 0
- for name, data in pairs(mob) do
- if data["active"] == false then
- wire = colors.combine(wire, data["freq"])
- end
- end
- redstone.setBundledOutput("bottom", wire)
- end
- fillTable()
- setWire()
- while true do
- term.clear()
- screen()
- -- fill(17,2,colors.lime, "Chicken")
- local e,side,x,y = os.pullEvent("monitor_touch")
- print(x..":"..y)
- checkxy(x,y)
- setWire()
- sleep(.1)
- end
Add Comment
Please, Sign In to add comment