Advertisement
Guest User

In-game Feedback visualizer by Mr. Burguers (beta v0 19/10)

a guest
Oct 19th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Run this from the feedback page, through your browser's development console, usually opened by CTRL+SHIFT+J.
  2. // This will "download" a .cfg file, save it in /Team Fortress 2/tf/cfg/
  3. // Load up your map in TF2 and type in "exec _burg_show_fb_YOURMAPNAME.cfg"
  4. // This should give you visible notes, green lasers representing feedback sightlines, and general feedback in the console.
  5. function download(data, filename) {
  6.     let a = document.createElement('a');
  7.     a.href = window.URL.createObjectURL(new Blob([data]));
  8.     a.setAttribute('download', filename);
  9.     document.body.appendChild(a);
  10.     setTimeout(() => {
  11.         a.click();
  12.         document.body.removeChild(a);
  13.         setTimeout(() => {
  14.             window.URL.revokeObjectURL(a.href);
  15.         }, 250);
  16.     }, 66);
  17.     return true;
  18. }
  19. function escStrQ(s) {return s.replace(/[";]/g, '')}
  20. function escStr(s) {return s.replace(/[;]/g, '')}
  21. function addCmd(cmd) {cfg+=escStr(cmd)+'\n'}
  22. function addAnnot(look, pos, disp) {
  23.     disp = escStrQ(disp);
  24.     addCmd('setpos_exact ' + look);
  25.     addCmd('ent_create training_annotation origin "' + look + '" lifetime -1 offset 0 display_text "' + disp + '"');
  26.     addCmd('ent_create info_target targetname _t' + t_iter);
  27.     t_iter++;
  28.     // Raise laser position to player view
  29.     pos = pos.split(' ');
  30.     pos[2] = parseFloat(pos[2]) + 71; // Raise start Z by average class eye height (71)
  31.     pos = pos.join(' ');
  32.     addCmd('setpos_exact ' + pos);
  33.     addCmd('ent_create env_beam targetname _t' + t_iter + ' spawnflags 1 life 0 BoltWidth 2 LightningStart _t' + t_iter + ' LightningEnd _t' + (t_iter - 1) + ' tripwire 0 renderamt 255 rendercolor "0 255 0" damage 0 ClipType 0 NoiseAmplitude 0 texture sprites/laserbeam.spr');
  34.     t_iter++;
  35. }
  36. var comments = document.getElementsByClassName('comments')[0].children;
  37. var map = window.top.location.href.split("/")[4];
  38. var gf = [];
  39. var fb = [];
  40. var cfg = '';
  41. var t_iter = 0;
  42. for (let i = 0; i < comments.length; i++) {
  43.     let has_coords = comments[i].children[1].innerText.indexOf("made an annotation at") != -1;
  44.     let commenter = comments[i].children[1].children[1].children[0].innerText;
  45.     let comment = comments[i].children[2].innerText;
  46.     if (has_coords) {
  47.         let look = comments[i].children[1].children[1].children[1].innerText;
  48.         let pos = comments[i].children[1].children[1].children[2].innerText;
  49.         fb.push([commenter, comment, look, pos]);
  50.     } else {
  51.         gf.push([commenter, comment]);
  52.     }
  53. }
  54. addCmd('sv_cheats 1;sv_allow_wait_command 1;setang_exact 90 0 0;con_filter_text_out "Failed to load sound";con_filter_enable 1');
  55. addCmd('echo ==================== General feedback ====================');
  56. for (let i = 0; i < gf.length; i++) {
  57.     addCmd('echo ' + gf[i][0] + ': ' + gf[i][1]); // AUTHOR: TEXT
  58. }
  59. addCmd('echo ==========================================================');
  60. for (let i = 0; i < fb.length; i++) {
  61.     addAnnot(fb[i][2], fb[i][3], fb[i][1] + ' - ' + fb[i][0]); // TEXT - AUTHOR
  62. }
  63. addCmd('ent_fire training_annotation Show');
  64. // addCmd('con_filter_text_out ""');
  65. // addCmd('con_filter_enable 0');
  66. download(cfg, '_burg_show_fb_' + map + '.cfg'/*, 'text/plain'*/);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement