that would be my travel code, and I thus presume you need help with it, hehe (as it is complicated for new people to coding).
-----------------------------
useful links:
1.
http://quest5.net/wiki/Category:All_Fun ... t_Commands (page 1, range: A-S)
2.
http://quest5.net/w/index.php?title=Cat ... h#mw-pages (page 2, range: S-Z)
3.
http://quest5.net/wiki/Using_Lists4.
http://quest5.net/wiki/Using_Dictionaries--------------
my step by step guide:
1. first, let's create (add) a "data storage object", so we don't clutter up the "game" object with global attributes:
(and it makes it easier, and more organized too, for further expansion of ~ an actual game worth of content and not just my example test game limited amount of content, lol, for example, dialogue~topics)
(if you want topics specific to only each individual characters~NPCs, then instead, just put the below stuff~Attributes~Scripts within that "character~NPC" Object's Attributes and Verbs)
In the GUI~Editor: just make (add) an (Type: Object Object; Non-Room Object; Non-Player Object) Object that is NOT inside of a room (Room Object), a Player Object, or another Object Object.
in Code:
<object name="global_data_object">
-> <inherit name="editor_object" />
</object>
2. create (add) your String List Attribute:
this is the dynamic list, that we'll be adding~removing topics to~from, to set what is available for random selection at any given time.
(we can start with it being blank too, as a variation)
In the GUI~Editor: "global_data_object" Object -> Attributes (Tab) -> Attributes -> Add ->
Attribute Name: topic_string_list
Attribute Type: String List
Attribute Value: (add in your topic keywords, ie: dragon; sword; princess)
In Scripting: Run as script -> Add a script -> Variables -> Set a variable or attribute -> (see below, the code scripting, for what to type in)
In Code:
<object name="global_data_object">
-> <inherit name="editor_object" />
-> <attr name="topic_string_list" type="simplestringlist">dragon;sword;princess</attr>
</object>
In Scripting: global_data_object.topic_string_list = split ("dragon;sword;princess",";")
In Scripting: StringListItem (global_data_object.topic_string_list, your keyword's counting index number in the list)
Lists start from 0, from left to right: (0) dragon, (1) sword, and (2) princess
("result" can be changed to what you want to call it, such as for example: "topic")
result = StringListItem (global_data_object.topic_string_list, 1)
input: 1
output~returns: sword
result = sword
result = StringListItem (global_data_object.topic_string_list, 2)
input: 2
output~returns: princess
result = princess
result = StringListItem (global_data_object.topic_string_list, 0)
input: 0
output~returns: dragon
result = dragon
result = StringListItem (global_data_object.topic_string_list, GetRandomInt (0,2))
input: (0-2)
output~returns: (dragon, sword, or princess)
result = (dragon, sword, or princess)
result = StringListItem (global_data_object.topic_string_list, GetRandomInt (0, ListCount (global_data_object.topic_string_list) - 1))
input: (0-whatever is the current size of the list ~ dynamic, and thus useful for us when we add~remove items from the list)
output~returns: (depends what items the list currently contains)
result = (depends what items the list currently contains)
3. create (add) a Script Dictionary Attribute:
In the GUI~Editor:
"global_data_object" Object -> Attributes (Tab) -> Attributes -> Add ->
Attribute Name: topic_script_dictionary
Attribute Type: Script Dictionary
Key Items: dragon, sword, and princess
Values (Scripts): (see below)
dragon:
run as script -> add a script -> (for example) -> output -> print a message -> MESSAGE -> the evil dragon has kidnapped the princess, you must save her from the evil dragon!
sword:
(same as above... blah blah blah)
princess:
(same as above... blah blah blah)
In code:
<object name="global_data_object">
<inherit name="editor_object" />
<attr name="topic_string_list" type="simplestringlist">dragon;sword;princess</attr>
<attr name="topic_script_dictionary type="scriptdictionary">
<item key="dragon">
msg ("blah blah blah")
</item>
<item key="sword">
msg ("blah blah blah")
</item>
<item key="princess">
msg ("blah blah blah")
</item>
</attr>
</object>
4. concept of what we're doing with the string list and script dictionary:
the script dictionary as can be seen, is what our topics are:
if dragon, then msg: blah blah blah
if sword, then msg: blah blah blah
if princess, then msg: blah blah blah
our string list is used to determine what topics are currently available for the script dictionary:
if string list (dragon,sword,princess), and if randomness selects (x=dragon,sword,or princess), then script dictionary (x=dragon,sword, or princess) msg: blah blah blah
if string list (dragon,sword), and if randomness selects (x=dragon or sword), then script dictionary (x=dragon or sword) msg: blah blah blah
you get the idea... I hope
so... conceptually:
if (choosen string list item~topic = script dictionary key~word item), then do that script dictionary item's msg script: blah
if (StringList: dragon = ScriptDictionary: dragon), then do ScriptDictionary: dragon 's script, ie msg: blah blah blah
if (dragon = dragon), then do ScriptDictionary's dragon's script, ie msg: blah blah blah
"match comparisons" (if string_1 = string_2 ~ if dragon = dragon) are a huge part of the tactic~logic~technique of doing things in code
5. which gets us to the complicated part, the removal (or the addition of ~ which I'm not going to cover right now) of topics to select from:
let's say we've got some topics that we want to remove (one-time topic events) and some topics that we don't want to remove (repeatable topic events)
thus we must craft a function correctly, to deal with this complexity
Our Function (slightly more complex), and~or Direct Verb (a custom one, so we don't mess up the built-in Verbs, let's call our custom Verb, for example, "chat", lol) Scripting (simplier: just put the below code as the script block for your Verb) of, let's say for example, the Object "wise_owl_npc_your_helpful_guide_through_this_game" (lol):
// we need to do this, to check if there's still topic choices in our string list:
result_1 = ListCount (global_data_object.topic_string_list) - 1
if (result_1 >= 0) {
// we need to do this, to get the current string list size, to get the random choice from that current selection of list choices:
result_2 = StringListItem (global_data_object.topic_string_list,GetRandomInt(0,result_1))
// we cause the the script to run for the choosen topic:
invoke (ScriptDictionaryItem (global_data_object.topic_script_dictionary,result_2))
// and now the beginning of the removal of topics proncess:
on ready {
// we create a list (split) of the topics that can be removed (the one time only topic events), AND we go through each of them (foreach), seeing if they match up with the topic that was randomly selected and run (if), and if they do match up, then we remove the topic from the String List (list remove), as it has already been run, and we don't want it to be selected and run again:
// let's say that we want only "dragon" and "princess" to be one time only topic events, while "sword" is a repeatable topic event, for this example:
foreach (item_x, split ("dragon;princess",";")) {
if (result_2 = item_x) {
list remove (global_data_object.topic_string_list, result_2)
}
}
}
}