Displaying clothing

I'm having trouble displaying specific clothing items. The only thing I can get to come close is:

msg "You are wearing " + GetOuter ("top") + "."

But that displays as: Object: Shirt.

I'm pretty sure I'm just not formatting it correctly, I don't know coding at all and am fumbling my way through things, but this is the first one to truly stump me.


GetOuter returns an object, which gets the text "Object" before it when it's treated as a string.

You will want either:

  • GetDisplayAlias (GetOuter ("top")) - gets the name or alias of the object (eg "shirt")
  • GetDisplayNameLink (GetOuter ("top"), "") - gets the name or alias and prefix (eg "a shirt")
  • GetDisplayName (GetOuter ("top")) - same as the one above (slightly less efficient, but usually easier to remember)
  • GetDisplayNameLink (GetOuter ("top"), "object") - displays the name or alias and prefix, but makes it a clickable link

Those definitely help, and are getting me closer, but I still have a few issues.

The item has (worn) displayed afterwards, which I'd rather not have, and if there is nothing in the slot, I get error messages.

I'd like a way to simply pull the alias or name of the worn object, so it will display as such: You are wearing a shirt.

Basically I'm trying to create a dynamic "look self" command that will include specific clothing, (or lack thereof), for each body section.


The item has (worn) displayed afterwards, which I'd rather not have

Ah; sorry, slipped my mind. GetDisplayGarment is the function you want; it's like GetDisplayName, but without the "(worn)".

TBH, I think it would make more sense for the wearables system to change the listalias rather than the actual alias. But that doesn't seem to be practical.


if there is nothing in the slot, I get error messages.

In that case, you'd want to check if the garment is null before trying to display it.

Basically I'm trying to create a dynamic "look self" command that will include specific clothing, (or lack thereof), for each body section.

I suspect the quickest way would be to do something like:

if (WornCount() = 0) {
  msg ("You are not wearing anything.")
}
else {
  // ListVisibleFor returns an objectlist of the outer garment in every slot
  foreach (garment, ListVisibleFor (game.pov)) {
    msg ("You are wearing " + GetDisplayGarment (garment) + ".")
  }
}

(This one can be modified if you want to change the way the list is displayed; it's relatively easy to tweak)

There is also a function:

msg ("You are wearing " + ListClothes() + ".")

but that has the disadvantage that it lists all clothes, not just the outer ones.

Another alternative might be:

l = NewStringList()
foreach (obj, ListVisibleFor(game.pov)) {
  list add (l, GetDisplayGarment(obj))
}
msg ("You are wearing" + FormatList(l, ",", "[And]", "[Nothing]") + ".")

Thank you, I think this will help out a lot!


Log in to post a reply.

Support

Forums