Advertisement
Westar777

Untitled

Jan 20th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. -- RCPanel by Westar
  2. version = '1'
  3.  
  4. function getMonitor()
  5. return peripheral.find('monitor');
  6. end
  7. function getModem()
  8. return peripheral.find('modem');
  9. end
  10. function split(s, delimiter)
  11. result = {};
  12. for match in (s..delimiter):gmatch("(.-)"..delimiter) do
  13. table.insert(result, match);
  14. end
  15. return result;
  16. end
  17. function menu(options)
  18. local sid = 0;
  19. local maxSid = 0;
  20.  
  21. while true do
  22. for k, v in pairs(options) do
  23. if k > maxSid then
  24. maxSid = k;
  25. end
  26. if sid == k then
  27. print('['..v.label..']');
  28. else
  29. print(' '..v.label..' ');
  30. end
  31. end
  32. local sEvent, param = os.pullEvent("key");
  33. if sEvent == 'key' then
  34. if param == 200 then
  35. if sid > 0 then
  36. sid = sid -1
  37. elseif sid == 0 then
  38. sid = maxSid;
  39. end
  40. elseif param == 208 then
  41. if sid < maxSid then
  42. sid = sid + 1;
  43. elseif sid == maxSid then
  44. sid = 0;
  45. end
  46. elseif param == 28 then
  47. return sid
  48. end
  49. end
  50. end
  51. end
  52.  
  53.  
  54. monitor = getMonitor();
  55. state = 0;
  56.  
  57. function mainDisplay()
  58. print('RCPanel v'..version..' by Westar');
  59. newState = menu({
  60. {
  61. value = 1,
  62. label = 'Turtle'
  63. },
  64. {
  65. value = 2,
  66. label = 'Stats'
  67. },
  68. {
  69. value = 3,
  70. label = 'WIP'
  71. }
  72. });
  73. doState(newState);
  74. end
  75.  
  76. function doState(newState)
  77. state = newState;
  78. if state == 0 then
  79. mainDisplay();
  80. end
  81. if state == 1 then
  82. turtleDisplay();
  83. end
  84.  
  85. end
  86.  
  87. doState(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement