A problem with a list

retroPacifist
07 Nov 2016, 04:08I want to have an if command set up to do:
}
if (Toothfairysprite UNUSED.aspect = "time";"void";"light";"mind";"heart";"rage";"hope";"doom";"life";"blood";"breath") {
}
But I don't think I'm formatting the list of options correctly. Thank you in advance!!!!!!!
hegemonkhan
07 Nov 2016, 04:37you can use the GUI/Editor to create/add/set a String List Attribute (but you can't an Object List Attribute):
'whatever' Object -> 'Attributes' Tab -> Attributes -> Add -> (see below)
(Object Name: whatever)
Attribute Name: (whatever)
Attribute Type: StringList
Attribute Value: add in your string item values
and/or...
there's two ways to create/set/add (and/or re-create/empty/re-set from/by over-writing) a list via scripting:
(note that there's two types of List Attributes: String Lists: holds/returns string items/values, and Object Lists: holds/returns object reference items)
- (see below)
NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE = split ("NAME_OF_ITEM_1; NAME_OF_ITEM_2; ETC_ETC_ETC", ";")
- (see below)
NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE = NewStringList () // or NewObjectList()
list add (NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE, NAME_OF_ITEM/VALUE)
// etc list adds as needed added items
// and to use the List:
VARIABLE = StringListItem (NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE, INDEX_NUMBER)
~OR~
it needs to be used within a script/function
and via scripting you can add/remove items from your list
here's some links on using lists/dictionaries and an example code ('explore and travel' functionality) using lists/dictionaries:
http://docs.textadventures.co.uk/quest/guides/using_lists.html
http://docs.textadventures.co.uk/quest/using_dictionaries.html
http://docs.textadventures.co.uk/quest/functions/string/split.html
http://textadventures.co.uk/forum/samples/topic/5137/list-and-dictionary-extensive-guide-by-hk
http://textadventures.co.uk/forum/samples/topic/5138/explore-and-travel-code-sample-by-hk
if you don't need inputs/parameters/arguments, you may want to use a Script Dictionary Attribute instead...
you can also use the 'foreach' Function:
http://docs.textadventures.co.uk/quest/scripts/foreach.html
foreach (item_variable, NAME_OF_OBJECT.NAME_OF_LIST_ATTRIBUTE) {
if (Toothfairysprite UNUSED.aspect = item_variable) {
// whatever script/s
}
}

retroPacifist
07 Nov 2016, 07:38Thankyou this fixed the problem!!!!!!!
The Pixie
07 Nov 2016, 08:17You cannot just assign a list like that, but you can use the Split function to create a list:
if (Toothfairysprite UNUSED.aspect = Split("time;void;light;mind;heart;rage;hope;doom;life;blood;breath". ";")) {

retroPacifist
07 Nov 2016, 10:20Yes I know I fixed it. Thanks for the help.