dragon81655

reader

Aug 4th, 2022 (edited)
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. local keyUp = true
  2. cursorPos = {x = 1, y = 2}
  3. enter = false
  4. function reader(currentString)
  5. local t2, key = os.pullEvent()
  6. if t2 == "key_up" then keyUp = true end
  7. if keyUp == true then
  8. if t2 == "char" then
  9. keyUp = false
  10. return currentString .. key
  11. end
  12. if key == 259 and t2 == "key" then
  13. keyUp = false
  14. return string.sub(currentString, 1, #currentString-1)
  15. end
  16. if key == 257 and t2 == "key" then
  17. history = 0
  18. enter = true
  19. end
  20. end
  21. return currentString
  22. end
  23. --[[local myString = ""
  24. local lastString = ""
  25.  
  26. while true do
  27. myString = reader(myString)
  28. if(myString ~= lastString) then
  29. term.clear()
  30. term.setCursorPos(1,1)
  31. print(myString)
  32. lastString = myString
  33. end
  34. end--]]
  35. return reader
Advertisement
Add Comment
Please, Sign In to add comment