PDA

View Full Version : $text question


louis1016
04-07-2011, 03:48 AM
Im trying to figure out if its possible to have an npc ask a player a question and use that response in the script. For example: I'm trying to create a script in which aedilles thrall asks the player to name a bot and then uses the quest::createbot function to create a bot with that name. Id really like for this to work, as my alternative is predefining names which Id rather not do. Can anyone please help me out?

trevius
04-07-2011, 05:48 AM
Yes, it is possible. You can use the $text variable and input it into a quest command just like any other variable that you may have created. Though, you will most likely want to add a filter on the text they enter to prevent them from adding special characters and such. If you search google for regular expression and perl and look for the regex to filter out all but letters, you can then set whatever you want as long as there is a quest command/object for it. You will also want to add in checks to make sure they aren't just hailing the NPC or using one of its other prompt key words (IE. if ($text !~ /Hail/i)).