Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- oMonitor = peripheral.wrap("monitor_10")
- oChest = peripheral.wrap("top")
- tColors = {
- ["bg"]=colors.white, -- background color
- ["tc"]=colors.black, -- text color
- ["fg"]=colors.lightBlue, -- foreground color
- ["vc"]=colors.blue, -- vanity color
- ["rc"]=colors.lightGray, -- row color
- }
- tDestinations = {
- "house1",
- "big house",
- "meem",
- "hihi",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "frick frack frock nutkc rjif",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- "big moose statue",
- }
- function fCenterPrint(sText, iY)
- local tSize = {term.getSize()}
- term.setCursorPos((tSize[1]/2)-(#sText/2)+1, iY)
- term.write(sText)
- end
- function fDrawLine(iY)
- local tSize = {term.getSize()}
- term.setCursorPos(1, iY)
- for i = 1,tSize[1] do
- term.write(" ")
- end
- end
- function fDrawSpecLine(iX, iXb, iY)
- term.setCursorPos(iX, iY)
- for i = iX, iXb do
- term.write(" ")
- end
- end
- function fDrawBottomLine(iY)
- term.setBackgroundColor(tColors.fg)
- fDrawLine(iY)
- term.setBackgroundColor(tColors.bg)
- end
- function fDrawTextLine(sText, iY)
- fDrawBottomLine(iY)
- term.setBackgroundColor(tColors.fg)
- fCenterPrint(sText, iY)
- term.setBackgroundColor(tColors.bg)
- end
- function fDrawDivider(iY, iYb)
- term.setBackgroundColor(tColors.fg)
- local tSize = {term.getSize()}
- for i = iY, iYb do
- term.setCursorPos(tSize[1]/2, i)
- term.write(" ")
- end
- end
- function fDrawVerticalLine(iX, iY, iYb)
- term.setBackgroundColor(tColors.fg)
- local tSize = {term.getSize()}
- for i = iY, iYb do
- term.setCursorPos(iX, i)
- term.write(" ")
- end
- end
- function fFormatTextLen(sText)
- local tSize = {term.getSize()}
- local iLen = (tSize[1]/2)-4
- if #sText > iLen then
- sText = string.sub(sText, 1, iLen-3)
- sText = sText .. "..."
- end
- return sText
- end
- function fGetAmountPerPage()
- local tSize = {term.getSize()}
- return (tSize[2]-2)*2
- end
- function fGetDividerPos()
- local tSize = {term.getSize()}
- return tSize[1]/2
- end
- iCurrent = -1
- while true do
- term.setBackgroundColor(tColors.bg)
- term.setTextColor(tColors.tc)
- term.clear()
- tSize = {term.getSize()}
- for i = 1,#tDestinations do
- if i <= (fGetAmountPerPage()/2) then
- if i % 2 == 0 then
- term.setBackgroundColor(tColors.rc)
- else
- term.setBackgroundColor(tColors.bg)
- end
- end
- if i >= (fGetAmountPerPage()/2)+1 then
- if i % 2 == 0 then
- term.setBackgroundColor(tColors.bg)
- else
- term.setBackgroundColor(tColors.rc)
- end
- end
- fDrawLine(i+1)
- if iCurrent == i then
- term.setBackgroundColor(tColors.vc)
- end
- --fDrawLine(i+1)
- if iCurrent <= (fGetAmountPerPage()/2) then
- fDrawSpecLine(2, fGetDividerPos()-1,i+1)
- end
- if iCurrent >= (fGetAmountPerPage()/2)+1 then
- fDrawSpecLine(fGetDividerPos()+1, tSize[1],(1+i)-(fGetAmountPerPage()/2))
- end
- --fDrawLine(i+1)
- if i <= (fGetAmountPerPage()/2) then
- term.setCursorPos(3,1+i)
- end
- if i >= (fGetAmountPerPage()/2)+1 then
- term.setCursorPos(fGetDividerPos()+2,(1+i)-(fGetAmountPerPage()/2))
- end
- term.write(fFormatTextLen(i .. ". " .. tDestinations[i]))
- end
- fDrawTextLine("Select your destination!", 1)
- fDrawTextLine("Click here to lock in your selection.", tSize[2])
- fDrawDivider(2, tSize[2]-1)
- fDrawVerticalLine(1, 2, tSize[2]-1)
- fDrawVerticalLine(tSize[1], 2, tSize[2]-1)
- term.setCursorPos(1,1)
- print(iCurrent)
- tEvent = {os.pullEvent()}
- if tEvent[1] == "mouse_click" or tEvent[1] == "monitor_touch" then
- if tEvent[4] > 1 and tEvent[4] < tSize[2] then
- if tEvent[3] < fGetDividerPos() then
- iCurrent = tEvent[4]-1
- else
- iCurrent = (tEvent[4]-1)+(fGetAmountPerPage()/2)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment