Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Monitor Setup
- local mon = peripheral.wrap("right")
- mon.setTextScale(1)
- mon.setTextColor(colors.white)
- local button={}
- mon.setBackgroundColor(colors.black)
- --Variable Definition
- buttonPush = false
- option = 0
- --Functions
- function home()
- shell.run("TitanOS")
- end
- function setTable(name, func, xmin, xmax, ymin, ymax)
- button[name] = {}
- button[name]["func"] = func
- button[name]["active"] = true
- button[name]["xmin"] = xmin
- button[name]["ymin"] = ymin
- button[name]["xmax"] = xmax
- button[name]["ymax"] = ymax
- end
- function fill(text, color, bData)
- mon.setBackgroundColor(color)
- local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
- local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
- for j = bData["ymin"], bData["ymax"] do
- mon.setCursorPos(bData["xmin"], j)
- if j == yspot then
- for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
- if k == xspot then
- mon.write(text)
- else
- mon.write(" ")
- end
- end
- else
- for i = bData["xmin"], bData["xmax"] do
- mon.write(" ")
- end
- end
- end
- mon.setBackgroundColor(colors.black)
- end
- function screen()
- local currColor
- for name,data in pairs(button) do
- local on = data["active"]
- if on == true then currColor = colors.lime else currColor = colors.red end
- fill(name, currColor, data)
- end
- end
- function checkxy(x, y)
- for name, data in pairs(button) do
- if y>=data["ymin"] and y <= data["ymax"] then
- if x>=data["xmin"] and x<= data["xmax"] then
- data["func"]()
- data["active"] = not data["active"]
- print(name)
- end
- end
- end
- end
- function heading(text,a)
- w, h = mon.getSize()
- mon.setCursorPos((w-string.len(text))/2+1,a)
- mon.write(text)
- end
- function dummy()
- buttonPush = not buttonPush
- end
- function menu1()
- if buttonPush == true then
- dummy()
- end
- button = {}
- mon.clear()
- sleep(.25)
- sleep(.25)
- heading("Please follow the On Screen Navigation Below",1)
- while buttonPush == false do
- setTable("Option1", one, 5, 15, 3, 5)
- setTable("Option2", two, 5, 15, 7, 9)
- setTable("Option3", three, 5, 15, 11, 13)
- screen()
- local e, side, x,y = os.pullEvent("monitor_touch")
- print(x..":"..y)
- checkxy(x, y)
- sleep(.1)
- end
- end
- function menu2()
- if buttonPush == true do
- dummy()
- end
- button = {}
- mon.clear()
- sleep(.25)
- while buttonPush == false then
- heading("Button ",1)
- mon.write(option.." was pressed.")
- setTable("Back", menu1, 50, 55, 17, 19)
- setTable("Home", home, 2, 6, 16, 18)
- screen()
- local e, side, x, y = os.pullEvent("monitor_touch")
- print(x..":"..y)
- checkxy(x, y)
- sleep(.1)
- end
- end
- function one()
- dummy()
- option = 1
- menu2()
- end
- function two()
- dummy()
- option = 2
- menu2()
- end
- function three()
- dummy()
- option = 3
- menu2()
- end
- --ASCII Variables
- local Logo = {
- [[ _ __ _ ___ ]],
- [[ o O O | |/ / ___ _ __ _ _ __ _ __| | ___ / __| ___ ]],
- [[ o | ' < / _ \ | ' \ | '_| / _' | / _' | / -_) ( |__ / _ \ ]],
- [[ TS__[O] |_|\_\ \___/ |_|_|_| _|_|_ \__,_| \__,_| \___| \___| \___/ ]],
- [[{======|__|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| |"""""|_|"""""|]],
- [[/o--000'""'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'"'-0-0-'.'-0-0-'"'-0-0-']],
- }
- --Program
- --------------
- --Opening Screen
- while buttonPush == false do
- mon.clear()
- mon.setTextScale(1)
- term.redirect(mon)
- term.clear()
- term.setCursorPos(1,1)
- for i = 1, #Logo do
- print(Logo[i])
- end
- heading("Welcome to Titan Tower!",12)
- heading("A Komrade Co. Enterprise.",13)
- term.restore()
- setTable("Press to Begin", dummy, 30, 50, 15, 17)
- screen()
- local e,side,x,y = os.pullEvent("monitor_touch")
- print(x..":"..y)
- checkxy(x,y)
- sleep(.1)
- end
- menu1()
- menu2()
Advertisement
Add Comment
Please, Sign In to add comment