links:
http://docs.textadventures.co.uk/quest/ ... lists.htmlhttp://docs.textadventures.co.uk/quest/ ... reach.htmlhttp://docs.textadventures.co.uk/quest/ ... jects.html^^^^
http://docs.textadventures.co.uk/quest/ ... tions.html-------
<function name="populate_npc_objectlist_function">
if (not HasAttribute (game, "npc_objectlist_attribute")) {
game.npc_objectlist_attribute = NewObjectList()
}
foreach (object_variable, AllObjects()) {
if (HasAttribute (object_variable, "person") {
list add (game.npc_objectlist_attribute, object_variable)
}
}
</function>
conceptually what the code above is doing:
if there is no npc list, create one. Then, you iterate (cycle) through all of the objects in the game, and check if they have the indicator/flag (Attribute and/or its Value), and if they do, then add them to the npc list. You can then use (such as iterating through) that npc list for doing whatever you want.
-------------------
you may want to create a String Attribute like this instead (as this way below only requires/uses a single Attribute, instead of making many Attributes):
Object_name.type_of_object
// obviously replace 'Object_name' or 'object_1...X' with the actual names of your Objects, and/or use the special keyword, 'this', if/when you can.
// you can change 'type_of_object' to whatever you want, this is just the naming/labeling that I like to use for it
as then you can use it for this:
object_1.type_of_object = "person"
object_2.type_of_object = "npc"
object_3.type_of_object = "monster"
object_4.type_of_object = "environment"
object_5.type_of_object = "tree"
object_6.type_of_object = "building"
object_7.type_of_object = "room"
object_8.type_of_object = "dungeon"
object_9.type_of_object = "room_object"
object_10.type_of_object = "pc"
object_11.type_of_object = "player"
object_12.type_of_object = "player_object"
object_13.type_of_object = "item"
object_14.type_of_object = "cash"
object_15.type_of_object = "object"
object_16.type_of_object = "object_object"
object_17.type_of_object = "town"
if (this.type_of_object = "npc") {
-> // whatever Script(s)
} else if (this.type_of_object = "monster") {
-> // whatever Script(s)
} else if (this.type_of_object = "item") {
-> // whatever Script(s)
} else if (this.type_of_object = "room") {
-> // whatever Script(s)
}
// etc etc etc
---------
and if you're able to work with List/Dictionary Attributes well, you can use them instead of a String Attribute, allowing you to check for multiple indicators/flags:
object_1.type_of_object_list = split ("spell;fire", ";")
object_1.type_of_object_list = split ("spell;water", ";")
object_2.type_of_object_list = split ("weapon; equipment", ";")
object_3.type_of_object_list = split ("weapon; equipment; melee", ";")
object_4.type_of_object_list = split ("weapon; equipment; ranged", ";")
object_5.type_of_object_list = split ("weapon; equipment; two_handed", ";")
object_6.type_of_object_list = split ("weapon; equipment; one_handed", ";")
object_7.type_of_object_list = split ("weapon; equipment; one_handed; melee", ";")
object_8.type_of_object_list = split ("weapon; equipment; one_handed; ranged", ";")
object_9.type_of_object_list = split ("weapon; equipment; two_handed; melee", ";")
object_10.type_of_object_list = split ("weapon; equipment; two_handed; ranged", ";")
object_11.type_of_object_list = split ("armor; equipment", ";")
object_12.type_of_object_list = split ("spell; fire; item", ";")
object_13.type_of_object_list = split ("item; normal", ";")
object_14.type_of_object_list = split ("item; battle", ";")
object_15.type_of_object_list = split ("item; quest", ";")
object_16.type_of_object_list = split ("item; map", ";")
// etc etc etc
if (ListContains (this.type_of_object_list, "spell")) {
-> whatever Script(s)
} else if (ListContains (this.type_of_object_list, "spell") and ListContains (this.type_of_object, "item")) {
-> whatever Script(s)
}
// etc etc etc