Advertisement
Pinkishu

Untitled

Jun 6th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.90 KB | None | 0 0
  1. function CMDMenuState:drawInput()
  2.     term.setCursorPos(3,5)
  3.     term.write(string.rep(" ",tW-4))
  4.     term.setCursorPos(3,5)
  5.     term.write(self.inp:sub(self.inpScroll+1,self.inpScroll+dispSize))
  6. end
  7.  
  8. if ev == "char" then
  9.         self.inp = self.inp:sub(0,self.inpCX-3+self.inpScroll) .. p1 .. self.inp:sub(self.inpCX-2+self.inpScroll,#self.inp)
  10.         self.inpCX = self.inpCX + 1
  11.         if self.inpCX == tW-1 then
  12.             self.inpCX = tW-2
  13.             self.inpScroll = self.inpScroll + 1
  14.         end
  15.         self:drawInput()
  16.         term.setCursorPos(self.inpCX,5)
  17.     elseif ev == "key" then
  18.         if p1 == keys.backspace and #self.inp > 0 then
  19.             self.inp = self.inp:sub(0,self.inpCX-4+self.inpScroll)..self.inp:sub(self.inpCX-2+self.inpScroll,#self.inp)
  20.             self.inpCX = self.inpCX - 1
  21.             if self.inpCX == 2 then
  22.                 self.inpCX = 3
  23.                 self.inpScroll = self.inpScroll - 1
  24.             end
  25.             self:drawInput()
  26.             term.setCursorPos(self.inpCX,5)
  27.         elseif p1 == keys.enter then
  28.             runCmd(self.inp)
  29.         elseif p1 == keys.left then
  30.             self.inpCX = self.inpCX - 1
  31.             if self.inpCX == 2 then
  32.                 self.inpCX = 3
  33.                 if self.inpScroll > 0 then
  34.                     self.inpScroll = self.inpScroll-1
  35.                     self:drawInput()
  36.                 end
  37.             end
  38.             term.setCursorPos(self.inpCX,5)
  39.         elseif p1 == keys.right and self.inpScroll + self.inpCX - 3 < #self.inp then
  40.             self.inpCX = self.inpCX + 1
  41.             if self.inpCX == tW - 1 then
  42.                 self.inpCX = tW - 2
  43.                 if #self.inp > self.inpScroll+dispSize then
  44.                     self.inpScroll = self.inpScroll + 1
  45.                     self:drawInput()
  46.                 end
  47.             end
  48.             term.setCursorPos(self.inpCX,5)
  49.         end
  50.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement