I struggled myself in understanding lists and dictionaries too, I think I finally get them pretty well (at least their most basic usages, anyways, lol. It took my a long time to create my travel coding at the bottom of this post, it wasn't easy for me to figure it out, laughs)
----------------------------------------
for the:
StringListItem (Object.StringList, Value)
(this entire code line above is ~ie returns~ just~only a Value actually, you need a script, ie doing an action with that Value)
I think you need either:
Do (StringListItem (Object.StringList, Value)
~OR~
Invoke (StringListItem (Object.StringList, Value)
http://quest5.net/wiki/Invokehttp://quest5.net/wiki/Do---------------------------------------------
ListCount is literally a counting, ie: 1, 2, 3, 4, 5, ...
you don't start with 0 when you're counting:
how many fingers are on your hand?:
0, 1, 2, 3, 4 = ERR, WRONG!
1, 2, 3, 4, 5 = DING DING, CORRECT!
it is annoying, because the List's iteration starts with 0... sighs:
<color_list type="simplestringlist">red;blue;yellow;orange;green;purple</color_list>
the List's iteration (the order of the list's items):
"red" = Do (StringListItem (Object.color_list, 0))
"blue" = Do (StringListItem (Object.color_list, 1))
"yellow" = Do (StringListItem (Object.color_list, 2))
"orange" = Do (StringListItem (Object.color_list, 3))
"green" = Do (StringListItem (Object.color_list, 4))
"purple" = Do (StringListItem (Object.color_list, 5))
Counting of the List's items:
red -> ListCount (Object.color_list) = 1
purple -> ListCount (Object.color_list) = 1
red; blue -> ListCount (Object.color_list) = 2
red; blue; yellow -> ListCount (Object.color_list) = 3
red; blue; yellow; orange -> ListCount (Object.color_list) = 4
red; blue; yellow; orange; green -> ListCount (Object.color_list) = 5
red; blue; yellow; orange; green; purple -> ListCount (Object.color_list) = 6
yellow; purple; orange; red; blue; green -> ListCount (Object.color_list) = 6
you may need "Do (...)" or "Invoke (...)" encasing the ListCount (Object.StringList), but I'm not sure.
-----------------------------
To CREATE a NEW ("Empty + then filling~adding items into it") List (via within scripting):
As a Variable:
StringList = NewStringList ()
list add (StringList, Value)
color_list = NewStringList ()
list add (color_list, "red")
list add (color_list, "blue")
list add (color_list, "yellow")
list add (color_list, "orange")
list add (color_list, "green")
list add (color_list, "purple")
As an Attribute:
Object.StringList = NewStringList ()
list add (Object.StringList, Value)
Object.color_list = NewStringList ()
list add (Object.color_list, "red")
list add (Object.color_list, "blue")
list add (Object.color_list, "yellow")
list add (Object.color_list, "orange")
list add (Object.color_list, "green")
list add (Object.color_list, "purple")
----------------------------------------
To CREATE a list (via as the Object's Attribute):
<object name="stringlist_data_object">
-> <color_list type="simplestringlist">red;blue;yellow;orange;green;purple</color_list>
-> <gender_list type="simplestringlist">male;female</gender_list>
-> <stat_list type="simplestringlist">strength;endurance;dexterity;agility;speed;luck</stat_list>
-> <race_list type="simplestringlist">human;dwarf;elf;gnome;hobbit;giant;orc</race_list>
-> <class_list type="simplestringlist">warrior;cleric;mage;thief</class_list>
-> <weapon_type_list type="simplestringlist">sword;axe;blunt;spear;staff;dagger;throwing;bow;crossbow;gun</weapon_type_list>
</object>
------------------------------
here's my travel coding (it uses stringlists and stringdictionaries), you can study it:
<asl version="540">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Testing Game Stuff">
<gameid>eef801a1-4e6b-4b0a-bdbf-8f3ecfa8389c</gameid>
<version>1.0</version>
<firstpublished>2013</firstpublished>
<turns type="int">0</turns>
<statusattributes type="simplestringdictionary">turns=</statusattributes>
<start type="script">
msg ("Important Note:")
msg ("Type in: help")
</start>
</game>
<object name="homeland">
<inherit name="editor_room" />
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
</object>
<object name="grassland">
<inherit name="editor_room" />
</object>
<object name="plains">
<inherit name="editor_room" />
</object>
<object name="desert">
<inherit name="editor_room" />
</object>
<object name="tundra">
<inherit name="editor_room" />
</object>
<object name="swampland">
<inherit name="editor_room" />
</object>
<object name="mountains">
<inherit name="editor_room" />
</object>
<object name="forest">
<inherit name="editor_room" />
</object>
<object name="wasteland">
<inherit name="editor_room" />
</object>
<object name="coastland">
<inherit name="editor_room" />
</object>
<object name="hills">
<inherit name="editor_room" />
</object>
<command name="help_command">
<pattern>help</pattern>
<script>
help_function
</script>
</command>
<command name="explore_command">
<pattern>explore</pattern>
<script>
explore_function
</script>
</command>
<command name="travel_command">
<pattern>travel</pattern>
<script>
travel_function
</script>
</command>
<object name="data_object">
<inherit name="editor_object" />
<travel_string_list type="simplestringlist">homeland</travel_string_list>
<homeland_events_string_list type="simplestringlist">grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery</homeland_events_string_list>
<homeland_events_script_dictionary type="scriptdictionary">
<item key="grassland_discovery">
list add (data_object.travel_string_list, "grassland")
msg ("You've discovered the grassland! Now, you can travel to the grassland and explore it!")
</item>
<item key="plains_discovery">
list add (data_object.travel_string_list, "plains")
msg ("You've discovered the plains! Now, you can travel to the plains and explore it!")
</item>
<item key="desert_discovery">
list add (data_object.travel_string_list, "desert")
msg ("You've discovered the desert! Now, you can travel to the desert and explore it!")
</item>
<item key="tundra_discovery">
list add (data_object.travel_string_list, "tundra")
msg ("You've discovered the tundra! Now, you can travel to the tundra and explore it!")
</item>
<item key="swampland_discovery">
list add (data_object.travel_string_list, "swampland")
msg ("You've discovered the swampland! Now, you can travel to the swampland and explore it!")
</item>
<item key="forest_discovery">
list add (data_object.travel_string_list, "forest")
msg ("You've discovered the forest! Now, you can travel to the forest and explore it!")
</item>
<item key="mountains_discovery">
list add (data_object.travel_string_list, "mountains")
msg ("You've discovered the mountains! Now, you can travel to the mountains and explore it!")
</item>
<item key="hills_discovery">
list add (data_object.travel_string_list, "hills")
msg ("You've discovered the hills! Now, you can travel to the hills and explore it!")
</item>
<item key="wasteland_discovery">
list add (data_object.travel_string_list, "wasteland")
msg ("You've discovered the wasteland! Now, you can travel to the wasteland and explore it!")
</item>
<item key="coastland_discovery">
list add (data_object.travel_string_list, "coastland")
msg ("You've discovered the coastland! Now, you can travel to the coastland and explore it!")
</item>
</homeland_events_script_dictionary>
</object>
<turnscript name="global_turnscript">
<enabled />
<script>
game.turns = game.turns + 1
</script>
</turnscript>
<function name="help_function">
msg ("Type 'explore' to explore your area.")
msg ("Type 'travel' to travel to different areas.")
</function>
<function name="explore_function"><![CDATA[
switch (game.pov.parent) {
case (homeland) {
result_1 = ListCount (data_object.homeland_events_string_list) - 1
if (result_1 >= 0) {
result_2 = StringListItem (data_object.homeland_events_string_list,GetRandomInt(0,result_1))
invoke (ScriptDictionaryItem (data_object.homeland_events_script_dictionary,result_2))
on ready {
foreach (item_x, split ("grassland_discovery;plains_discovery;desert_discovery;tundra_discovery;swampland_discovery;forest_discovery;mountains_discovery;hills_discovery;wasteland_discovery;coastland_discovery",";")) {
if (result_2 = item_x) {
list remove (data_object.homeland_events_string_list, result_2)
}
}
}
} else {
msg ("There seemingly is nothing left to explore in this area.")
}
}
}
]]></function>
<function name="travel_function">
show menu ("Where do you wish to travel?",data_object.travel_string_list,false) {
if (not game.pov.parent = GetObject (result)) {
game.pov.parent = GetObject (result)
} else {
msg ("You are already at this area.")
ask ("Try again?") {
if (result=true) {
travel_function
} else {
msg ("You realize that you need to discover a new area to travel to first, before you can travel to that place.")
}
}
}
}
</function>
</asl>
------------------------
P.S.
ListContains (
http://quest5.net/wiki/ListContains ) can be very useful too!
if (ListContains (Object.color_list, "green") {
-> msg ("most plants are green")
}
----------------------