Advertisement
Tkap1

Untitled

Nov 17th, 2023
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. const wide = 1;
  3. const cursed = 2;
  4.  
  5. function is_modifier(str)
  6. {
  7.     if(str === "!w") {
  8.         return 1;
  9.     }
  10.     else if(str === "!c") {
  11.         return 2;
  12.     }
  13.     return 0;
  14. }
  15.  
  16. function is_emote(str)
  17. {
  18.     // todo
  19.     return true;
  20. }
  21.  
  22. const str = "!w Kappa !c !w PogChamp !c PogChamp PogChamp"
  23. const words = str.split(" ");
  24. const output = [];
  25. for(let i = 0; i < words.length; i += 1) {
  26.     const modifier = is_modifier(words[i]);
  27.     if(modifier > 0) {
  28.         // If the previous text/word was a non modifier emote, add a modifier to that emote
  29.         if(output.length > 0 && output[output.length - 1].is_emote && !output[output.length - 1].is_modifier) {
  30.             output[output.length - 1].modifiers.push(modifier);
  31.         }
  32.         else {
  33.             // Otherwise, add the modifier as an emote
  34.             output.push({text: words[i], is_emote: true, is_modifier: true});
  35.         }
  36.     }
  37.     else if(is_emote(words[i])) {
  38.         output.push({text: words[i], is_emote: true, is_modifier: false, modifiers: []});
  39.     }
  40.     else {
  41.         output.push({text: words[i], is_emote: false, is_modifier: false});
  42.     }
  43. }
  44. console.table(output);
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement