Trying to program random response messages in Quest

bitterkarella
24 Aug 2016, 01:56

I have kind of a random question, which might be incredibly obvious or maybe isn't possible to do in Quest.

In my game, I've set it up so that there's a radio in a particular room. When the player enters that room, I'd like to have the radio periodically emit some background chatter, pulling randomly from a list of pre-written phrases every five seconds or so.

I tried something like this with the "play a message 5 seconds after entering the room" command, but (1) the game will continue running down the list of responses even after the player has left the room and I want the responses ONLY to happen while the player is in the room with the radio object and (2) I can't really get it to be random.

I'm not sure if I'm explaining that very well, but any help would be most appreciated. Thanks muchly!


The Pixie
24 Aug 2016, 08:39

I would create a timer, that prints a message, and use a text processor command to make it random. The format is like this:

{random:First option:Second option:Third}

To have it start when the player enters the room, on the room's Scripts tab, in the "After entering the room" section, do Enable timer, and in the "After leaving the room", do Disable timer.


bitterkarella
26 Aug 2016, 07:24

Thanks! That's very helpful! Stupid follow-up question: Although the random messages display perfectly, they don't appear to trigger the autoscroll. So the messages will just keep piling up un they trail off screen unless I manually scroll. Is there a way to make them trigger the autoscroll the same way that other messages do?


Watcher55
26 Aug 2016, 21:35

Yes, messages after timeout scripts don't seem to scroll. After printing the text, just do:
JS.scrollToEnd ()


XanMag
27 Aug 2016, 02:01

Or, place JS.scrolltoEnd() in the game scripts tab under the 'Turn scripts - run after every turn the player takes in this game' section. Should work that way to and you'd only have to do it once.


bitterkarella
27 Aug 2016, 03:38

Cool, thanks! Much obliged!