I’ve added chat emotes, and commands to my chat, but how do I check for several cases of inputs, and if none of them just do a normal one. e.g.
If /dance
Then…
If /Smile
Then…
And in the end, if nothing of the ones above, then do normal text. How do I do this context of many if cases, or could I use a wild card, to check if first character of the string is a “/” … Cutout from the code (.js):
if(inputField == "/smile")
{
inputField = "ARRRRRRRRRRRRRRRGH SMILE!";
}
else
{
// Normal chat output would go here.
}
Use a Switch-Case :
private var inputField : String = "/smile";
switch(inputField )
{
case "/smile" :
// do stuff for condition 1
outputField = "ARRRRRRRRRRRRRRRGH SMILE!";
break;
case "/frown" :
// do stuff for condition 2
outputField = "why so down?";
break;
case "/angry" :
// do stuff for condition 3
outputField = "Look Out";
break;
default :
// do stuff if none of the above
outputField = "Nice Day !";
break;
}