Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("top")
- mouseWidth = 0
- mouseHeight = 0
- mon.setTextScale(0.5)
- button = {}
- button["x"] = {3,3,3,3}
- button["length"] = {53,53,53,53}
- button["y"] = {3,7,11,15}
- button["height"] = {3,3,3,3}
- button["txt"] = {"Hallway Lights","zombie","skeleton","bill"}
- button["state"] = {0,0,0,0}
- button["colour"] = {colors.white, colors.orange, colors.orange,colors.blue}
- button["side"] = {"left","left","right","left"}
- function clear()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- end
- clear()
- function setTable()
- for i = 1,#button["x"] do
- if button["state"][i] == 1 then
- mon.setBackgroundColor(colors.white)
- else
- mon.setBackgroundColor(colors.gray)
- end
- for y = 0, button["height"][i] - 1 do
- mon.setCursorPos(button["x"][i], button["y"][i] + y)
- mon.write(string.rep(" ",button["length"][i]))
- end
- buttonX = button["x"][i] + ((button["length"][i] - string.len(button["txt"][i])) / 2)
- print(buttonX)
- mon.setCursorPos(buttonX, button["y"][i] + 1)
- mon.setTextColor(colors.black)
- mon.write(button["txt"][i])
- end
- end
- setTable()
- function Redstone()
- rs.setBundledOutput("back",0)
- for i = 1,#button["state"] do
- if button["state"][i] == 1 then
- rs.setBundledOutput(button["side"][i],colors.combine(rs.getBundledOutput(button["side"][i]),button["colour"][i]))
- else
- rs.setBundledOutput(button["side"][i],colors.subtract(rs.getBundledOutput(button["side"][i]),button["colour"][i]))
- end
- end
- end
- Redstone()
- function BP()
- for i = 1,#button["x"] do
- if mouseWidth > button["x"][i] - 1 and mouseWidth < (button["length"][i] + button["x"][i]) and mouseHeight > button["y"][i] - 1 and mouseHeight < (button["height"][i] + button["y"][i] + 1) then
- button["state"][i] = button["state"][i] + 1
- if button["state"][i] >= 2 then
- button["state"][i] = 0
- end
- end
- setTable()
- Redstone()
- end
- end
- function Press()
- repeat
- event,p1,p2,p3 = os.pullEvent()
- if event=="monitor_touch" then
- mouseWidth = p2
- mouseHeight = p3
- BP()
- end
- until event=="char" and p1==("x")
- end
- Press()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement