Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("top")
- mon.setTextScale(2)
- mon.setTextColor(colors.white)
- local button={}
- mon.setBackgroundColor(colors.black)
- local cb = peripheral.wrap("right")
- function setTable(warp, name, xmin, xmax, ymin, ymax)
- button[warp] = {}
- button[warp]["warp"] = warp
- button[warp]["name"] = name
- button[warp]["active"] = false
- button[warp]["xmin"] = xmin
- button[warp]["ymin"] = ymin
- button[warp]["xmax"] = xmax
- button[warp]["ymax"] = ymax
- end
- function fill(color, bData)
- mon.setBackgroundColor(color)
- local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
- local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(bData["name"])) /2) +1
- local xspot2 = math.floor((bData["xmax"] - bData["xmin"] - string.len(bData["warp"])) /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(bData["name"]) +1 do
- if k == xspot then
- mon.write(bData["name"])
- else
- mon.write(" ")
- end
- end
- elseif j == bData["ymax"] then
- for k = 0, bData["xmax"] - bData["xmin"] - string.len(bData["warp"]) + 1 do
- if k == xspot2 then
- mon.write(bData["warp"])
- 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 z,data in pairs(button) do
- if data["name"] == "vide" then
- currColor = colors.red
- else
- currColor = colors.lime
- end
- fill(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
- cb.setCommand("warps " .. data["warp"] .. " @p[c=1]")
- cb.runCommand()
- return true
- end
- end
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement