Using room names to set variables on all rooms

There once was a thread about names containing the same word, like room_kitchen, room_bedroom. So you could use the room names to make changes to all of them at the same time. Perhaps adding an attribute or verb, whatever. Can't find it. Could use a hint...
Ring a bell
or have a script?


you can use the 'name' ID String Attribute or you can use another Attribute, including the Inherited Attributes (Object Types / Types), and a few other methods as well I think (Attribute Type: TypeOf (XXX), Element Type: ??? GetUniqueElementName (XXX) ???)


for names/aliases/etc (aka: strings/text), you got the 'String Manipulation' Functions:

http://docs.textadventures.co.uk/quest/functions/#string

StartsWith (XXX)
EndsWith (XXX)
Mid (XXX)
Instr (XXX)
InstrRev (XXX)
Left (XXX)
Right (XXX)
Replace (XXX)
Split (XXX)
Join (XXX)


for some examples:

create ("example_object")

example_object.room_objectlist_attribute = NewObjectList ()

// -----

foreach (object_variable, AllObjects ()) {
  if (StartsWith (object_variable.name, "room")) {
    object_variable.type_string_attribute = "room"
    list add (example_object.room_objectlist_attribute, object_variable)
  }
}

// --------

foreach (object_variable, AllObjects ()) {
  if (EndsWith (object_variable.name, "bedroom")) {
    object_variable.type_string_attribute = "bedroom"
    list add (example_object.bedroom_objectlist_attribute, object_variable)
  } else if (EndsWith (object_variable.name, "kitchen")) {
    object_variable.type_string_attribute = "kitchen"
    list add (example_object.kitchen_objectlist_attribute, object_variable)
  }
}

// ------

foreach (object_variable, AllObjects ()) {
  if (GetString (object_variable, "type_string_attribute") = "room") {
    list add (example_object.room_objectlist_attribute, object_variable)
  }
}

// ----

foreach (object_variable, AllObjects ()) {
  if (GetString (object_variable, "type_string_attribute") = "bedroom") {
    list add (example_object.bedroom_objectlist_attribute, object_variable)
  } else if (GetString (object_variable, "type_string_attribute") = "kitchen") {
    list add (example_object.kitchen_objectlist_attribute, object_variable)
  }
}

@hegemonkhan
Just the ticket! Thanks


Log in to post a reply.

Support

Forums