coolnickname

Untitled

Jul 12th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | None | 0 0
  1. var tier = 0;
  2.  
  3. say(npc, "Yo I'm a dinosaur, so rawr and stuff.");
  4.  
  5. function onchat(player, msg) {
  6. msg = msg.toLowerCase();
  7. msg = msg.replace(",", " , ");
  8. msg = msg.replace(".", " . ");
  9. msg = msg.replace("!", " . ");
  10. msg = msg.replace("?", " . ");
  11. var msgArray = msg.split(" ");
  12.  
  13. if(msg.contains("sell") || msg.contains("buy") || msg.contains("trade")){
  14.  
  15. var canArray = ["can", "may", "could", "do"];
  16. var youArray = ["you", "u", "ya"];
  17. var tradeArray = ["sell", "buy", "trade"];
  18. var endSentenceArray = ["?", "!", "."];
  19. var andArray = ["and", "also", "btw"];
  20. var numberArray = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
  21. var wordI = "i";
  22. var wordComma = ",";
  23.  
  24. var sentence = checkSentence(tradeArray, canArray, youArray, endSentenceArray, andArray, wordI, wordComma, numberArray);
  25.  
  26. say(npc, "I can read: ");
  27. say(npc, "I can see you said this: ");
  28. say(npc, "");
  29.  
  30. }
  31. }
  32.  
  33. function checkSentence(msgArray, canArray, youArray, tradeArray, endSentenceArray, andArray, wordI, wordComma, numberArray){
  34. var ArrayOutput = [];
  35. var words_output = [];
  36. var mainLayout_output = ["normal"];
  37. var layout1_output = [];
  38. var layout2_output = [];
  39.  
  40. for (var i = 0; i < msgArray.length; i++){
  41.  
  42. if(canArray.indexOf(msgArray[i]) > -1){
  43.  
  44. words_output.push("canArray");
  45.  
  46. }else if(youArray.indexOf(msgArray[i]) > -1){
  47.  
  48. words_output.push("youArray");
  49.  
  50. }else if(tradeArray.indexOf(msgArray[i]) > -1){
  51.  
  52. words_output.push("tradeArray");
  53. mainLayout_output.push("objective");
  54.  
  55. }else if(endSentenceArray.indexOf(msgArray[i]) > -1){
  56.  
  57. words_output.push("endSentenceArray");
  58. if(msgArray[i] == "!"){
  59. if(msgArray[i + 1] == undefined || numberArray.indexOf(msgArray[i + 1]) > -1 || endSentenceArray.indexOf(msgArray[i + 1]) > -1){
  60. mainLayout_output[0] = "yelling";
  61. }
  62. }else if(msgArray[i] == "?"){
  63. if(mainLayout_output[mainLayout_output.length - 1] == "objective"){
  64. mainLayout_output[mainLayout_output.length - 1] = "question";
  65. }else if(mainLayout_output[mainLayout_output.length - 2] == "objective"){
  66. mainLayout_output[mainLayout_output.length - 2] = "question";
  67. }
  68. }
  69. }else if(msgArray[i] == wordI){
  70.  
  71. words_output.push("wordI");
  72.  
  73. }else if(msgArray[i] == wordComma){
  74.  
  75. words_output.push("wordComma");
  76.  
  77. layout1_output = mainLayout_output;
  78. mainLayout_output = ["normal"];
  79.  
  80. if(andArray.indexOf(msgArray[i + 1]) > -1){
  81. words_output.push("andArray");
  82. layout1_output = mainLayout_output;
  83. mainLayout_output = ["normal"];
  84. }
  85.  
  86. }
  87. }
  88. layout2_output = mainLayout_output;
  89. ArrayOutput = [words_output, layout1_output, layout2_output];
  90. return ArrayOutput;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment