Advertisement
nik1111

init

May 19th, 2022
653
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --
  2. -- Created by Grcpils
  3. -- 03/14/2021
  4. -- Github: https://github.com/grcpils/cc-gui_api
  5. -- Please do not delete this header ;)
  6. --
  7.  
  8. require("table")
  9. local Utils    =  require("GUI/utils")
  10. local Version  =  require("GUI/version")
  11. local Button   =  require("GUI/button")
  12. local Group    =  require("GUI/group")
  13. local Progress =  require("GUI/progress")
  14. local Tiles    =  require("GUI/tiles")
  15.  
  16. GUI_MONITOR = nil
  17. GUI_BUTTONS = {}
  18. GUI_GROUPS = {}
  19. GUI_PROGRESS = {}
  20. GUI_TILES = {}
  21. GUI_CONFIG = {}
  22.  
  23. local catchEvents = function (x,y)
  24.     Button.waitForClick(x, y)
  25. end
  26.  
  27. local setMonitor = function (monitor)
  28.     GUI_MONITOR = peripheral.wrap(monitor)
  29. end
  30.  
  31. local welcomeTerm = function ()
  32.     term.setCursorPos(13,1)
  33.     term.setTextColor(colors.yellow)
  34.     term.write("| GUI v"..Version.get())
  35.     term.setCursorPos(1,2)
  36. end
  37.  
  38. local init = function (e_callback)
  39.     if GUI_MONITOR == nil then
  40.         Utils.printErr("[GUI] Error %s %s: No monitor setup\n", debug.getinfo(2).source, debug.getinfo(2).currentline)
  41.         return
  42.     end
  43.     welcomeTerm()
  44.     Version.checkUpdate()
  45.     Utils.clearAll()
  46.     Button.drawAll()
  47.     Group.drawAll()
  48.     Progress.drawAll()
  49.     Tiles.drawAll()
  50.     if e_callback ~= nil then
  51.         if type(e_callback) == "function" then
  52.             e_callback()
  53.         else
  54.             Utils.printErr("[GUI] Error %s %s: argument give to GUI.init() is not a function\n", debug.getinfo(2).source, debug.getinfo(2).currentline)
  55.         end
  56.     end
  57. end
  58.  
  59. return {
  60.     init = init,
  61.     setMonitor = setMonitor,
  62.     Button = Button,
  63.     Group = Group,
  64.     Progress = Progress,
  65.     Tiles = Tiles,
  66.     catchEvents = catchEvents
  67. }
  68.  
Advertisement
RAW Paste Data Copied
Advertisement