coolnickname

Untitled

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