Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.find("monitor")
- mX, mY = mon.getSize()
- activeScreen = 1
- function monPrint(txt)
- local this = term.current()
- term.redirect(mon)
- print(txt)
- term.redirect(this)
- end
- function drawActiveScreen()
- if screens[activeScreen] then
- setlabel(screens[activeScreen]())
- else
- print("something went wrong!")
- end
- end
- function setlabel(text)
- mon.setBackgroundColor(colors.gray)
- mon.setTextColor(colors.white)
- for i=1,3 do
- mon.setCursorPos(1,mY-i-3)
- mon.write(" ")
- end
- cWrite(text,mY-5)
- end
- function screen1()
- mon.setCursorPos(1,1)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.yellow)
- mon.write("Main information:")
- mon.setCursorPos(1,3)
- mon.setTextColor(colors.white)
- monPrint("You can rightclick the buttons below to switch tabs to see more info on ranks, paths and their differences.")
- return " Information"
- end
- function screen2()
- mon.setCursorPos(1,1)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.yellow)
- mon.write("Rank type 1 information:")
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,3)
- monPrint("These ranks blablabla information blabla sigh I gotta sleep")
- return "Rank type 1"
- end
- function screen3()
- return "Rank type 2"
- end
- function cWrite(text,line)
- local len = string.len(text)
- mon.setCursorPos(math.ceil(mX/2)-(len/2),line)
- mon.write(text)
- end
- function drawButton(mode,active)
- local text = "unset"
- if active == true then
- mon.setBackgroundColor(colors.white)
- else
- mon.setBackgroundColor(colors.lightGray)
- end
- mon.setTextColor(colors.black)
- if mode == "prev" then
- xStart = 1
- text = "Back"
- else
- xStart = (mX-1)/2 + 2
- text = "Next"
- end
- bgText = ""
- repeat
- bgText = bgText.." "
- until string.len(bgText) >= math.floor(mX/2)
- for i=1,3 do
- mon.setCursorPos(xStart,mY-(i-1))
- mon.write(bgText)
- end
- if mode == "prev" then
- mon.setCursorPos(xStart+5,mY-1)
- else
- mon.setCursorPos(xStart+5,mY-1)
- end
- mon.write(text)
- end
- function main()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- drawButton("prev")
- drawButton("next")
- drawActiveScreen()
- event = {os.pullEvent("monitor_touch")}
- centerP = mX / 2
- --print(textutils.serialize(event))
- if event[4] >= mY-3 then
- if event[3] < centerP then
- activeScreen = activeScreen - 1
- if activeScreen == 0 then
- activeScreen = #screens
- end
- elseif event[3] > centerP then
- activeScreen = activeScreen + 1
- if activeScreen > #screens then
- activeScreen = 1
- end
- end
- end
- --print(activeScreen)
- end
- screens = {screen1,screen2,screen3}
- while true do
- main()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement