I have a pattern matching chatbot where I use the following to select at random the various responses.
Is there an easy way to change the above to where it always selects message[0] first and then goes in numerical order. For example message[0] then message[1] then message[2] then message[3]. After message[3] is triggered then it starts back to message[0]
Thanks!
Code:
if (input.search("favorite food")!= -1) {
message[0] = "Pizza!";
message[1] = "Sub sandwich.";
message[2] = "Tacos.";
message[3] = "Cheeseburger";
[COLOR=red]num = [Math.floor(Math.random()*4)][/color]
document.result.result.value = message[num];
return true;}
Is there an easy way to change the above to where it always selects message[0] first and then goes in numerical order. For example message[0] then message[1] then message[2] then message[3]. After message[3] is triggered then it starts back to message[0]
Thanks!