Guest User

Robeats

a guest
Mar 20th, 2023
7,886
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 KB | None | 1 0
  1. --// variables
  2.  
  3. local player = game:GetService("Players").LocalPlayer;
  4.  
  5. local accuracy_bounds = {
  6. Perfect = -0,
  7. Great = -100,
  8. Okay = -100
  9. };
  10.  
  11. local accuracy_names = {"Perfect", "Great", "Okay"};
  12.  
  13. local accuracy = shared.accuracy or "Perfect"; -- Perfect, Great, Okay, Random
  14. local note_time_target = accuracy_bounds[accuracy];
  15.  
  16. local track_system;
  17.  
  18. --// functions
  19.  
  20. local function get_track_action_functions(track_system)
  21. local press_track, release_track;
  22.  
  23. for index, track_function in next, track_system do
  24. if type(track_function) == "function" then
  25. local constants = getconstants(track_function);
  26.  
  27. if table.find(constants, "press") then
  28. press_track = track_function;
  29.  
  30. if release_track then
  31. break;
  32. end;
  33. elseif table.find(constants, "release") then
  34. release_track = track_function;
  35.  
  36. if press_track then
  37. break;
  38. end;
  39. end;
  40. end;
  41. end;
  42.  
  43. return press_track, release_track;
  44. end;
  45.  
  46. local function get_local_track_system(session)
  47. local local_slot_index = getupvalue(session.set_local_game_slot, 1);
  48.  
  49. for index, session_function in next, session do
  50. if type(session_function) == "function" then
  51. local object = getupvalues(session_function)[1];
  52.  
  53. if type(object) == "table" and rawget(object, "count") and object:count() <= 4 then
  54. return object:get(local_slot_index);
  55. end;
  56. end;
  57. end;
  58. end;
  59.  
  60. --// get tracksystem
  61.  
  62. for index, module in next, getloadedmodules() do
  63. local module_value = require(module);
  64.  
  65. if type(module_value) == "table" then
  66. local new_function = rawget(module_value, "new");
  67.  
  68. if new_function then
  69. local first_upvalue = getupvalues(new_function)[1];
  70.  
  71. if type(first_upvalue) == "table" and rawget(first_upvalue, "twister") then
  72. track_system = module_value;
  73.  
  74. break;
  75. end;
  76. end;
  77. end;
  78. end;
  79.  
  80. --// main autoplayer
  81.  
  82. local old_track_system_new = track_system.new;
  83. track_system.new = function(...)
  84. local track_functions = old_track_system_new(...);
  85. local arguments = {...};
  86.  
  87. if arguments[2]._players._slots:get(arguments[3])._name == player.Name then -- make sure its only autoplaying your notes if in multiplayer
  88. for index, track_function in next, track_functions do
  89. local upvalues = getupvalues(track_function);
  90.  
  91. if type(upvalues[1]) == "table" and rawget(upvalues[1], "profilebegin") then
  92. local notes_table = upvalues[2];
  93.  
  94. track_functions[index] = function(self, slot, session)
  95. local local_track_system = get_local_track_system(session);
  96. local press_track, release_track = get_track_action_functions(local_track_system);
  97.  
  98. local test_press_name = getconstant(press_track, 10);
  99. local test_release_name = getconstant(release_track, 6);
  100.  
  101. if accuracy == "Random" then
  102. note_time_target = accuracy_bounds[accuracy_names[math.random(1, 3)]];
  103. end;
  104.  
  105. for note_index = 1, notes_table:count() do
  106. local note = notes_table:get(note_index);
  107.  
  108. if note then
  109. local test_press, test_release = note[test_press_name], note[test_release_name];
  110.  
  111. local note_track_index = note:get_track_index(note_index);
  112. local pressed, press_result, press_delay = test_press(note);
  113.  
  114. if pressed and press_delay >= note_time_target then
  115. press_track(local_track_system, session, note_track_index);
  116.  
  117. session:debug_any_press();
  118.  
  119. if rawget(note, "get_time_to_end") then -- if its not a long note then release right after
  120. delay(math.random(5, 18) / 100, function()
  121. release_track(local_track_system, session, note_track_index);
  122. end);
  123. end;
  124. end;
  125.  
  126. if test_release then
  127. local released, release_result, release_delay = test_release(note);
  128.  
  129. if released and release_delay >= note_time_target then
  130. delay(math.random(2, 5) / 100, function()
  131. release_track(local_track_system, session, note_track_index);
  132. end);
  133. end;
  134. end;
  135. end;
  136. end;
  137.  
  138. return track_function(self, slot, session);
  139. end;
  140. end;
  141. end;
  142. end;
  143.  
  144. return track_functions;
  145. end;
Add Comment
Please, Sign In to add comment