Advertisement
Marlingaming

System Screen API

Nov 20th, 2022 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. function Clear()
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. end
  5.  
  6. function OptionPrompt_list(y,Options)
  7. local n = 1
  8. while true do
  9. for i = 1, #Options do
  10. term.setCursorPos(1,y + (i - 1))
  11. term.clearLine()
  12. if n == i then term.write(">> "..Options[i]) else term.write("-"..Options[i]) end
  13. end
  14. local a, b = os.pullEvent("key")
  15. if b == keys.w and n > 1 then n = n - 1 end
  16. if b == keys.s and n < #Options then n = n + 1 end
  17. if b == keys.enter then break end
  18. end
  19. return n
  20. end
  21.  
  22. function OptionPrompt_box(y,Options)
  23. local n = 1
  24. while true do
  25. local Text = Options[n]
  26. term.setCursorPos(1,y)
  27. term.clearLine()
  28. if n > 1 then Text = "<< "..Text end
  29. if n < #Options then Text = Text.." >>" end
  30. term.write(Text)
  31. local a, b = os.pullEvent("key")
  32. if b == keys.a and n > 1 then n = n - 1 end
  33. if b == keys.d and n < #Options then n = n + 1 end
  34. if b == keys.enter then break end
  35. end
  36. return n
  37. end
  38.  
  39. function TextField()
  40. local input
  41. repeat
  42. local a, b = os.pullEvent("key")
  43. if b ~= keys.enter then input = read() end
  44. until b == keys.enter
  45. return input
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement