Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- books = {{"FloorB","Dense","Clickme","y"},{"testing","TEST","HAI","CLIk"}}
- names = {{"BedrockFloor","Dense Ores World","Click Me!","y"},{"testing","TEST","HAI","clickit"}}
- xes = {}
- max = 4
- page = 1
- function reset()
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.clear()
- end
- function cprint(w,y,text)
- term.setCursorPos((w/2)-(#text/2),y)
- term.write(text)
- end
- function getCenter(w,text,reset)
- if reset == false then
- one = (w/2)-(#text/2)
- two = one+#text
- tbl = {}
- table.insert(tbl,one)
- table.insert(tbl,two-1)
- table.insert(xes,tbl)
- elseif reset == true then
- xes = {}
- end
- end
- while true do
- reset()
- term.setBackgroundColor(colors.red)
- term.setCursorPos(1,1)
- size = {term.getSize()} --term has already been redirected.
- for i = 1,size[1] do
- term.write(" ")
- end
- term.setCursorPos(1,size[2])
- for i = 1,size[1] do
- term.write(" ")
- end
- term.setCursorPos((size[1]/2)-4,size[2]-2)
- term.write(" < ")
- term.setCursorPos((size[1]/2)+1,size[2]-2)
- term.write(" > ")
- cprint(size[1],1,"EBTele Terminal")
- term.setBackgroundColor(colors.white)
- cprint(size[1],size[2]-1,"Page "..page)
- cprint(size[1],3,"Select a Destination")
- for i = 1,#books[page] do
- term.setBackgroundColor(colors.red)
- cpos = {term.getCursorPos()}
- cprint(size[1],cpos[2]+2," "..names[page][i].." ")
- getCenter(size[1]," "..names[page][i].." ",false)
- end
- evnt = {os.pullEvent()}
- if evnt[1] == "mouse_click" then
- for i = 1,#books[page] do
- if evnt[4] == 3+(2*i) then
- if evnt[3] >= xes[i][1] and evnt[3] <= xes[i][2] then
- print(names[page][i])
- --sleep
- end
- end
- end
- if evnt[4] == size[2]-2 then
- if evnt[3] >= (size[1]/2)-5 and evnt[3] <= (size[1]/2)-2 then
- if page == 1 then
- page = #books
- else
- page = page-1
- end
- elseif evnt[3] >= (size[1]/2) and evnt[3] <= (size[1]/2)+3 then
- if page == #books then
- page = 1
- else
- page = page + 1
- end
- end
- end
- end
- getCenter(size[1],"na",true)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement