Advertisement
Pirnogion

GUIElements

Jan 19th, 2015
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. --Objects
  2. local GUIElement = {}
  3.  
  4. function GUIElement:Constructor(Name, Text, BlinkText, FirstColor, SecondColor, FirstTextColor, SecondTextColor, PosX, PosY)
  5.     obj = {}
  6.    
  7.     obj.name      = Name      or "unnamed"
  8.     obj.text      = Text      or "undefined"
  9.     obj.blinktext = BlinkText or " "
  10.    
  11.     obj.fcolor  = FirstColor      or colors.black
  12.     obj.scolor  = SecondColor     or colors.white
  13.     obj.ftcolor = FirstTextColor  or colors.gray
  14.     obj.stcolor = SecondTextColor or colors.white
  15.    
  16.     obj.x = PosX or 1
  17.     obj.y = PosY or 1
  18.    
  19.     obj.active = false
  20.    
  21.     setmetatable(obj, self)
  22.     self.__index = self
  23.    
  24.     return obj
  25. end
  26.  
  27. function GUIElement:Blink()
  28.     if self.active then
  29.         term.setBackgroundColor(self.fcolor)
  30.         term.setTextColor(self.ftcolor)
  31.     else
  32.         term.setBackgroundColor(self.scolor)
  33.         term.setTextColor(self.stcolor)
  34.     end
  35.     term.setCursorPos(self.x, self.y)
  36.     term.write(self.blinktext)
  37.     term.setBackgroundColor(self.scolor)
  38.     term.setTextColor(self.ftcolor)
  39.     term.write(" " .. self.text)
  40.     self.active = not self.active
  41. end
  42.  
  43. --Program
  44. local points = {}
  45.  
  46. function CreateBlinkPoint(Name, Text, BlinkText, FirstColor, SecondColor, FirstTextColor, SecondTextColor, PosX, PosY, Blink)
  47.     points[Name] = GUIElement:Constructor(Name, Text, BlinkText, FirstColor, SecondColor, FirstTextColor, SecondTextColor, PosX, PosY, Blink)
  48.     return points[Name]
  49. end
  50.  
  51. function DrawPoints()
  52.     for _, value in pairs(points) do
  53.         value:Blink()
  54.     end
  55. end
  56.  
  57. function DestroyBlinkPoint(Name)
  58.     points[Name] = nil
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement