Jyzarc

Terminal

Feb 12th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. --Terminal
  2. terminal = {
  3.     running = true;
  4.     text = "";
  5.     param = {};
  6. }
  7.  
  8. function terminal.updateScreen()
  9.     term.clear()
  10.     term.setCursorPos(1,1)
  11.     print(terminal.text)
  12. end
  13.  
  14. while terminal.running do
  15.     terminal.updateScreen()
  16.     terminal.param[1],terminal.param[2],terminal.param[3],terminal.param[4] = os.pullEvent()
  17.     if terminal.param[1] == "char" then
  18.         terminal.text = terminal.text..terminal.param[2]
  19.     elseif terminal.param[1] == "key" then
  20.         if terminal.param[2] == 28 then
  21.             terminal.text = terminal.text.."\n"
  22.         elseif terminal.param[2] == 14 then
  23.             terminal.text = string.sub(terminal.text,1,string.len(terminal.text)-1)
  24.         end
  25.     end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment