proc/Told()
mob/tell(mob/M as mob in view(), msg as text)
usr << "You tell [M]: [msg]"
M.Told(msg)
mob/DemoGuy
Asked(msg)
if(findtext(msg,"hello")) src.tell(usr,"Hello.")
else if(findtext(msg,"hey")) src.tell(usr,"Hey to you too.")
else if(findtext(msg,"hola")) src.tell(usr,"Buenas Dias.")
else if(findtext(msg,"monkey")) src.tell(usr,"Mmm...Monkeys.")
else if(findtext(msg,"armedillo")) src.tell(usr,"In Montana!")
else if(findtext(msg,"dice")) src.tell(usr,"Go eat some chicken you freak!")
else if(findtext(msg,"DM")) src.tell(usr,"Hey, that's what I'm programmed in!")
Now, I'm not really happy with having a whole lot of if, else if, else if, else if's in this code. I tried the switch only to discover that it only likes "constant expressions", so that's not going to work. I was wondering if anyone has some suggestions for how to improve this?
var/list/phrases = list ("hey" = "Hey to you, too.","etc" = "And so forth.")
Then, in your proc:
for (var/t in src.phrases)
if (findtext(t,msg)) usr << "[phrases[t]]"
I don't know for sure that the src/usrs match what you were doing, but you should get the idea.