xXm0dzXx

Untitled

Apr 21st, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. local currentX = 1 --Saves the current X of the cursor
  2. local currentY = 1 --Saves the current Y of the cursor
  3.  
  4.  
  5. function drawCursor()
  6. term.clear() --Clears the screen
  7. term.setCursorPos(currentX, currentY) --Draws a cursor at the current X/Y
  8. write(">")
  9. end
  10.  
  11.  
  12. while true do
  13. drawCursor()
  14. local e,key, char = os.pullEvent( "key" )
  15. if e == "key" then
  16. if key == 17 or key == 200 then --up
  17. currentY = currentY -1
  18. elseif key == 31 or key == 208 then --down
  19. currentY = currentY +1
  20. elseif key == 203 or key == 30 then --left
  21. currentX = currentX -1
  22. elseif key == 205 or key == 32 then --right
  23. currentX = currentX +1
  24. end
  25. elseif e == "char" then
  26. term.setCursorPos(currentX +1, currentY)
  27. write(char)
  28. end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment