Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- nCursor = 1
- defColour = colours.white
- defBgColour = colours.black
- defBorderColour = colors.white
- tSize = {term.getSize()}
- tMenu = {
- {name="Cruor's building", colour=colours.lightBlue},
- {name="Empty", colour=colours.white},
- {name="Empty", colour=colours.white}
- }
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function output(text, posX, posY, colour, bgColour)
- if colour then
- term.setTextColour(colour)
- else
- term.setTextColour(defColour)
- end
- if bgColour then
- term.setBackgroundColour(bgColour)
- else
- term.setBackgroundColour(defBgColour)
- end
- if tostring(posX) == "center" then
- term.setCursorPos((tSize[1]/2)-(#text/2), posY)
- else
- term.setCursorPos(posX, posY)
- end
- term.write(text)
- end
- function clearBackground()
- clear()
- for i=1, tSize[2] do
- for k=1, tSize[1] do
- output(" ", k, i, nil, defBgColour)
- end
- end
- end
- function printBorder()
- clear()
- for i=1, tSize[1] do
- output(" ", i, 1, nil, defBorderColour)
- end
- for i=1, tSize[1] do
- output(" ", i, tSize[2], nil, defBorderColour)
- end
- for i=1, tSize[2] do
- output(" ", 1, i, nil, defBorderColour)
- end
- for i=1, tSize[2] do
- output(" ", tSize[1], i, nil, defBorderColour)
- end
- output("Spawn Teleport Pad", "center", 1, colours.black, colors.white)
- end
- function redraw()
- clearBackground()
- printBorder()
- if #tMenu > tSize[2]-2 then
- -- Scroll bar stuff here
- else
- local nStartY = (tSize[2]/2-2)-(#tMenu/2)+1
- local h = nStartY
- for i=1, #tMenu do
- output(tMenu[i].name, "center", h, tMenu[i].colour)
- h = h + 1
- end
- output("[", (tSize[1]/2)-(#tMenu[nCursor].name/2)-1, nStartY+nCursor-1, colours.yellow, nil)
- output("]", (tSize[1]/2)+(#tMenu[nCursor].name/2), nStartY+nCursor-1, colours.yellow, nil)
- end
- end
- function execute(tAble)
- rs.setBundledOutput("bottom", tAble.colour)
- end
- function main()
- redraw()
- while true do
- evt, key = os.pullEvent("key")
- if key == 200 and nCursor >= 1 then
- nCursor = nCursor - 1
- execute(tMenu[nCursor])
- elseif key == 208 and nCursor <= #tMenu then
- nCursor = nCursor + 1
- execute(tMenu[nCursor])
- end
- redraw()
- end
- end
- pcall(main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement