INFOCOM-Style Inventory Command (Revisited)

image


New Command

<command name="custom_inventory_cmd">
    <pattern type="string">^i$|^inv$|^inventory$</pattern>
    <synonyms type="stringlist">
      <value>i</value>
      <value>inv</value>
      <value>inventory</value>
    </synonyms>
    <script>
      list = FormatObjectList (Template ("CarryingListHeader"), game.pov, Template ("And"), ".")
      if (list = "") {
        msg ("You are empty-handed.")
      }
      else {
        CustomInventory
      }
    </script>
  </command>

New Functions

<function name="CustomInventory"><![CDATA[
    msg ("You have:")
    stuff = GetDirectChildren(game.pov)
    stuff = ListExclude(stuff, hangover)
    stuff = ListExclude (stuff, no_tea)
    indents = 1
    foreach (o, stuff) {
      worn = ""
      if (GetBoolean(o, "worn")) {
        worn = " (being worn)"
      }
      msg (Spaces(indents) + GetDisplayName(o) + worn)
      PrintContentsWithIndents (o, indents)
    }
  ]]></function>
  <function name="PrintContentsWithIndents " parameters="o, indents"><![CDATA[
    if (GetBoolean (o, "feature_container") and (GetBoolean(o, "isopen") or GetBoolean (o, "transparent"))) {
      stuff = GetDirectChildren (o)
      stuff = ListExclude(stuff, FilterByAttribute (stuff, "scenery", true))
      stuff = FilterByAttribute (stuff, "visible", true)
      if (ListCount (stuff) > 0) {
        msg (Spaces(indents) + "It looks like " + GetDefiniteName(o) + " contains:")
        indents = indents + 1
        foreach (obj, stuff) {
          msg (Spaces(indents) + GetDisplayName(obj))
          PrintContentsWithIndents (obj, indents)
        }
      }
    }
  ]]></function>

Modified functions

<function name="_SetGarmentAlias" parameters="object"><![CDATA[
    ext = GetDescriptor(object)
    // object.alias = object.display + ext
    if (HasString(object, "listalias")) {
      if (StartsWith(object.listalias, "<span style=\"color:blue\">")) {
        object.listalias = null
        do (object, "colourmylistalias")
      }
      else {
        object.listalias = object.original_listalias + ext
      }
    }
  ]]></function>
<function name="GetDefiniteName" parameters="obj" type="string">
    result = GetDisplayAlias(obj)
    if (not DoesInherit(obj, "namedmale") and not DoesInherit(obj, "namedfemale") and not result = "me" and not result = "you" and GetBoolean(obj, "usedefaultprefix")) {
      result = "the " + result
    }
    return (result)
  </function>

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums