SHARE
TWEET

Favorite Game Setting Thing ChatJS

atm959 Jun 4th, 2016 (edited) 154 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var favGame = ""; //Favorite game name
  2. var currentGame = ""; //Current game name
  3. var favConsole = ""; //Favorite game console
  4. //The HTML stuff for the text.
  5. document.getElementById("sidepane").innerHTML += "<strong>Your Statistics:</strong><br>";
  6. favGame = readStorage("favoriteGame");
  7. document.getElementById("sidepane").innerHTML += "<p style=\"margin: 0 0 0 0\" id=\"favgame\">Favorite game: \"" + favGame + "\"</p>";
  8. currentGame = readStorage("currentGame");
  9. document.getElementById("sidepane").innerHTML += "<p style=\"margin:0 0 0 0\" id=\"currentgame\">Current game: \"" + currentGame + "\"</p>";
  10. favConsole = readStorage("favConsole");
  11. document.getElementById("sidepane").innerHTML += "<p style=\"margin: 0 0 0 0\" id=\"favconsole\">Favorite console: \"" + favConsole + "\"</p>";
  12. commands.push(new Command("games", function(str){ //Push the command to the command stack
  13.     //Storage for favorite game: "favoriteGame"
  14.     //Storage for current game: "currentGame"
  15.     //Storage for favorite console: "favConsole"
  16.     favGame = "";
  17.     currentGame = "";
  18.     favConsole = "";
  19.     var args = str.split(" "); //Split the arguments string into separate parts and put them into an array
  20.     var i = 0; //Used for any for loops.
  21.     if(args[1] == "favorite"){ //If the first argument is "favorite"
  22.         if(args[2] == "set"){ //If the second argument is "set"
  23.             for(i = 3; i <= args.length - 1; i++){ //Read through the remaining arguments, join to string
  24.                 if(i == 3){ //If the argument is 3, then it is the first word of the title
  25.                     favGame = favGame + args[i]; //Take the first word of the title and put it into string
  26.                 } else { //Otherwise, it is all of the other words in the title
  27.                     favGame = favGame + " " + args[i]; //Take other words of title, add a space and word
  28.                 }
  29.             }
  30.             document.getElementById("favgame").innerHTML = "Favorite game: \"" + favGame + "\"";
  31.             writeStorage("favoriteGame", favGame); //Store the data
  32.             sendMessage("/me set their favorite game to: \"" + favGame + "\"."); //Send the message
  33.         } else if(args[2] == "tell"){ //If the second argument is "tell"
  34.             favGame = readStorage("favoriteGame"); //Read the data, store into favGame
  35.             sendMessage("/me - favorite game is: \"" + favGame + "\"."); //Send the message
  36.         } else if(args[2] == "recall"){ //If the second argument is "recall"
  37.             favGame = readStorage("favoriteGame"); //Read the data, store into favGame
  38.             systemMessage("Your favorite game is: \"" + favGame + "\"."); //Show the message
  39.         }
  40.     } else if(args[1] == "current"){ //If the first argument is "current"
  41.         if(args[2] == "set"){ //If the second argument is "set"
  42.             for(i = 3; i <= args.length - 1; i++){ //Read through the remaining arguments, join to string
  43.                 if(i == 3){ //If the argument is 3, then it is the first word in the title
  44.                     currentGame = currentGame + args[i]; //Take the first word of the title, put into string
  45.                 } else { //Otherwise, it is all of the other words in the title
  46.                     currentGame = currentGame + " " + args[i]; //Take remaining args, add with space
  47.                 }
  48.             }
  49.             document.getElementById("currentgame").innerHTML = "Current game: \"" + currentGame + "\"";
  50.             writeStorage("currentGame", currentGame); //Store the data
  51.             sendMessage("/me is currently playing: \"" + currentGame + "\"."); //Send the message
  52.         } else if(args[2] == "clear"){ //If the second argument is "clear"
  53.             currentGame = ""; //Empty out the string
  54.             document.getElementById("currentgame").innerHTML = "Current game: \"" + currentGame + "\"";
  55.             writeStorage("currentGame", currentGame); //Write the data
  56.             sendMessage("/me is not currently playing a game.");
  57.         } else if(args[2] == "tell"){ //If the second argument is "tell"
  58.             currentGame = readStorage("currentGame"); //Read the data
  59.             if(currentGame == ""){ //If the string is blank
  60.                 sendMessage("/me - not currently playing a game."); //Send the message
  61.             } else { //Otherwise, the string is not empty
  62.                 sendMessage("/me - currently playing: \"" + currentGame + "\"."); //Send the message
  63.             }
  64.         } else if(args[2] == "recall"){ //If the second argument is "recall"
  65.             currentGame = readStorage("currentGame"); //Read the data
  66.             if(currentGame == ""){ //If the string is blank
  67.                 systemMessage("You are not currently playing a game."); //Send the message
  68.             } else { //Otherwise, the string is not empty
  69.                 systemMessage("You are currently playing: \"" + currentGame + "\"."); //Send the message
  70.             }
  71.         }
  72.     } else if(args[1] == "console"){ //If the first argument is "system"
  73.         if(args[2] == "set"){ //If the second argument is "set"
  74.             for(i = 3; i <= args.length - 1; i++){ //Read through the remaining arguments
  75.                 if(i == 3){ //If it is the first word in the console name, put it into the string
  76.                     favConsole = favConsole + args[i]; //Put the word into favConsole
  77.                 } else { //Otherwise, it is any of the other words in the console name
  78.                     favConsole = favConsole + " " + args[i]; //Add to string with a space separating
  79.                 }
  80.             }
  81.             document.getElementById("favconsole").innerHTML = "Favorite console: \"" + favConsole + "\"";
  82.             writeStorage("favConsole", favConsole); //Store the data
  83.             sendMessage("/me has set their favorite console to: \"" + favConsole + "\"."); //Send the message
  84.         } else if(args[2] == "tell"){ //If the second argument is "tell"
  85.             favConsole = readStorage("favConsole"); //Read the data
  86.             sendMessage("/me - favorite console is: \"" + favConsole + "\"."); //Send the message
  87.         } else if(args[2] == "recall"){ //If the second argument is "recall"
  88.             favConsole = readStorage("favConsole"); //Read the data
  89.             systemMessage("Your favorite console is: \"" + favConsole + "\"."); //Send the message
  90.         }
  91.     }
  92. }));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top