Advertisement
z1haze

GUIUtils.lua

Feb 25th, 2025 (edited)
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. -- GUI util module for programs
  2. local GUIUtils = {}
  3.  
  4. function GUIUtils.create()
  5.     local instance = {}
  6.  
  7.     function instance.clearLine()
  8.         local x, y = term.getCursorPos()
  9.  
  10.         term.setCursorPos(1, y)
  11.         write("|                                     |")
  12.         term.setCursorPos(x, y)
  13.     end
  14.  
  15.     function instance.drawFrame()
  16.         term.clear()
  17.  
  18.         -- side borders
  19.         for i = 1, 13 do
  20.             term.setCursorPos(1, i)
  21.             write("|")
  22.             term.setCursorPos(39, i)
  23.             write("|")
  24.         end
  25.  
  26.         -- top border
  27.         term.setCursorPos(1, 1)
  28.         write("O-------------------------------------O")
  29.  
  30.         -- middle line
  31.         term.setCursorPos(1, 5)
  32.         write("O-------------------------------------O")
  33.  
  34.         -- bottom border
  35.         term.setCursorPos(1, 13)
  36.         write("O-------------------------------------O")
  37.  
  38.         -- move cursor to bottom
  39.         local _, h = term.getSize()
  40.         term.setCursorPos(1, h)
  41.     end
  42.    
  43.     return instance
  44. end
  45.  
  46. return GUIUtils
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement