Page 1 of 1
AI Chatting
Posted: Mon Aug 24, 2009 7:15 pm
by Fierfek
In my map, I want to have a list of texts, that every 5 seconds or so, a random one appears on screen (eg. - every 5 seconds, scorch says something like "Look, fireworks!"), as if one of the AI is chatting. Is this possible, and if it is, how do I do it?
Re: AI Chatting
Posted: Mon Aug 24, 2009 7:41 pm
by Frisbeetarian
You just use the command ShowMessageText(). Put it on a timer and pick a string based on a random number. If you don't know how to use the function, search the assets; I already did that to find the function for you, it's not that hard.
Re: AI Chatting
Posted: Mon Aug 24, 2009 7:43 pm
by Fierfek
Frisbeetarian wrote:You just use the command ShowMessageText(). Put it on a timer and pick a string based on a random number. If you don't know how to use the function, search the assets; I already did that to find the function for you, it's not that hard.
Okay, thanks!
Re: AI Chatting
Posted: Mon Aug 24, 2009 7:45 pm
by Frisbeetarian
Randomized Message Texts
Posted: Mon Aug 24, 2009 11:47 pm
by Fierfek
Okay, reading that topic now. Thanks again!
-------------
I have a large list of strings in my localization, and I want to add in a script that displays a random one from level.RC1.texts. So far, I have this script to go from:
How do I implement that so it chooses a random string?
Topics merged. -Staff
Re: AI Chatting
Posted: Tue Aug 25, 2009 12:39 am
by kinetosimpetus
(might be different syntax, but something like...)
Code: Select all
randChat = math.random(1,10)
if randChat == 1 then
ShowMessageText(level.RC1.texts.1)
else if randChat == 2 then
ShowMessageText(level.RC1.texts.2)
end
Re: AI Chatting
Posted: Tue Aug 25, 2009 12:46 am
by Maveritchell
kinetosimpetus wrote:(might be different syntax, but something like...)
Code: Select all
randChat = math.random(1,10)
if randChat == 1 then
ShowMessageText(level.RC1.texts.1)
else if randChat == 2 then
ShowMessageText(level.RC1.texts.2)
end
You will need to put your string name in quotation marks, and your ShowMessageText should have a second argument mentioning the team it's being shown to.
Also, to refine that, it is easier to append a variable onto your strings (this is how the stock scripts do it, Felucia is a good example). Note that for the original poster, it will probably be easier to just do it as posted above.
Code: Select all
randChat = math.random(10)
ShowMessageText("level.RC1.texts" .. randChat, 1)
Also note that if you want your random int to be between 1 and something else, you can just put math.random(number) instead of math.random(1, number).