Pinkishu

Untitled

Jun 6th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. local self = getfenv()
  2. internal = {}
  3.  
  4. function self.new(name,x,y,width)
  5.     local txt = {}
  6.     txt.name = name
  7.     txt.x = x
  8.     txt.y = y
  9.     txt.width = width
  10.     txt.value = ""
  11.     txt.scrolled = 0
  12.     txt.cursorAt = 1
  13.     txt.active = false
  14.     txt.scrollWhenInactive = false
  15.     txt.scrolling = false
  16.  
  17.     setmetatable(txt,{__index=internal})
  18. end
  19.  
  20. function internal:setText()
  21. end
  22.  
  23. function internal:updateScroll()
  24. end
  25.  
  26. function internal:initScroll()
  27.     self.scrolling = true
  28. end
  29.  
  30. function internal:stopScroll()
  31.     self.scrolling = false
  32. end
  33.  
  34. function internal:drawText()
  35. end
  36.  
  37. function internal:setCursor()
  38. end
  39.  
  40. function internal:update(dt)
  41.     if self.scrolling then
  42.         self:updateScroll(dt)
  43.     end
  44. end
  45.  
  46. function internal:draw()
  47.  
  48. end
  49.  
  50. function internal:checkClicked()
  51. end
  52.  
  53. function internal:activate()
  54.     gui.activateControl(self)
  55. end
  56.  
  57. function internal:deactivate()
  58.     gui.deactivateControl()
  59. end
  60.  
  61. function internal:onDeactivate()
  62.     term.setCursorBlink(false)
  63.     if txt.scrollWhenInactive then
  64.         self:initScroll()    
  65.     end
  66. end
  67.  
  68. function internal:onActivate()
  69.     term.setCursorBlink(true)
  70.     if self.scrolling then
  71.         self:stopScroll()
  72.     end
  73.     self:draw()
  74.     self:setCursor()
  75. end
Advertisement
Add Comment
Please, Sign In to add comment