Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = coroutine.yield
- os.setComputerLabel("Information board")
- mon = peripheral.find("monitor")
- mX, mY = mon.getSize()
- activeScreen = 1
- buttonTime = 0.2
- listColor = colors.green
- listItemColor = colors.lightGray
- headerColor = colors.yellow
- subHeaderColor = colors.orange
- function monPrint(txt)
- local this = term.current()
- term.redirect(mon)
- print(txt)
- term.redirect(this)
- end
- function writeRequirement(req_,val_)
- mon.setTextColor(listColor)
- local thisX, thisY = mon.getCursorPos()
- mon.write("- "..req_..":")
- mon.setCursorPos(20,thisY)
- mon.setTextColor(listItemColor)
- monPrint(val_)
- end
- function drawActiveScreen()
- if screens[activeScreen] then
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(headerColor)
- mon.setCursorPos(1,1)
- setlabel(screens[activeScreen]())
- else
- print("something went wrong!")
- activeScreen = 1
- 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.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.")
- monPrint("\nEvery item in the store can be aquired by using reward points, these are obtained by voting or donating.")
- monPrint("\nThere are four paths, you will gradually rank up inside the path chosen, starting with rank type 1.")
- return "Information"
- end
- function screen2()
- mon.write("Rank type 1 information:")
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,3)
- monPrint("This rank requires no playtime and is granted when joining a path.")
- mon.setTextColor(subHeaderColor)
- monPrint()
- monPrint("Commands / Permissions:")
- mon.setTextColor(listColor)
- monPrint("- All default commands")
- return "Rank type 1"
- end
- function screen3()
- mon.write("Rank type 2 information: ")
- mon.setCursorPos(1,3)
- mon.setTextColor(colors.white)
- monPrint("To achieve this rank you must meet all requirements, ranking up doesnt cost anything, you just need to have the status.")
- mon.setTextColor(subHeaderColor)
- monPrint("\nRequirements:")
- mon.setTextColor(listColor)
- writeRequirement("Total playtime","1 day")
- writeRequirement("Money","500$")
- writeRequirement("Exp","5 levels")
- mon.setTextColor(subHeaderColor)
- monPrint("\nAdded permission:")
- mon.setTextColor(listColor)
- monPrint("- Bank access")
- return "Rank type 2"
- end
- function screen4()
- monPrint("Rank type 3 information:")
- mon.setTextColor(colors.white)
- monPrint("\nTo rank up, or check your status use: /ar check.")
- mon.setTextColor(subHeaderColor)
- monPrint("\nRequirements:")
- writeRequirement("Total playtime","2 days")
- writeRequirement("Money","2.000$")
- writeRequirement("Exp","10 levels")
- mon.setTextColor(subHeaderColor)
- monPrint("\nAdded command:")
- mon.setTextColor(listColor)
- monPrint("- /hat")
- return "Rank type 3"
- end
- function screen5()
- monPrint("Rank type 4 information:")
- mon.setTextColor(colors.white)
- monPrint("\nStaff isn't allowed to loan money to players in order for them to rank up, ask someone who trusts you and isn't staff instead.")
- mon.setTextColor(subHeaderColor)
- monPrint("\nRequirements:")
- writeRequirement("Total playtime","5 days")
- writeRequirement("Money","5.000")
- writeRequirement("Exp","25 levels")
- mon.setTextColor(subHeaderColor)
- monPrint("\nAdded command:")
- mon.setTextColor(listColor)
- monPrint("- /back")
- return "Rank type 4"
- end
- function screen6()
- mon.setCursorPos(1,1)
- mon.setTextColor(headerColor)
- monPrint("Rank type 5 information:")
- mon.setTextColor(colors.white)
- monPrint("\nVote points are aquired by voting or donating, Check back on the donation shop regularly to spend these points!")
- mon.setTextColor(subHeaderColor)
- monPrint("\nRequirements:")
- writeRequirement("Total playtime","10 days")
- writeRequirement("Money","10.000")
- writeRequirement("Exp","40 levels")
- mon.setTextColor(subHeaderColor)
- monPrint("\nAdded permission:")
- mon.setTextColor(listColor)
- monPrint("- /back on death.\n (Might be replaced)")
- return "Rank type 5"
- end
- function cWrite(text,line)
- local len = string.len(text)
- mon.setCursorPos(math.ceil(mX/2)-math.floor(len/2),line)
- mon.write(text)
- end
- function drawButton(mode,active)
- local text
- 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
- buttonNext = false
- buttonPrev = false
- function main()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- drawActiveScreen()
- drawButton("prev",buttonPrev)
- drawButton("next",buttonNext)
- if restore ~= true then
- sleep(buttonTime)
- else
- mon.setTextColor(colors.gray)
- mon.setBackgroundColor(colors.black)
- cWrite("Board set to resting state.",mY-3)
- end
- buttonPrev = false
- buttonNext = false
- drawButton("prev",buttonPrev)
- drawButton("next",buttonNext)
- timeOutTimer = os.startTimer(120)
- restore = false
- event = {os.pullEvent()}
- centerP = mX / 2
- if event[1] == "monitor_touch" then
- if event[4] >= mY-3 then
- if event[3] < centerP then
- activeScreen = activeScreen - 1
- if activeScreen == 0 then
- activeScreen = #screens
- end
- buttonPrev = true
- elseif event[3] > centerP then
- activeScreen = activeScreen + 1
- if activeScreen > #screens then
- activeScreen = 1
- end
- buttonNext = true
- end
- end
- os.cancelTimer(timeOutTimer)
- elseif event[1] == "timer" and event[2] == timeOutTimer and activeScreen ~= 1 then
- activeScreen = 1
- restore = true
- end
- end
- screens = {screen1,screen2,screen3,screen4,screen5,screen6}
- while true do
- main()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement