Easiest way to display object names with working links?

I'm trying to write a pamphlet style object that when you look at it the description then lists all of it's sub-objects so that when you click on those they will display their specific descriptions but DisplayList() but this only tostrings the sub-object's alias. I then tried a custom function called FancyObjectList() that I got a long time ago for another project. I also added a line to check for a boolean attribute called "enabled" I applied to each sub-object so I can hide certain objects from use when they aren't available for publication.

Object: Pamphlet
-> Types - "Types" - attribute 'enabled' =true, scenery = true, visible = false
-> Types2 - "More Types!" - attribute 'enabled' =true, scenery = true, visible = false

But when I display it I get the object text displayed correctly but without the actual object links for both sub-objects as GetDisplayNameLink() doesn't appear to work.

"Preferences: Types and More Types!

if (not IsDefined ("joiner")) {
  joiner = "and"
}
if (TypeOf (objects) = "object") {
  objects = GetDirectChildren (objects)
}
if (ListCount (objects) = 0) {
    if (IsDefined ("empty")) {
        return (empty)
    }
    else {
        return ("")
    }
}
else {
  result = ""
  itemsLeft = ListCount(objects)
  foreach (item, objects) {
      if (item.enabled = TRUE) {
          switch (TypeOf(item)) {
              case ("object") {
                  if (DoesInherit (item, "defaultexit")) {
                      result = result + GetDisplayNameLink(item, "exit")
                  }
                 else {
                     result = result + GetDisplayNameLink(item, "object") ```This is the line it hits per object as expected```
                 }
              }
              case ("string") {
                  result = result + item
              }
             default {
                 result = result + ToString (item)
             }
         }
         itemsLeft = itemsLeft - 1
         if (itemsLeft > 0) {
             if (itemsLeft > 1 or (GetBoolean(game, "oxfordcomma") and not ListCount (objects) = 2)) {
                 result = result + ", "
             }
            else {
                result = result + " "
            }
           if (itemsLeft = 1) {
              result = result + joiner + " "
           }
       }
    }
 }
 result = preList + result + postList
  return (Trim (result))
}

Usage:

msg (FancyObjectList ("Preferences:", GetDirectChildren(Pamphlet), "<br/>", "There are no preferences to display."))

Does anyone have an idea what I'm doing wrong here?


I've also tried

msg (FormatList (GetDirectChildren(Pamphlet), "<br/>", "<br/>", ""))

But this still didn't give me the object links of it's list.


If FormatObjectList didn't work, it's probably because you can't see the objects. Before transferring control back to the player, Quest removes all links to objects that aren't currently visible.

I would suggest that if you want the pamphlet's contents to be visible, you make it transparent. You can then make its contents scenery so that they don't show up in the normal objects list.


Thanks, I'm not sure how to make those objects "transparent", what settings do I need to set and where?


I've got all of my pamphlet sub objects set to visible and scenery but FormatObjectList() is still removing the links.

Update:
I've seen it's possible to use Transparency with Containers but I wasn't sure I should be using this for a standard object.


I've seen it's possible to use Transparency with Containers but I wasn't sure I should be using this for a standard object.

If it's not a container, the player can't interact with objects inside it, so links to them will never be displayed.

If you set the pamphlet's transparent flag to true, objects inside it will be treated as if it's a container, which should make them visible and linkable. This would also allow the player to look at the pamphlet and see an automatically generated list of its contents - which is why you make the contents 'scenery' to suppress this. However, this may still cause them to appear on the 'inventory' pane if the pamphlet is in the inventory. (scenery is a little unreliable for the inventory) - I've not tested this exact case).

If you only want to be able to do one thing with each subobject, an alternative might be to make command links. These aren't automatically disabled, so the player can always click on them. If you have a custom command which the player uses to read those subjects, you could set its "scope" to Pamphlet, which should mean that the command can be used on objects inside the pamphlet whether they are visible or not.


I've resorted to using Pamphlet as a Container type and Hide/Display child items on Look At which does let me see a list of all of the items and their links, the only problem I now have is that it adds all of those items to the room object list after you've stopped looking at the pamphlet, but it's not the end of the world so I've moved on to the next thing.


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

Support

Forums