View difference between Paste ID: 4aZ7s7Nr and AH8P3Sbn
SHOW: | | - or go back to the newest paste.
1
---- By: Goodle
2
3
-- Variables
4-
term = peripheral.wrap("right")
4+
5
6
CnWidth = width / 2
7
CnHeight = height / 2
8
9
time = os.time()
10
formattedTime = textutils.formatTime( time, false)
11
12
isMenu = false
13
isDesktop = false
14
isStartup = false
15
          
16
-- Functions
17
18
function time()
19
  return textutils.formatTime(os.time(), true)
20
end
21
22
startup = function()
23
  isStartup = true
24
  term.clear()
25
  term.setCursorPos(CnWidth-5,height-1)
26
  term.setTextColour( colours.blue )
27
  term.write("WaffgoOS by")
28
  term.setCursorPos(CnWidth-20,height)
29
  term.write("Goodle Software - In cooperation with CPGGC")
30
  term.setCursorPos(CnWidth-3,CnHeight-1)
31
  term.setTextColour( colours.lightBlue )
32
  term.write("Loading")
33
  term.setCursorPos(CnWidth-6,CnHeight)
34
  term.write(";")
35
  term.setCursorPos(CnWidth+6,CnHeight)
36
  term.write(";")
37
  term.setBackgroundColour( colours.black )
38
  term.setCursorPos(CnWidth,CnHeight+1)
39
  term.write('0%')
40
  sleep(1)
41
  paintutils.drawLine(CnWidth-5,CnHeight, CnWidth,CnHeight, colours.green )
42
  term.setBackgroundColour( colours.black )
43
  term.setCursorPos(CnWidth-1,CnHeight+1)
44
  term.write("50%")
45
  sleep(0.5)
46
  paintutils.drawLine(CnWidth,CnHeight, CnWidth+4,CnHeight, colours.green )
47
  term.setBackgroundColour( colours.black )
48
  term.setCursorPos(CnWidth-1,CnHeight+1)
49
  term.clearLine()
50
  term.write("78%")
51
  sleep(0.3)
52
  term.setCursorPos(CnWidth-1,CnHeight+1)
53
  term.clearLine()
54
  term.write("80%")
55
  sleep(0.5)
56
  paintutils.drawLine(CnWidth+4,CnHeight, CnWidth+5,CnHeight, colours.green )
57
  term.setBackgroundColour( colours.black )
58
  term.setCursorPos(CnWidth-1,CnHeight+1)
59
  term.clearLine()
60
  term.write("100%")
61
  term.setCursorPos(CnWidth-3,CnHeight-1)
62
  term.clearLine()
63
  term.setBackgroundColour( colours.black )
64
  term.write("Welcome!")
65
  sleep(3)
66
  isStartup = false
67
  desktop()
68
end
69
70
71
desktop = function()
72
  
73
  isDesktop = true
74
  term.clear()
75
  pixelsDown = 1
76
  pixelsDownLimit = height
77
  -- Desktop drawing
78
  
79
  while pixelsDown ~= height
80
    do paintutils.drawLine(1,pixelsDown, width,pixelsDown, colours.white )
81
    pixelsDown = pixelsDown + 1
82
    end
83
  paintutils.drawLine(1,height, width,height, colours.blue )
84
  term.setCursorPos(1,height)
85
  term.setTextColour( colours.white )
86
  term.setBackgroundColour( colours.lime )
87
  term.write(' @ menu ')
88
  
89
  -- Clock Drawing
90
  
91
  term.setCursorPos(width-6,height)
92
  term.setTextColour( colours.white )
93
  term.setBackgroundColour( colours.blue )
94
  local mon = window.create(term.current(),width-6,height,width,height)
95
  local ok, err = pcall( function()
96
  parallel.waitForAny(
97
        function()
98
          while true do
99
                mon.clear()
100
                mon.setCursorPos(2,3)
101
                mon.write(time())
102
                sleep(1)
103
          end
104
        end,
105
        function()
106
          os.run( {}, "desktop" )
107
        end
108
        )
109
  end )
110
  
111
  while isDesktop == true do
112
    term.setBackgroundColour( colours.white )
113
    term.setCursorPos(0,0)
114
    term.setCursorBlink(false)
115
    local event, click, x, y = os.pullEvent("mouse_click")
116
    if x == 2 then
117
      if y == height then
118
      break
119
      end
120
    end
121
  end
122
end
123
124
drawWindow = function()
125
  term.clear()
126
end
127
128
129
drawMenu = function()
130
  isMenu = true
131
  local menuPD = 2 -- Menu pixels down
132
  local menuPDL = height-1 -- Menu pixels down limit
133
  local menuPUL = height-10 -- Menu pixels up limit
134
  -- Menu pixels right limit is = 15
135
  while menuPD < menuPDL do
136
    paintutils.drawLine(1, menuPUL, 15, menuPUL, 400 )
137
    menuPUL = menuPUL + 1
138
    menuPD = menuPD + 1
139
  end -- Dimensions of menu: w-15 from left, h-9 from height - 1
140
  term.setCursorPos(1,height)
141
  term.setTextColour( colours.white )
142
  term.setBackgroundColour( colours.green )
143
  term.write(" @ menu ")
144
  
145
  paintutils.drawLine(9,height, 15,height, colours.blue )
146
  term.setCursorPos(2,height-1)
147
  term.setBackgroundColour( 400 )
148
  term.setTextColour( colours.yellow )
149
  term.write("@ Exit") -- Logoff button
150
  term.setCursorPos(2,height-2)
151
  term.setTextColour( colours.red )
152
  term.write("@ Shutdown") -- Shutdown button
153
  term.setCursorPos(2,height-3)
154
  term.setTextColour( colours.green )
155
  term.write("@ TMNET") -- Shutdown button
156
  
157
  term.setBackgroundColour( colours.white )
158
  while isMenu == true do
159
    local event, click2, x, y = os.pullEvent("mouse_click")
160
    if x == 2 and y == height then
161
        isMenu = false
162
        desktop()
163
        break
164
    end
165
    if x == 2 then
166
      if y == height-1 then
167
        isMenu = false
168
        isStartup = false
169
        isDesktop = false
170
        exit()
171
      end
172
   end
173
   if x == 2 then
174
     if y == height-2 then
175
        os.shutdown()
176
      end
177
   end
178
   if x == 2 then
179
     if y == height-3 then
180
        shell.run("web")
181
        isMenu = false
182
        desktop()
183
        break
184
      end
185
   end
186
  end  
187
end
188
189
exit = function()
190
  term.clear()
191
  term.setBackgroundColour(colours.black)
192
  term.setTextColour(colours.white)
193
  term.setCursorPos(1,1)
194
  term.clear()
195
end
196
-- Program execution
197
198
startup()
199
200
drawMenu()
201
202
while isDesktop == true do
203
  drawMenu()  
204
end