Easy way to change a string list to another?

thanos
04 May 2018, 21:29

I have a string list with idling messages (e.g. "Joe looks worried/Joe spits/etc", from which I PickOneString every now and then. When something happens in the game, I want to change the whole string list to include other messages.

What's the easiest/more compact way to do it?


K.V.
04 May 2018, 22:39

Hello.

Let's say we have this already:

game.NPC_list = Split("Fred;Barney", ";")

We can do this:

list add (game.NPC_list, "Wilma")
list add (game.NPC_list, "Betty")

We could also do:

list2 = Split("Pebbles;Bam-Bam", ";")
game.NPC_list = ListCombine(game.NPC_list, list2)

You can do this:

list1 + list2

...and that will work in Quest, but if you ever convert your game to a website using QuestJS (if I ever get it up and running), Javascript will turn those two arrays into a string, so I'm sticking with ListCombine().


http://docs.textadventures.co.uk/quest/functions/#list

http://docs.textadventures.co.uk/quest/using_lists.html


K.V.
04 May 2018, 22:43

PS (sort of on-topic)

When using Split(), we can now do this Split("one;two") rather than this Split("one;two", ";").

This is a change in the C# code in Quest, which means it does not get added to your published .quest file. This means anyone playing your game on an older version of Quest will run into Problems if you only feed one parameter to Split().


Doctor Agon
05 May 2018, 00:28

Not sure if it's relevant to what you're trying to do, but have you seen this thread on random scenery:
http://textadventures.co.uk/forum/samples/topic/5178/how-to-add-scenery-to-several-rooms-at-once-no-coding-required
I use it quite often, it lets you add a random scenic object to the room you are in. Something though I recently discovered, is that you can use text processor codes {...text...} inside the string list of the 'flavour' object.
eg A rabbit {random:watches you:twitches it's nose}.
Joe {random:watches TV:spits:drinks tea}.