Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Pastebin code: 9L63zjmY
- local bundleSide = "right"
- local mon = peripheral.wrap("bottom")
- local mX, mY = mon.getSize()
- mon.setTextScale(1)
- mon.setTextColor(colors.white)
- local button={}
- mon.setBackgroundColor(colors.black)
- --moves lift one block
- function Move( col )
- rs.setBundledOutput(bundleSide, col)
- sleep(0.1)
- rs.setBundledOutput(bundleSide, 0)
- sleep(0.9)
- end
- function checkxy(x, y)
- local activeFunc = "none"
- print(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
- data["active"] = not data["active"]
- activeFunc = name
- print(name)
- end
- end
- end
- if (activeFunc ~= "none") then
- button[activeFunc]["func"]()
- end
- 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 CreateButton(name, func, minX, minY, maxX, maxY)
- button[name] = {}
- button[name]["func"] = func
- button[name]["active"] = false
- button[name]["xmin"] = minX
- button[name]["ymin"] = minY
- button[name]["xmax"] = maxX
- button[name]["ymax"] = maxY
- end
- function SetUpButtons()
- --CreateButton("Sec", Top, 3, 2, 5, 2)
- CreateButton("B", Basement, 2, 11, 3, 11)
- CreateButton("LB", LowerBasement, 5, 11, 6, 11)
- end
- function Screen()
- local currColor
- for name,data in pairs(button) do
- local on = data["active"]
- if on == true then
- currColor = colors.lime
- else currColor = colors.red
- end
- fill(name, currColor, data)
- end
- end
- function checkxy(x, y)
- end
- SetUpButtons()
- while true do
- mon.clear()
- Screen()
- local event, side, x, y = os.pullEvent()
- if event == "monitor_touch" then
- checkxy(x, y)
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement