AI Chatting
Moderator: Moderators
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
AI Chatting
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?
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: AI Chatting
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.
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Re: AI Chatting
Okay, thanks!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.
- Frisbeetarian
- Jedi

- Posts: 1233
- Joined: Wed Sep 12, 2007 3:13 pm
Re: AI Chatting
It was also in the FAQ...
http://www.gametoast.com/forums/viewtop ... 04#p140204
http://www.gametoast.com/forums/viewtop ... 04#p140204
- Fierfek
- High General

- Posts: 805
- Joined: Wed Jul 01, 2009 4:38 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Somewhere in the Galaxy (Most Likely Scrapping Tinnies)
Randomized Message Texts
Okay, reading that topic now. Thanks again!Frisbeetarian wrote:It was also in the FAQ...
http://www.gametoast.com/forums/viewtop ... 04#p140204
-------------
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:
Code: Select all
math.random(1,10)Topics merged. -Staff
-
kinetosimpetus
- Imperial Systems Expert

- Posts: 2381
- Joined: Wed Mar 25, 2009 4:15 pm
- Projects :: A secret project
Re: AI Chatting
(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- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: AI Chatting
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.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
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)
