Advertisement
Marlingaming

Help Application

Apr 6th, 2022 (edited)
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.03 KB | None | 0 0
  1. local tArg = {...}
  2.  
  3. local w, h = term.getSize()
  4. --Page Contents: title, text, images, links
  5. local Pages = {{"UI","The UI is made up of 3 sections; Desktop, Dropdown, and Application screen. Desktop allows you to open apps and has its background as the users selected desktop background, which can be changed in settings. Dropdown allows the user to see past notifications, and messages. Background of Dropdown can be changed in settings as well. Application screen is where the running application can display information to the user and receive inputs.",-1,-1},{"System_Organization","the folders for the system are organized based off use. \n APIs: 'os/System/Tools'\n UI assets: 'os/UI' \n Desktop Icon Images: 'os/UI/DesktopIcons' \n files that run on startup: 'startup' \n os files: 'os/Files' \n logs: 'os/Files/Logs' \n users: 'os/System/Users'",-1,-1},{"Application_API","Application Tools",-1,{{"text","AppApi_Text"},{"Buttons","AppApi_Button"},{"Images","AppApi_Image"},{"Input box","AppApi_Input"},{"other functions","AppApi_Misc"}}},{"AppApi_Text","used to display text on screen, color can be changed using App.setTextColor(color) \n format: \n App.newText(id,text,x,y)",-1,{{"For Text Color","AppApi_Misc"}}},{"AppApi_Button","used for creating new buttons \n format: \n App.newButton(id,text,action,x,y) \n Other Details \n Buttons can either call a app event when pressed or call a file event. these are as follows: \n tsk.(appEventName) AppEvent \n lnk.(path)  file to be ran",-1,-1},{"AppApi_Image","Display Image \n App.newImage(id,path,x,y)",-1,-1},{"AppApi_Input","allows user input (wip)",-1,-1},{"AppApi_Misc","other functions \n change background color: \n App.setBackground(color) \n change text color: \n App.setTextColor(color) \n run Application: \n App.setApplication(path) \n toggle scrollability: \n App.setScroll(true/false) \n See Also",-1,{{"colors","Misc_colors"},{"Shortcuts","System_Shortcuts"}}},{"System_Shortcuts","the desktop shows programs based off if they have a shortcut, and if they have a image attached to that shortcut. shortcuts for desktop are stored at 'os/Desktop_Shortcuts' but its not recommended to directly add a file to that folder, instead i recommend using the shortcut function of the file system advance api. \n simply run 'fsAdv.CreateShortcut(path of program, name to display on desktop, image shortcut uses)'",-1,{{"file formats","System_FileFormats"}}},{"System_FileFormats","Supported Formats: \n text document: .txt \n video: .vid \n image: .nfp \n program: .lua \n shortcut/link: .lnk",-1,{{"Folders","System_Organization"}}},{"Misc_colors","this system uses the base craftos color system, so you just need to do color.(color) or the single character repersentation of the color"}}
  6.  
  7. function Menu()
  8. App.Clear()
  9. App.newText("MenuText","==Help Menu==",w/2 - 6, 1)
  10. for i = 1, #Pages do
  11.     App.newButton("button"..i,Pages[i][1],"tsk."..Pages[i][1],w/2 - string.len(Pages[i][1])/2,(i * 2))
  12.  
  13. end
  14. end
  15.  
  16. function Page(I)
  17. App.Clear()
  18. App.newText("title",Pages[I][1],w/2 - string.len(Pages[I][1])/2,1)
  19. App.newButton("return","return","tsk.Menu",1,1)
  20.  
  21. local Y = 3
  22.  
  23. local lines = require "cc.strings".wrap(Pages[I][2], w-2)
  24. for i = 1, #lines do
  25.     App.newText("Disc"..i,lines[i],1,i + 2)
  26.     Y = Y + 1
  27. end
  28. if Pages[I][3] ~= -1 then
  29.     for i = 1, #Pages[I][3] do
  30.         local file = fs.open(Pages[I][3][i],"r")
  31.         local Height = 0
  32.         local Content
  33.         repeat
  34.             Content = file.readLine()
  35.             if Content ~= nil then Height = Height + 1 end
  36.         until Content == nil
  37.         file.close()
  38.         App.newImage("Image"..i,Pages[I][3][i],1,Y)
  39.         Y = Y + Height + 1
  40.     end
  41. end
  42. if Pages[I][4] ~= -1 then
  43.     for i = 1, #Pages[I][4] do
  44.         App.newButton("link"..i,Pages[I][4][i][1],"tsk."..Pages[I][4][i][2],1,Y)
  45.         Y = Y + 1
  46.     end
  47. end
  48. end
  49.  
  50. function FindPage(text)
  51. local I
  52. for i = 1, #Pages do
  53.     if Pages[i][1] == text then I = i end
  54. end
  55. Page(I)
  56. end
  57.  
  58. if tArg[1] == "start" then
  59.     Menu()
  60. elseif tArg[1] == "Menu" then
  61.     Menu()
  62. else
  63.     FindPage(tArg[1])
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement