Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tier = 0;
- say(npc, "Yo I'm a dinosaur, so rawr and stuff.");
- function onchat(player, msg) {
- msg = msg.toLowerCase();
- msg = msg.replace(",", " , ");
- msg = msg.replace(".", " . ");
- msg = msg.replace("!", " ! ");
- msg = msg.replace("?", " ? ");
- var msgArray = msg.split(" ");
- if(msg.contains("sell") || msg.contains("buy") || msg.contains("trade")){
- var canArray = ["can", "may", "could", "do"];
- var youArray = ["you", "u", "ya"];
- var tradeArray = ["sell", "buy", "trade"];
- var endSentenceArray = ["?", "!", "."];
- var andArray = ["and", "also", "btw"];
- var numberArray = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
- var wordI = "i";
- var wordComma = ",";
- var sentence = checkSentence(tradeArray, canArray, youArray, endSentenceArray, andArray, wordI, wordComma, numberArray);
- debugMessages(sentence);
- }
- }
- function checkSentence(msgArray, canArray, youArray, tradeArray, endSentenceArray, andArray, wordI, wordComma, numberArray){
- var ArrayOutput = [];
- var words_output = [];
- var mainLayout_output = ["normal"];
- var layout1_output = [];
- var layout2_output = [];
- for (var i = 0; i < msgArray.length; i++){
- if(canArray.indexOf(msgArray[i]) > -1){
- words_output.push("canArray");
- }else if(youArray.indexOf(msgArray[i]) > -1){
- words_output.push("youArray");
- }else if(tradeArray.indexOf(msgArray[i]) > -1){
- words_output.push("tradeArray");
- mainLayout_output.push("objective");
- }else if(endSentenceArray.indexOf(msgArray[i]) > -1){
- words_output.push("endSentenceArray");
- if(msgArray[i] == "!"){
- if(msgArray[i + 1] == undefined || numberArray.indexOf(msgArray[i + 1]) > -1 || endSentenceArray.indexOf(msgArray[i + 1]) > -1){
- mainLayout_output[0] = "yelling";
- }
- }else if(msgArray[i] == "?"){
- if(mainLayout_output[mainLayout_output.length - 1] == "objective"){
- mainLayout_output[mainLayout_output.length - 1] = "question";
- }else if(mainLayout_output[mainLayout_output.length - 2] == "objective"){
- mainLayout_output[mainLayout_output.length - 2] = "question";
- }
- }
- }else if(msgArray[i] == wordI){
- words_output.push("wordI");
- }else if(msgArray[i] == wordComma){
- words_output.push("wordComma");
- layout1_output = mainLayout_output;
- mainLayout_output = ["normal"];
- if(andArray.indexOf(msgArray[i + 1]) > -1){
- words_output.push("andArray");
- layout1_output = mainLayout_output;
- mainLayout_output = ["normal"];
- }
- }
- }
- layout2_output = mainLayout_output;
- ArrayOutput = [words_output, layout1_output, layout2_output];
- return ArrayOutput;
- }
- function debugMessages(sentence){
- var words_output = sentence[0];
- var layout1 = sentence[1];
- var layout2 = sentence[2];
- var str_words_output = "null";
- var str_layout1 = "null";
- var str_layout2 = "null";
- for (var i = 0; i < words_output.length; i++){
- if(words_output[i] != undefined){
- str_words_output = str_words_output, " ", words_output[i];
- }
- }
- for (var i = 0; i < layout1.length; i++){
- if(layout1[i] != undefined){
- str_layout1 = str_layout1, " ", layout1[i];
- }
- }
- for (var i = 0; i < str_layout2.length; i++){
- if(str_layout2[i] != undefined){
- str_str_layout2 = str_str_layout2, " ", str_layout2[i];
- }
- }
- if(str_words_output != "null"){
- say(npc, "I can read: ", str_words_output);
- }
- if(str_layout1 != "null"){
- say(npc, "I can see you said this: ", str_layout1);
- }
- if(str_layout2 != "null"){
- say(npc, "", str_layout2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment