Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const wide = 1;
- const cursed = 2;
- function is_modifier(str)
- {
- if(str === "!w") {
- return 1;
- }
- else if(str === "!c") {
- return 2;
- }
- return 0;
- }
- function is_emote(str)
- {
- // todo
- return true;
- }
- const str = "!w Kappa !c !w PogChamp !c PogChamp PogChamp"
- const words = str.split(" ");
- const output = [];
- for(let i = 0; i < words.length; i += 1) {
- const modifier = is_modifier(words[i]);
- if(modifier > 0) {
- // If the previous text/word was a non modifier emote, add a modifier to that emote
- if(output.length > 0 && output[output.length - 1].is_emote && !output[output.length - 1].is_modifier) {
- output[output.length - 1].modifiers.push(modifier);
- }
- else {
- // Otherwise, add the modifier as an emote
- output.push({text: words[i], is_emote: true, is_modifier: true});
- }
- }
- else if(is_emote(words[i])) {
- output.push({text: words[i], is_emote: true, is_modifier: false, modifiers: []});
- }
- else {
- output.push({text: words[i], is_emote: false, is_modifier: false});
- }
- }
- console.table(output);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement