Miki_Tellurium

notepad-main

Jan 2nd, 2023 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | Gaming | 0 0
  1. -- Notepad app by Miki_Tellurium
  2. -- Version: 1.0.0
  3. local textLibrary = require("text")
  4. local buttonLibrary = require("button")
  5. local library = require("notepadsettings")
  6.  
  7. term.clear()
  8. term.setBackgroundColor(colors.black)
  9. term.setTextColor(colors.white)
  10. local version = {1, 0, 0}
  11. local program = nil
  12.  
  13. --Settings setup
  14. notepadsettings.defineSettings()
  15. notepadsettings.createSettings()
  16. settings.load("notepad.settings")
  17. local headerText = settings.get("HeaderText")
  18. local headerColor = settings.get("HeaderColor")
  19. local ingameInfoTitleColor = settings.get("IngameInfoTitleColor")
  20. local ingameInfoColor = settings.get("IngameInfoColor")
  21. local irlInfoTitleColor = settings.get("IrlInfoTitleColor")
  22. local irlInfoColor = settings.get("IrlInfoColor")
  23. -- Buttons definition
  24. local settingsButton = button:new()
  25. settingsButton:setLabel("Settings")
  26. settingsButton:setBackgroundColor(colors.purple)
  27. settingsButton:setTextColor(colors.black)
  28. settingsButton:setLocation(3, 17)
  29. local memosButton = button:new()
  30. memosButton:setLabel("Memos")
  31. memosButton:setBackgroundColor(colors.yellow)
  32. memosButton:setTextColor(colors.black)
  33. memosButton:setLocation(3, 9)
  34.  
  35. term.setBackgroundColor(colors.black)
  36. term.clear()
  37. -- Show time informations
  38. function timeInfos()
  39.  while true do
  40.   local header = headerText
  41.   local ingame_day = os.day("ingame")
  42.   local ingame_time = textutils.formatTime(os.time("ingame"), true)
  43.   local irl_date = os.date("%d/%m/%Y")
  44.   local irl_time = textutils.formatTime(os.time("local"), true)
  45.   text.print(header, 1, 1, headerColor)
  46.   if settings.get("ItalyFlag") == true then
  47.    term.setCursorPos(23, 1)
  48.    term.blit("   ", "fff", "d0e")
  49.   end
  50.   text.print("Ingame day:", 2, 2, ingameInfoTitleColor)
  51.   text.print(ingame_day, 5, 3, ingameInfoColor)
  52.   text.print("Ingame time:", 2, 5, ingameInfoTitleColor)
  53.   text.print(ingame_time.." ", 5, 6, ingameInfoColor)
  54.   text.print("IRL Date:", 16, 2, irlInfoTitleColor)
  55.   text.print(irl_date, 16, 3, irlInfoColor)
  56.   text.print("IRL Time:", 16, 5, irlInfoTitleColor)
  57.   text.print(irl_time.." ", 18, 6, irlInfoColor)
  58.   text.print("v", 1, 20, colors.white)
  59.   text.print(version[1]..".", 2, 20, colors.blue)
  60.   text.print(version[2]..".", 4, 20, colors.cyan)
  61.   text.print(version[3], 6, 20, colors.lightBlue)
  62.   sleep(0.1)
  63.  end
  64. end
  65. -- Draw buttons and perform actions
  66. function buttons()
  67.  settingsButton:paint()
  68.  memosButton:paint()
  69.  local event = {os.pullEvent("mouse_click")}
  70.  if settingsButton:waitForClick(event) then
  71.   program = "settingsapp.lua"
  72.  elseif memosButton:waitForClick(event) then
  73.   program = "memos.lua"
  74.  end
  75. end
  76. -- Run the program
  77. while true do
  78.  parallel.waitForAny(timeInfos, buttons)
  79.  if program ~= nil then
  80.   shell.run(program)
  81.  end
  82. end
Advertisement
Add Comment
Please, Sign In to add comment