coolnickname

Untitled

Jul 12th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. var tier = 0;
  2.  
  3. say(npc, "I only love Nico");
  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. debugMessages(sentence);
  26. say(npc, "Script finished");
  27. }
  28. }
  29.  
  30. function checkSentence(msgArray, canArray, youArray, tradeArray, endSentenceArray, andArray, wordI, wordComma, numberArray){
  31. say(npc, "checkSentence called");
  32. var ArrayOutput = [];
  33. var words_output = [];
  34. var mainLayout_output = ["normal"];
  35. var layout1_output = [];
  36. var layout2_output = [];
  37.  
  38. for (var i = 0; i < msgArray.length; i++){
  39.  
  40. if(canArray.indexOf(msgArray[i]) > -1){
  41.  
  42. words_output.push("canArray");
  43.  
  44. }else if(youArray.indexOf(msgArray[i]) > -1){
  45.  
  46. words_output.push("youArray");
  47.  
  48. }else if(tradeArray.indexOf(msgArray[i]) > -1){
  49.  
  50. words_output.push("tradeArray");
  51. mainLayout_output.push("objective");
  52.  
  53. }else if(endSentenceArray.indexOf(msgArray[i]) > -1){
  54.  
  55. words_output.push("endSentenceArray");
  56. if(msgArray[i] == "!"){
  57. if(msgArray[i + 1] == undefined || numberArray.indexOf(msgArray[i + 1]) > -1 || endSentenceArray.indexOf(msgArray[i + 1]) > -1){
  58. mainLayout_output[0] = "yelling";
  59. }
  60. }else if(msgArray[i] == "?"){
  61. if(mainLayout_output[mainLayout_output.length - 1] == "objective"){
  62. mainLayout_output[mainLayout_output.length - 1] = "question";
  63. }else if(mainLayout_output[mainLayout_output.length - 2] == "objective"){
  64. mainLayout_output[mainLayout_output.length - 2] = "question";
  65. }
  66. }
  67. }else if(msgArray[i] == wordI){
  68.  
  69. words_output.push("wordI");
  70.  
  71. }else if(msgArray[i] == wordComma){
  72.  
  73. words_output.push("wordComma");
  74.  
  75. layout1_output = mainLayout_output;
  76. mainLayout_output = ["normal"];
  77.  
  78. if(andArray.indexOf(msgArray[i + 1]) > -1){
  79. words_output.push("andArray");
  80. layout1_output = mainLayout_output;
  81. mainLayout_output = ["normal"];
  82. }
  83.  
  84. }
  85. }
  86. layout2_output = mainLayout_output;
  87. ArrayOutput = [words_output, layout1_output, layout2_output];
  88. return ArrayOutput;
  89. say(npc, "Checksentence finished");
  90. }
  91.  
  92. function debugMessages(sentence){
  93. say(npc, "debugMessages called");
  94. var words_output = sentence[0];
  95. var layout1 = sentence[1];
  96. var layout2 = sentence[2];
  97. var str_words_output = "null";
  98. var str_layout1 = "null";
  99. var str_layout2 = "null";
  100.  
  101. for (var i = 0; i < words_output.length; i++){
  102. say(npc, "Debugging words_output");
  103. if(words_output[i] != undefined){
  104. say(npc, words_output[i]);
  105. str_words_output = str_words_output, " ", words_output[i];
  106. }
  107. }
  108.  
  109. for (var i = 0; i < layout1.length; i++){
  110. say(npc, "debugging layout1");
  111. if(layout1[i] != undefined){
  112. say(npc, words_output[i]);
  113. str_layout1 = str_layout1, " ", layout1[i];
  114. }
  115. }
  116.  
  117. for (var i = 0; i < str_layout2.length; i++){
  118. say(npc, "Debugging layout2");
  119. if(str_layout2[i] != undefined){
  120. say(npc, words_output[i]);
  121. str_layout2 = str_layout2, " ", str_layout2[i];
  122. }
  123. }
  124. say(npc, str_words_output);
  125. if(str_words_output != "null"){
  126. say(npc, "I can read: ", str_words_output);
  127. }
  128. if(str_layout1 != "null"){
  129. say(npc, "I can see you said this: ", str_layout1);
  130. }
  131. if(str_layout2 != "null"){
  132. say(npc, "", str_layout2);
  133. }
  134. say(npc, "Debugmessages finished");
  135. }
Advertisement
Add Comment
Please, Sign In to add comment