Login
Remember
IF Answers
Ask a Question

# How do I work with lists in Quest?

0 votes
58 views
asked Jun 27 in Authoring by DGNXFoxN (1 point)
edited Jun 28 by Alex

Within the Quest tool, how would I go about working with lists?

I have had answers with instructions in code form, but since I'm pretty new to this, I have no clue what to do with them.

- lists
- quest

commented Jul 6 by jaynabonne (141 points)
To be honest, the question as posted is a bit hard to answer. It's like asking someone "how do I work with wood?" And the answer is basically: well, it depends on what you want to do. It might be more helpful to ask questions based on things you want to accomplish. Then, if a list will suffice for what you're trying to do, someone can give you an example of that particular usage. (The reason I'm saying this is that often people will think they need to use X, when in reality, they need to use Y, and asking how to use X in that case just confuses things since it doesn't address the initial problem they wanted to solve to begin with.)

## 1 Answer

0 votes
answered Jun 27 by hegemonkhan (161 points)
edited Jun 28 by hegemonkhan

here's (a rare, lol) mostly non-code post for you, hehe:

within the GUI~Editor, there's two types of means~ways of making your game:

.1. initial creation ('adding'~'setting') before the game begins:

Add -> Object, Exit, Function, Verb, Command, Attribute, etc

example of adding~creating~intially_setting of Attributes:

'player' Player Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: player)
Attribute Name: strength
Attribute Type: int (integer)
Attribute Value: 100

.2. scripting (ACTION~EVENTS: creating~adding, setting, re-setting, removing, deleting, changing, altering, etc. At the beginning of the game and~or during the game):

(Object's Verb~Command~Function~Turnscript~Timer~etc) -> run as script -> add a~new script (the circle buttons)

example of scripting:

'strength potion' Object -> 'Verb' Tab -> add -> Name: consume -> (see below)

add new script -> variables -> 'set a variable or attribute' Script -> set variable player.strength = [expression] player.strength + 2

add a script -> output -> 'print a message' Script -> print message [expression] "You consume the strength potion, increasing your strength by 2, having now {player.strength} strength."

Lists and Dictionaries are a Type of Attribute ~ Attribute Type:

Attribute Types ~ Types of Attributes:

String Attributes
Boolean Attributes
Integer Attributes
Double Attributes
Object Attributes
Script Attributes
String List Attributes
Object List Attributes (this unfortunately doesn't exist in the GUI~Editor's 'add creation', so your only option is via the GUI~Editor's scripting or just doing~writing it in~as code)
String Dictionary Attributes
Object Dictionary Attributes
Script Dictinary Attributes

'Include Reference' Attributes (Libraries)
'Inherited' Attributes (Object Types)

so, for lists, examples:

adding~creation~initially_setting:

'player' Player Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)

(Object Name: player)
Attribute Name: favorite_foods
Attribute Type: string list
Attribute Value: (add, repeat as needed for each Value): pizza, hamburger, ice cream, chocolate, pasta, candy

or, via scripting instead (example):

'hk' Object -> 'Verb' Tab -> Add -> Name: foods -> (see below)

[run as script] -> add new script -> variables -> 'set a variable or attribute' Script -> (see below)

set variable hk.favorite_foods = [expression] NewStringList ()

add a script -> variables -> 'add a value to a list' Script -> (see below)

add to list hk.favorite_foods [text] pizza

add a script -> variables -> 'add a value to a list' Script -> (see below)

add to list hk.favorite_foods [text] hamburger

etc etc etc

as for actually then doing stuff with the lists... that's a whole behemoth beast in itself... not for this post, lol.

resources:

http://docs.textadventures.co.uk/quest/guides/using_lists.html
http://docs.textadventures.co.uk/quest/functions/newstringlist.html
http://docs.textadventures.co.uk/quest/functions/string/split.html
http://docs.textadventures.co.uk/quest/scripts/list_add.html
http://docs.textadventures.co.uk/quest/scripts/list_remove.html
http://docs.textadventures.co.uk/quest/functions/listcount.html
http://docs.textadventures.co.uk/quest/functions/listcontains.html
etc etc etc

commented Jun 27 by hegemonkhan (161 points)
the point of lists is that you can iterate (cycle, go through each Value) through the list, and select what (specific and~or random and~or All~Every) item (Value) from the list. This allows for doing some very cool stuff. Also, it's easy to add~remove items (Values) from the list too.
Do note that with Object Lists, you actually are NOT 'physically' doing anything with the Object, but rather 'virtually~logically'. For example, if you 'add an Object to an Object List', you are NOT actually moving that Object (from where ever it is located at) over into that Object List. So I can have 'pizza' be in 'my bedroom' Room Object's Objectlist, while the actual 'physical' 'pizza' Object is still in the 'pizza restuarant' Room Object.
commented Jun 27 by hegemonkhan (161 points)
edited Jun 27 by hegemonkhan
This gives a good GUI~Editor example of the most basic usage of lists:
http://docs.textadventures.co.uk/quest/guides/character_creation.html
good for a start~intro into using lists.
my attempt at understanding this 3 years ago:
http://forum.textadventures.co.uk/viewtopic.php?t=3348 (my noobie thread at starting to learn quest and its code: good for a laugh, I was so confused+overwhelmed by all of the terms after I finished with the tutorial, laughs. I didn't know how to do anything on my own outside of the simple direct instructions of the tutorial)
http://forum.textadventures.co.uk/viewtopic.php?t=3348#p22036 (the first post of me trying to understand the character creation)

## Related questions

- How do I use the create exit command properly in Quest
- How do I make verbs synonymous for only certain objects in Quest 5.6.1?
- In a Gamebook, how do I fix that the text processor is not working properly on my version of Quest (I think)?
- In Quest, how do I send an integer from javascript to Quest and keep it an integer?
- How do I ask questions in Quest?

...