actually, I am messing up, argh, sorry.
you got to use~make a "Script Dictionary", for scripts
http://quest5.net/wiki/Using_Dictionarieshttp://quest5.net/wiki/Scriptdictionaryhttp://quest5.net/wiki/ScriptDictionaryItemand also use "invoke" or "do":
http://quest5.net/wiki/Invokehttp://quest5.net/wiki/DoScript Dictionary:
Key (String) = Expression (Script)
string_1 = script_1
string_2 = script_2
conceptual: if input is string_1, then output is script_1
Scripting: invoke (ScriptDictionaryItem (Object.ScriptDictionary, String_Value)
for example:
Object.ScriptDictionary:
HK = run_laps
Michael = do_push_ups
invoke (Object.ScriptDictionary, HK)
output effect: HK will run laps
invoke (Object.ScriptDictionary, Michael)
output effect: Michael will do push ups
here's an example:
<object name="global_data_object">
<inherit name="editor_object" />
<attr name="homeland_events_script_dictionary" type="scriptdictionary">
<item key="grassland_discovery">
msg ("You've discovered the grassland! Now, you can travel to the grassland and explore it!")
</item>
<item key="plains_discovery">
msg ("You've discovered the plains! Now, you can travel to the plains and explore it!")
</item>
</attr>
</object>
<function name="explore_function">
invoke (ScriptDictionaryItem (global_data_object.homeland_events_script_dictionary, grassland_discovery))
// or: invoke (ScriptDictionaryItem (global_data_object.homeland_events_script_dictionary, plains_discovery))
</function>
----------------------------
here's an example game code of all of this stuff working together to do something ("explore" and "travel" features) in a game:
using "StringLists" and "GetRandomInt" and "ScriptDictionaries" together.
you "explore" to randomly select events in your starting area, some (well, I haven't added in other unrelated events, such as finding~selecting an item or equipment or a gold bag or a monster~fight event, as this is just for testing) of the events are "area discovery" events, which enable you to now (using the) "travel" to those areas. I don't want these events to get selected again when you "Explore", so they must be removed from the StringList (which thus then also prevents the ScriptDictionary of those events' scripts from running as well).
for example:
"explore" (ie: event) button
"travel" (ie: goto) button
Areas of the game:
grassland (starting area)
plains
desert
swamp
Grassland's "Explore" events:
1. discover the "plains" (allows you to now travel to the plains area)
2. discover the "desert" (allows you to now travel to the plains area)
3. discover the "swamp" (allows you to now travel to the plains area)
4. encounter an "orc" monster
5. find a 50 gold bag
6. get sick (lose 10 HP each turn until cured or dead)
7. etc...
plains' "explore" events:
1. etc etc etc
2. etc etc etc
etc etc etc
(not as elegant as Jay's coding, but it's functional, lol)
<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>
----------------------
the Script Dictionary contains the actual "script events", so we don't want to add~remove these, and thus instead, we use the "StringList" to add~remove our "events' labels~names", which determine (by matching up to the ScriptDictionary, and thus in effect, "calling upon" that Script from the ScriptDictionary) what events can be run and~or when they can or will be run.
StringList:
1. HK
2. Michael
result_x = StringListItem (Object.StringList, GetRandomInt (0, ListCount (Object.StringList) - 1))
---------------
// result_x is what script we're "calling upon" in the Script Dictionary below
// if result_x = HK, then run_laps
// else if result_x = Michael, then do push ups
ScriptDictionary:
1. HK=run_laps
2. Michael=do_push_ups
invoke (Object.ScriptDictionary, result_x)
and after it is run, we remove that event option from the list, so it can't be run again by the Script Dictionary:
list remove (Object.StringList, result_x)
// do note that we're removing the item from the *STRING LIST*, we don't change the Script Dictionary at all, as it is simply a "data base" of:
String_1 = Script_1
String_2 = Script_2
String_3 = Script_3
String_4 = Script_4
etc etc etc
the "invoking" of this "data base" (the Script Dictionary) is based upon the chosen STRING LIST's item (string), but NOT directly upon the Script Dictionary's key item (string).
conceptual:
if (StringList's String = ScriptDictionary's String), then do ScriptDictionary's corresponding Script:
String List:
(1) String
(2) String
(3) String
Script Dictionary:
String_1 = Script_1
String_2 = Script_2
String_3 = Script_3
String List == Script Dictionary:
String__.. == String_1 = Script_1
String__.. == String_2 = Script_2
String__.. == String_3 = Script_3
if (String_List's_String = Script_Dictionary's_String_1), and if (Script_Dictionary's_String_1 = Script_Dictionary's_Script_1), then do~invoke Script_Dictionary's_Script_1
else
if (String_List's_String = Script_Dictionary's_String_2), and if (Script_Dictionary's_String_2 = Script_Dictionary's_Script_2), then do~invoke Script_Dictionary's_Script_2)
else
if (String_List's_String = Script_Dictionary's_String_3), and if (Script_Dictionary's_String_3 = Script_Dictionary's_Script_3), then do~invoke Script_Dictionary's_Script_3
so by adding~removing from the StringList, we determine what script can or will be (or not) run from the ScriptDictionary.