making and using custom lists
shadowphile
23 Jun 2013, 02:25Hi.
Where can I define a stringlist so that I can reference it in my script? I'm adding a dropdown control in the ObjectOptions tab that will access this list and assign to a single attribute for the object.
I see that I can do this inline, but my list is really too long to build without line-breaks. I figured I would just define the list elsewhere and my control would reference that.
-Is there a way in XML syntax to word-wrap a line? (not the output, just the XML code itself)
I'm very new to writing XML and with my traditional coding background I think I still get confused.
Here's an approximation of my control
I'd like to use foodlist as my validvalues instead of the chinese/korean example in the lines above it.
thanks
Where can I define a stringlist so that I can reference it in my script? I'm adding a dropdown control in the ObjectOptions tab that will access this list and assign to a single attribute for the object.
I see that I can do this inline, but my list is really too long to build without line-breaks. I figured I would just define the list elsewhere and my control would reference that.
-Is there a way in XML syntax to word-wrap a line? (not the output, just the XML code itself)
I'm very new to writing XML and with my traditional coding background I think I still get confused.
Here's an approximation of my control
<control>
<mustnotinherit>editor_room</mustnotinherit>
<controltype>dropdown</controltype>
<caption>Type of Food</caption>
<attribute>FoodType</attribute>
<validvalues type="simplestringdictionary">dim=dimsum (chinese); kim=kimchee (korean)</validvalues>
<foodlist type = "stringlist">
<value>quail eggs</value>
<value>caviar</value>
etc, dozens more entries
</foodlist>
<onlydisplayif>GetBoolean(this, "lightsource")</onlydisplayif>
<advanced/>
</control>
I'd like to use foodlist as my validvalues instead of the chinese/korean example in the lines above it.
thanks
HegemonKhan
23 Jun 2013, 04:03a list or dictionary, like any attribute, just needs to be attached to any permanent object, and then it can be used any where.
such as putting it in the Game Object, for example. Just as you might do "game.turns", you can do "game.food_list" (create the food_list attribute of course in the Game Object, just as you'd create the turns attribute in the Game Object)
or, you can always make a "data storage" object:
here's some links for you:
http://quest5.net/wiki/Category:All_Fun ... t_Commands
http://quest5.net/wiki/Invoke
http://quest5.net/wiki/Using_Lists
http://quest5.net/wiki/Using_Dictionaries
http://quest5.net/wiki/Split
http://quest5.net/wiki/Show_menu
here's how split works:
split ("red;blue;yellow",";") // creates a local (temporary) string list
here's how you can use show menu:
show menu ("What color is your hat?",split ("red;blue;yellow",";"),false) {
}
or (from the already coded stuff above)
show menu ("What color is your hat?",list_database.color_list,false) {
such as putting it in the Game Object, for example. Just as you might do "game.turns", you can do "game.food_list" (create the food_list attribute of course in the Game Object, just as you'd create the turns attribute in the Game Object)
or, you can always make a "data storage" object:
<object name="list_database">
<color_list type="simplestringlist">red;blue;yellow</color_list>
<food_list type="simplestringlist">meat;veggies;fruits</food_list>
<drink_list type="simplestringlist">wine;beer;rum</drink_list>
</object>
// and then to call upon it in some script block:
invoke (list_database.color_list) // returns the string list, err... maybe you use "return" instead of invoke, too lazy to look up how to show a list, lol. You should be able to easily figure it out as to what command script you use though.
// or
invoke (StringListItem (list_database.color_list,0)) // returns the string item: red
here's some links for you:
http://quest5.net/wiki/Category:All_Fun ... t_Commands
http://quest5.net/wiki/Invoke
http://quest5.net/wiki/Using_Lists
http://quest5.net/wiki/Using_Dictionaries
http://quest5.net/wiki/Split
http://quest5.net/wiki/Show_menu
here's how split works:
split ("red;blue;yellow",";") // creates a local (temporary) string list
here's how you can use show menu:
show menu ("What color is your hat?",split ("red;blue;yellow",";"),false) {
}
or (from the already coded stuff above)
show menu ("What color is your hat?",list_database.color_list,false) {
shadowphile
23 Jun 2013, 06:12holy cow, lots of goodies there, thanks so much HegemonKhan. Guess I didn't realize the wiki was so useful. (I'm used to them being sketchy)