This repository was archived by the owner on Jan 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.lua
More file actions
78 lines (65 loc) · 1.41 KB
/
Copy pathstartup.lua
File metadata and controls
78 lines (65 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
function printCentered( y,s )
local w,h = term.getSize()
term.setCursorPos(w/2 - #s/2, y)
term.write(s)
end
term.setTextColor(colors.white)
shell.run("clear")
-- [[ Menu
local termWidth, termHeight = term.getSize()
local selectedItem = 1
local running = true
function Choice1()
running = false
shell.run("disk/lwindow/starter")
end
function Exit()
running = false
print("\n\n\nSystem will shutdown in 3 secounds")
os.sleep(3)
os.shutdown()
end
mainMenu = {
[1] = { text = "LWindow", handler = Choice1 },
[2] = { text = "Exit", handler = Exit }
}
function printMenu( menu)
z = 7
term.setTextColor(colors.yellow)
printCentered(5, "MineOS")
term.setTextColor(colors.white)
for i=1,#menu do
z = z + 1
term.setCursorPos(20, z)
if i == selectedItem then
print(">> "..menu[i].text)
else
print(" "..menu[i].text)
end
end
end
function onKeyPressed( key, menu)
if key == keys.enter then
onItemSelected(menu)
elseif key == keys.up then
if selectedItem > 1 then
selectedItem = selectedItem - 1
end
elseif key == keys.down then
if selectedItem < #menu then
selectedItem = selectedItem + 1
end
end
end
function onItemSelected( menu )
menu[selectedItem].handler()
end
function main()
while running do
shell.run("clear")
printMenu(mainMenu)
event, key = os.pullEvent("key")
onKeyPressed(key, mainMenu)
end
end
main()