Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this acts as main script CSP
- local w, h = term.getSize()
- local IntPrograms = {"os/os_Programs/os_AccountPgScript", "os/os_Programs/os_BankingApp","os/os_Programs/os_SettingsMenu", "os.reboot"}
- local ProgramNames = {"AccountPage","Banking","Settings","Reboot"}
- local Menu_Buttons = {}
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function CenterText(y,text)
- local x = math.floor((w - string.len(text)) /2)
- term.setCursorPos(x,y)
- term.clearLine()
- term.write(text)
- end
- local function MenuDrawer()
- Clear()
- term.setBackgroundColor(colors.cyan)
- paintutils.drawFilledBox(1,1,w,3,colors.gray)
- paintutils.drawFilledBox(1,1,3,3,colors.white)
- CenterText(1,"===Main=Menu===")
- CenterText(3,"Applications")
- term.setBackgroundColor(colors.cyan)
- CreateButton(3,3,"System","reboot")
- end
- local function ManagePanels(Panel)
- print(Panel)
- end
- local function CreateButton(x,y,Cat,Action)
- Menu_Buttons[#Menu_Buttons+1] = {x,y,Cat,Action}
- paintutils(x-2,y-2,x+2,y+2,colors.red)
- end
- local function CheckButton(i)
- if Menu_Buttons[i][3] == "Script" then shell.run(Menu_Buttons[i][4]) end
- if Menu_Buttons[i][3] == "System" and Menu_Buttons[i,4] == "reboot" then os.reboot() end
- if Menu_Buttons[i][3] == "Panel" then ManagePanels(Menu_Buttons[i,4]) end
- end
- function UserInteraction()
- local event
- while true do
- event = {os.pullEvent("mouse_click")}
- for i = 1, #Menu_Buttons do
- if event[3] >= Menu_Buttons[i,1]-2 and event[3] <= Menu_Buttons[i,1]+2 and event[4] >= MenuButtons[i,2]-2 and event[4] <= Menu_Buttons[i,2]+2 then CheckButton(i) end
- end
- end
- end
- Clear()
- MenuDrawer()
- UserInteraction()
Add Comment
Please, Sign In to add comment