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);
- say(npc, "I can read: ");
- say(npc, "I can see you said this: ");
- say(npc, "");
- }
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment