· 6 years ago · Dec 26, 2019, 09:06 PM
1
2--[[
3
4OS Freeware v2
5
6Revisions from OS Freeware v1:
7 - more stable window api
8 - better app management
9 - less code with more stable engine
10 - more user friendly
11 - code more clear for developers to monkey with
12 - more avaliable settings for desktop
13
14Just Does Games
15
16]]
17
18version = "Freeware v2.1.0" -- os version
19dir = "/freewarev2/" -- os directory
20
21
22-- pre-functions
23
24function clr() return term.clear() end
25function cp(x,y) return term.setCursorPos(x,y) end
26function setText(col) return term.setTextColor(colors[col]) end
27function setBack(col) return term.setBackgroundColor(colors[col]) end
28
29-- pre-functions
30
31
32
33
34-- pre-values
35
36w,h = term.getSize() -- gets size of computer (entire computer, not the window api)
37
38if not http or not term.isColor() or w ~= 51 or h ~= 19 then -- strict requirements
39 if not http then
40 return print("Http is not present")
41 elseif not term.isColor() then
42 return print("Advanced Computer Required")
43 elseif w ~= 51 or h ~= 19 then
44 return print("51x19 Device Only")
45 end
46end
47
48--== Global Values ==--
49
50running = true -- loop for the os (if false, ends entire os)
51update = true -- update apps on the screen (used for after running a program or to update desktop)
52apps = {} -- used for loading all apps (format: name [string], type [number], location [string], texture [table])
53loaded_apps = {} -- used to load the currently displaying apps easier
54page = 1 -- current page
55maxPage = 1 -- max amount of pages
56app_locations = {8,22,36} -- app x-axis
57
58title_color = "white" -- app title color (default: "white")
59desktop_color = "black" -- desktop background color (default: "black")
60scroll_color = "gray" -- desktop scroll left to right background color (default: "gray")
61scroll_text_color = "white" -- desktop scroll left to right text color (default: "white")
62bar_color = "lightBlue" -- desktop bar color (default: "lightBlue")
63bar_text_color = "blue" -- desktop bar text color (default: "blue")
64
65--== Global Values ==--
66
67-- pre-values
68
69
70-- load icons
71
72_t = { -- default app textures
73
74{
75"noTexture",
76"eeeeeeee",
77"eeeeeeee",
78"55555555",
79"55555555",
80"bbbbbbbb",
81"bbbbbbbb"
82},
83
84{
85"ShellOS",
86"11111111",
87"10fffff1",
88"1f0ffff1",
89"10ff00f1",
90"1ffffff1",
91"11111111"
92},
93
94{
95"Homebrew",
96"90999909",
97"90999909",
98"90000009",
99"90000009",
100"90999909",
101"90999909"
102},
103
104{
105"Reboot",
106" 77777",
107" 71117",
108" 71717",
109" 71117",
110" 71777",
111" 777"
112},
113
114{
115"Shutdown",
116" 77777",
117" 7eee7",
118" 7e7e7",
119" 7eee7",
120" 7e777",
121" 777"
122},
123
124{
125"Worm",
126" 777777",
127"7777ddd7",
128"7e77d777",
129"7777d777",
130"7dddd7e7",
131" 777777"
132},
133
134{
135"Adventure",
136" 777777",
137"77000077",
138"77077077",
139"77000077",
140"77077077",
141" 777777"
142},
143
144{
145"Landslide",
146" cccccc ",
147"cc0ccccc",
148"cc0ccccc",
149"cc0ccccc",
150"cc0000cc",
151" cccccc "
152},
153
154{
155"Pastebin",
156" 000000",
157"08887000",
158"08087770",
159"08887070",
160"08007770",
161" 000000"
162},
163
164{
165"Lua",
166" bbbb",
167" b0bbbb",
168"bb0bbbbb",
169"bb0bbbbb",
170" b0000b",
171" bbbb"
172},
173
174{
175"Crash",
176" bbbb",
177" b0000b",
178"bb0bbbbb",
179"bb0bbbbb",
180" b0000b",
181" bbbb"
182},
183
184}
185for i=1, #_t do -- verifies that the files exists. If the file does not exists, creates the file again.
186 if not fs.exists(dir.."icons/".._t[i][1]..".nfp") then
187 local file = fs.open(dir.."icons/".._t[i][1]..".nfp", "w")
188 for ii=1, #_t[i]-1 do
189 file.writeLine(_t[i][ii+1])
190 end
191 file.close()
192 end
193end
194t_noTexture = paintutils.loadImage(dir.."icons/noTexture.nfp")
195t_ShellOS = paintutils.loadImage(dir.."icons/ShellOS.nfp")
196t_Homebrew = paintutils.loadImage(dir.."icons/Homebrew.nfp")
197t_Reboot = paintutils.loadImage(dir.."icons/Reboot.nfp")
198t_Shutdown = paintutils.loadImage(dir.."icons/Shutdown.nfp")
199t_Worm = paintutils.loadImage(dir.."icons/Worm.nfp")
200t_Adventure = paintutils.loadImage(dir.."icons/Adventure.nfp")
201t_Landslide = paintutils.loadImage(dir.."icons/Landslide.nfp")
202t_Pastebin = paintutils.loadImage(dir.."icons/Pastebin.nfp")
203t_Lua = paintutils.loadImage(dir.."icons/Lua.nfp")
204t_Crash = paintutils.loadImage(dir.."icons/Crash.nfp")
205
206
207
208
209
210-- load icons
211
212
213
214
215-- os games
216
217function playLandslide()
218 -- Landslide --
219 -- Just Does Games --
220
221 term.clear()
222
223 local x,y = term.getSize()
224 local px = math.ceil(x/2)
225 local rocks = {} -- Rock Data: {rock x, rock y, id}
226 local maxRocks = 100
227 local run = true
228 local difficulty = {.1,.4}
229 local gamespeed = 0.3
230 local score = 0
231 local maxGamespeed = 0.01
232 local maxScore = 999999999
233 local alt = true
234
235 local function drawRedBar()
236 term.setCursorPos(1,y-3)
237 term.setBackgroundColor(colors["red"])
238 term.clearLine() print("")
239 term.clearLine()
240 end
241
242 local function drawRocks()
243 if score > 500 then
244 -- Do nothing
245 elseif score > 400 then
246 if alt then
247 term.setCursorPos(1,y-3)
248 for i=1, math.floor(x/2) do
249 write(" !")
250 end
251 term.setCursorPos(1,y-2)
252 for i=1, math.floor(x/2) do
253 write("! ")
254 end
255 else
256 term.setCursorPos(1,y-3)
257 for i=1, math.floor(x/2) do
258 write(" ")
259 end
260 term.setCursorPos(1,y-2)
261 for i=1, math.floor(x/2) do
262 write(" ")
263 end
264 end
265 alt = not alt
266 end
267 for i=1, #rocks do
268 term.setCursorPos(rocks[i][1],rocks[i][2]) term.setBackgroundColor(colors["lightGray"]) write(" ")
269 if rocks[i][2] ~= y+1 then
270 term.setCursorPos(rocks[i][1],rocks[i][2]-1) term.setBackgroundColor(colors["black"]) write(" ")
271 end
272 if rocks[i] ~= nil then
273 if px == rocks[i][1] and rocks[i][2] == y then run = false end
274 end
275 end
276 if score > 500 then
277 drawRedBar()
278 end
279 end
280
281 local function drawPlayer()
282 term.setCursorPos(px,y) term.setBackgroundColor(colors["white"]) write(" ")
283 if px ~= x then
284 term.setCursorPos(px+1,y) term.setBackgroundColor(colors["black"]) write(" ")
285 end
286 if px ~= 1 then
287 term.setCursorPos(px-1,y) term.setBackgroundColor(colors["black"]) write(" ")
288 end
289 end
290 drawPlayer()
291
292 local function spawnRock()
293 if maxRocks ~= #rocks then
294 table.insert(rocks, {math.random(1,x),0})
295 end
296 end
297
298 local function destroyRock(rock)
299 term.setCursorPos(rock[1],rock[2]) term.setBackgroundColor(colors["black"]) write(" ")
300 table.remove(rocks, 1)
301 if score ~= maxScore then score = score + 1 end
302 if gamespeed < maxGamespeed then
303 if score > 200 then
304 gamespeed = gamespeed - 0.01
305 elseif score > 400 then
306 gamespeed = gamespeed - 0.02
307 else
308 gamespeed = gamespeed - 0.03
309 end
310 elseif gamespeed < 0 then
311 gamespeed = maxGamespeed
312 end
313 end
314
315 local function engine1() -- player location
316 while run do
317 sleep(.0001)
318 local a,i = os.pullEvent("key")
319 if a == "key" then
320 if i == keys.a or i == keys.left then
321 if px ~= 1 then
322 px = px - 1
323 end
324 elseif i == keys.d or i == keys.right then
325 if px ~= x then
326 px = px + 1
327 end
328 end
329 end
330
331 for i=1, #rocks do
332 if rocks[i] ~= nil then
333 if px == rocks[i][1] and rocks[i][2] == y then run = false end
334 end
335 end
336 drawPlayer()
337 end
338 end
339
340 local function engine2() -- rock spawner
341 while true do
342 sleep(math.random(difficulty[1],difficulty[2]))
343 spawnRock()
344 end
345 end
346
347 local function engine3() -- rock manager
348 while run do
349 local rocksToDestroy = {}
350 for i=1, #rocks do
351 if rocks[i] ~= nil then
352 if rocks[i][2] ~= y+1 then
353 rocks[i][2] = rocks[i][2] + 1
354 else
355 table.insert(rocksToDestroy, rocks[i])
356 end
357 end
358 end
359 drawRocks()
360
361 for i=1, #rocksToDestroy do
362 destroyRock(rocksToDestroy[i])
363 end
364 for i=1, #rocks do
365 if rocks[i] ~= nil then
366 if px == rocks[i][1] and rocks[i][2] == y then run = false end
367 end
368 end
369 sleep(gamespeed)
370 end
371 end
372
373 local function gameover()
374 sleep(.5)
375 term.setTextColor(colors["white"])
376 term.setBackgroundColor(colors["black"])
377 term.clear()
378 term.setCursorPos(x/2-(string.len("Game Over")/2), y/2-1)
379 write("Game Over")
380 term.setCursorPos(x/2-(string.len("Score - "..score)/2), y/2)
381 write("Score - "..score)
382 sleep(1)
383 term.setCursorPos(x/2-(string.len("Press any key to exit...")/2), y/2+3)
384 write("Press any key to exit...")
385 os.pullEvent()
386 end
387
388 local function loop()
389 parallel.waitForAny(engine1,engine2,engine3)
390 gameover()
391 end
392
393 loop()
394end
395
396-- os games
397
398
399-- os programs
400
401function pbrun(code, action, name)
402 if code == nil then
403 return "Invalid Code"
404 elseif string.len(code) < 8 then
405 return "Invalid Code Length."
406 elseif action == "get" and name == nil or name == "" then
407 return "File Name Missing."
408 elseif name ~= nil then
409 if fs.exists(name) then
410 return "File Already Exists"
411 end
412 end
413 term.setCursorBlink(false)
414 cp(1,h-3) setBack("white") setText("white")
415 if action == "run" then
416 cp(1,1) setText("white") setBack("black") clr()
417 return shell.run("pastebin "..action.." "..code)
418 elseif action == "get" then
419 return shell.run("pastebin "..action.." "..code.." "..name)
420 end
421end
422
423function runPastebin()
424 term.setCursorBlink(true)
425 local buttonToggle = true
426 local updat = true
427 local chars = ""
428 local charSelected = true
429 local fsSelected = false
430 local fsPath = ""
431 local runPB = false
432 local stattoggle = true
433 local statm = ""
434
435 local run = true
436
437 while run do
438 if runPB then
439 runPB = false
440 local res
441 setBack("white")
442 cp(6,14+string.len("GO Status: ")) setText("orange") write("Running...")
443 if buttonToggle then
444 res = pbrun(chars, "get", fsPath)
445 else
446 res = pbrun(chars, "run")
447 end
448 term.setCursorBlink(true)
449 if res ~= true then
450 statm = res
451 else
452 statm = "Success!"
453 end
454 setText("black")
455 end
456 if updat then
457 updat = not updat
458 cp(1,1)
459 setText("black")
460 setBack("white")
461 clr()
462 paintutils.drawLine(1,1,w,1,colors["lightGray"])
463 cp(1,3)
464
465 setBack("white")
466 write("Pastebin Code: ")
467 setBack("lightGray")
468 for i=1, 9 do write(" ") end
469
470 if buttonToggle then
471 paintutils.drawFilledBox(5,5,10,8,colors["green"])
472 cp(6,6) write("Get")
473 paintutils.drawFilledBox(12,5,17,8,colors["gray"])
474 cp(13,6) write("Run")
475 else
476 paintutils.drawFilledBox(5,5,10,8,colors["gray"])
477 cp(6,6) write("Get")
478 paintutils.drawFilledBox(12,5,17,8,colors["green"])
479 cp(13,6) write("Run")
480 end
481 paintutils.drawFilledBox(5,12,10,15,colors["lime"])
482 cp(6,13) write("GO ")
483 setBack("white") write(" Status: ")
484 if stattoggle then setText("green") else setText("red") end
485 write(statm) setText("black")
486
487 if buttonToggle then
488 cp(1,10)
489 setBack("white")
490 write("File Name: ")
491 setBack("lightGray")
492 for i=1, w-string.len("File Name: ") do
493 write(" ")
494 end
495 end
496
497 end
498
499 setBack("lightGray")
500 cp(string.len("Pastebin Code: ")+1,3)
501 write(chars.." ")
502 cp(string.len("Pastebin Code: ")+1+string.len(chars),3)
503
504 if buttonToggle then
505 cp(string.len("File Name: ")+1,10)
506 write(fsPath.." ")
507
508 if charSelected then
509 cp(string.len("Pastebin Code: ")+1+#chars, 3)
510 else
511 cp(string.len("File Name: ")+1+string.len(fsPath), 10)
512 end
513 end
514
515 a,i,x,y = os.pullEvent()
516 if a == "mouse_click" then
517 if i == 1 then
518 if x >= string.len("Pastebin Code: ")+1 and x <= string.len("Pastebin Code: ")+9 and y == 3 then
519 term.setCursorBlink(true)
520 fsSelected = false
521 charSelected = true
522 elseif x >= string.len("File Name: ")+1 and y == 10 and buttonToggle then
523 term.setCursorBlink(true)
524 fsSelected = true
525 charSelected = false
526 else
527 term.setCursorBlink(false)
528 charSelected = false
529 if x >= 5 and x <= 10 and y >= 5 and y <= 8 then
530 buttonToggle = true updat = true
531 elseif x >= 12 and x <= 17 and y >= 5 and y <= 8 then
532 buttonToggle = false updat = true
533 end
534 end
535 end
536 elseif a == "paste" then
537 if charSelected then
538 if string.len(chars..i) <= 8 then chars = chars..i end
539 elseif fsSelected then
540 if string.len(fsPath..i) < w-string.len("File Name: ")-1 then fsPath = fsPath..i end
541 end
542 elseif a == "char" then
543 if i ~= " " then
544 if charSelected then
545 if string.len(chars) ~= 8 then chars = chars..i end
546 else
547 if string.len(fsPath) < w-string.len("File Name: ")-1 then fsPath = fsPath..i end
548 end
549 end
550 elseif a == "key" then
551 if i == keys.backspace and charSelected then
552 chars = string.sub(chars,1,-2)
553 elseif i == keys.backspace and fsSelected then
554 fsPath = string.sub(fsPath,1,-2)
555 elseif i == keys.enter or i == keys.tab then
556 if charSelected then
557 charSelected = false
558 if buttonToggle then
559 fsSelected = true
560 else
561 runPB = true updat = true
562 end
563 elseif fsSelected then
564 runPB = true updat = true
565 end
566 end
567 end
568
569 end
570 term.setCursorBlink(false)
571end
572
573function runDesktop(browse)
574 -- Desktop
575 if browse ~= nil then browse = true else browse = false end
576 local w,h = term.getSize()
577 local run = true
578 local selected = 1
579 local scroll = 1
580 local updat = true
581 local display
582 local l_apps = apps
583 while run do
584 if updat then
585 updat = false cp(1,1) setText("white") setBack("black") clr()
586 end
587 display = {}
588 if #l_apps > h-math.ceil(#l_apps/6) then
589 --
590 end
591 a,i = os.pullEvent("key")
592
593 end
594 sleep(2)
595end
596
597-- os programs
598
599
600
601
602
603-- base os-functions
604
605function _save() -- save all apps
606 local file = fs.open(dir.."apps/list.lua", "w")
607 file.write(textutils.serialize(apps))
608 file.close()
609 page = 1
610 maxPage = math.ceil(#apps/6)
611end
612
613function _load() -- load all apps
614 if fs.exists(dir.."apps/list.lua") then
615 local file = fs.open(dir.."apps/list.lua","r")
616 local data = file.readAll()
617 file.close()
618 apps = textutils.unserialize(data)
619 else
620 apps = {{"ShellOS", 1, "", t_ShellOS, 1},{"Homebrew", 1, "", t_Homebrew, 1}, {"Shutdown", 1, "", t_Shutdown, 1}, {"Reboot", 1, "", t_Reboot, 1}, {"Worm", 1, "", t_Worm, 1}, {"Adventure", 1, "", t_Adventure, 1}, {"Landslide", 1, "", t_Landslide, 1}, {"Pastebin", 1, "", t_Pastebin, 1}, {"Lua", 1, "", t_Lua, 1}, {"Crash", 1, "", t_Crash, 1}, {"Desktop", 1, "", t_Desktop, 1}, {"Test", 1, "", t_noTexture, 1},}
621 end
622 page = 1
623 maxPage = math.ceil(#apps/6)
624end
625
626function _display_desktop()
627 loaded_apps = {}
628 for i=1, 6 do
629 loaded_apps[i] = apps[i+(6*(page-1))]
630 end
631 setText(title_color)
632 for i=1, #loaded_apps do
633 if i <= 3 then -- top
634 setBack(desktop_color)
635 cp(app_locations[i], 1) write(loaded_apps[i][1])
636 if loaded_apps[i][4] == nil then loaded_apps[i][4] = t_noTexture end
637 paintutils.drawImage(loaded_apps[i][4], app_locations[i], 2)
638 else -- bottom
639 setBack(desktop_color)
640 cp(app_locations[i-3], h-8) write(loaded_apps[i][1])
641 if loaded_apps[i][4] == nil then loaded_apps[i][4] = t_noTexture end
642 paintutils.drawImage(loaded_apps[i][4], app_locations[i-3], h-7)
643 end
644 end
645 if page ~= 1 then
646 setBack(scroll_color)
647 setText(scroll_text_color)
648 else
649 setBack("black")
650 setText("gray")
651 end
652 for i=1, 6 do
653 cp(1,h/2-i+4)
654 write(" ")
655 end
656 cp(1,h/2-3) write("<")
657 cp(1,h/2+3) write("<")
658 if page ~= maxPage then
659 setBack(scroll_color)
660 setText(scroll_text_color)
661 else
662 setBack("black")
663 setText("gray")
664 end
665 for i=1, 6 do
666 cp(w, h/2-i+4)
667 write(" ")
668 end
669 cp(w,h/2-3) write(">")
670 cp(w,h/2+3) write(">")
671 cp(1,h) setBack(bar_color) term.clearLine() cp(1,h) setText(bar_text_color) write("Page: "..page.."/"..maxPage)
672end
673
674function _update()
675 update = false setBack(desktop_color) clr()
676 _display_desktop()
677end
678
679-- base os-functions
680
681
682-- os-program index
683
684function runProgram(location, wd)
685 local old = term.current() local mainw
686 if wd ~= nil then
687 mainw = window.create(term.current(),3,3,w-4,h-5)
688 paintutils.drawBox(2,2,w-1,h-2,colors["lightGray"])
689 paintutils.drawPixel(w-1,2,colors["red"])
690 else
691 mainw = window.create(term.current(),1,1,w,h-1)
692 setBack("black")
693 setText("white")
694 clr()
695 paintutils.drawLine(1,h,w,h,colors["lightGray"])
696 paintutils.drawPixel(w,h,colors["red"])
697 end
698 sleep(.5)
699
700 local function window()
701 local run = true
702 while run do
703 a,i,x,y = os.pullEvent()
704 if a == "mouse_click" then
705 if x == w and y == h and wd == nil then
706 run = false
707 elseif x == w-1 and y == 2 and wd ~= nil then
708 run = false
709 end
710 end
711 end
712 end
713 local _program_return
714 local function program()
715 if type(location) == "string" then
716 cp(1,1) setText("white") setBack("black") clr() print("Loading App...") sleep(.7)
717 _program_return = shell.run(location)
718 sleep(1)
719 print("Press any key to exit...")
720 os.pullEvent()
721 elseif type(location) == "function" then
722 _program_return = location()
723 end
724 end
725
726 local oldTerm = term.redirect(mainw)
727 local r,e = pcall(function() parallel.waitForAny(window, program) end)
728 local newTerm = term.redirect(old)
729
730
731 term.setCursorBlink(false)
732 update = true
733 if not r then
734 return error(e)
735 end
736 if run == true then
737 return false
738 else
739 return _program_return
740 end
741end
742
743_index = {
744
745ShellOS = function()
746 shell.run("shell")
747end,
748
749Homebrew = function()
750 running = false
751end,
752
753Shutdown = function()
754 os.shutdown()
755end,
756
757Reboot = function()
758 os.reboot()
759end,
760
761Worm = function()
762 shell.run("worm")
763end,
764
765Adventure = function()
766 shell.run("adventure")
767end,
768
769Landslide = function()
770 playLandslide()
771end,
772
773Pastebin = function()
774 runPastebin()
775end,
776
777Lua = function()
778 shell.run("lua")
779end,
780
781Crash = function()
782 error("Crash App")
783end,
784
785Desktop = function()
786 runDesktop()
787end,
788
789Test = function() -- use this to test anything
790 runProgram(function() runDesktop() end, true)
791end
792
793}
794
795-- os-program index
796
797
798-- os
799
800function runtime() -- Main Loop
801 -- main script
802 _load()
803 while running do
804 -- main loop
805 if update then
806 _update()
807 end
808 local a,i,x,y = os.pullEvent("mouse_click")
809 if i == 1 then -- left-click
810 if x == 1 and y >= 6 and y <= 12 then
811 if page > 1 then page = page - 1 update = true end
812 elseif x == w and y >= 6 and y <= 12 then
813 if page < maxPage then page = page + 1 update = true end
814 elseif x >= app_locations[1] and x <= app_locations[1]+7 then -- row 1 (left)
815 if y >= 1 and y <= 7 then
816 -- top-left
817 if loaded_apps[1] ~= nil then
818 if loaded_apps[1][2] == 1 then
819 runProgram(_index[string.gsub(loaded_apps[1][1], " ","")])
820 else
821 runProgram(loaded_apps[1][3])
822 end
823 end
824 elseif y >= 11 and y <= 17 then
825 -- bottom-left
826 if loaded_apps[4] ~= nil then
827 if loaded_apps[4][2] == 1 then
828 runProgram(_index[string.gsub(loaded_apps[4][1], " ","")])
829 else
830 runProgram(loaded_apps[4][3])
831 end
832 end
833 end
834 elseif x >= app_locations[2] and x <= app_locations[2]+7 then -- row 2 (middle)
835 if y >= 1 and y <= 7 then
836 -- top-mid
837 if loaded_apps[2] ~= nil then
838 if loaded_apps[2][2] == 1 then
839 runProgram(_index[string.gsub(loaded_apps[2][1], " ","")])
840 else
841 runProgram(loaded_apps[2][3])
842 end
843 end
844 elseif y >= 11 and y <= 17 then
845 -- bottom-mid
846 if loaded_apps[5] ~= nil then
847 if loaded_apps[5][2] == 1 then
848 runProgram(_index[string.gsub(loaded_apps[5][1], " ","")])
849 else
850 runProgram(loaded_apps[5][3])
851 end
852 end
853 end
854 elseif x >= app_locations[3] and x <= app_locations[3]+7 then -- row 3 (right)
855 if y >= 1 and y <= 7 then
856 -- top-right
857 if loaded_apps[3] ~= nil then
858 if loaded_apps[3][2] == 1 then
859 runProgram(_index[string.gsub(loaded_apps[3][1], " ","")])
860 else
861 runProgram(loaded_apps[3][3])
862 end
863 end
864 elseif y >= 11 and y <= 17 then
865 -- bottom-right
866 if loaded_apps[6] ~= nil then
867 if loaded_apps[6][2] == 1 then
868 _index[string.gsub(loaded_apps[6][1], " ","")]()
869 else
870 runProgram(loaded_apps[6][3])
871 end
872 end
873 end
874 end
875 elseif i == 2 then -- right-click
876
877 end
878 end
879end
880
881
882res, er = pcall(runtime) -- Runs OS and returns if it crashed or not
883
884-- os
885
886
887-- end-of-code results
888
889if not res then -- Crashed
890 setText("white")
891 setBack("cyan")
892 cp(1,1) clr()
893 print("A problem has been detected and Freeware has been shut down to prevent damage to your computer.")
894 print("")
895 print("If this is the first time you've seen this Stop error screen, restart your computer. If this appears again, feel free to contact me.") print("")
896 write("Discord Server: ") setText("blue") print("https://discord.gg/SA5tBQ2") setText("white")
897 write("Email: ") setText("yellow") print("edwardelric32578@gmail.com") setText("white") print("")
898 if er == nil then er = "error code was not found! (api?)" end
899 write("Error: ")
900 printError(er)
901 print("")
902 sleep(2)
903 print("Press any key to reboot...")
904 os.pullEvent() os.reboot()
905end
906
907-- Only runs if it didn't crash
908setText("white")
909setBack("black")
910cp(1,1) clr()
911print("Freeware v2")
912sleep(1)
913
914-- end-of-code results