Displaying in-room descriptions for objects only?

I'm trying to find a way where the objects are displayed only as in-room descriptions only. Is there a way of turning off the objects names in the display. I don't want the first two lines being displayed.

a small room
a Book titled Red Roses, a Book titled Brave knight, a Door and a Wooden Bookself.
You are in a small room with concrete walls.
A door is in one of the walls There is a wooden bookself with a single shelf


Just found out that you can make objects scenery so they don't appear listed.


On the game's "Room Descriptions" tab, there is a section headed "Room description layout". It lists the four parts of the auto-generated room description and lets you give each a number to determine which order they come in. If you give any of them a number that isn't 1, 2, 3, or 4, then that part won't be shown.

Or if you only want this to happen for certain objects (those with an in-room description), you can set them as scenery. But be careful, because when a player picks up an object and drops it again, this will remove the scenery flag, causing it to reappear in the object list. (It's also worth checking if the in-room description mentions being on a shelf/table/etc because this can be weird if the player moves it to somewhere else)

In the past, I've had objects with a script that runs when they're dropped:

this.scenery = true
this.parent = destinationswitch (destination) {
  case (bookshelf, library) {
    this.inroomdescription = "There is a battered yellow {object:dictionary} among the books on the shelf."
  }
  case (kitchen, dining room) {
    this.inroomdescription = "There is a worn {object:dictionary} on the table."
  }
  case (lounge) {
    this.inroomdescription = "A tatty yellow {object:dictionary:book} looks quite out of place on the polished coffee table."
  }
  default {
    this.inroomdescription = "The {object:dictionary} is on the floor where you left it, ready to trip any careless passers by."
  }
}

(the first two lines turn the "scenery" flag back on, and move the object to its destination. The rest is just an example of how to change the in-room description based on circumstances)


Hi mrangel.

I don't mind the object appearing in the object list after I have dropped it as long as it does not appear twice in the description.
I like your idea of using switch to determine where the object is to be located depending on what room the object is dropped in.
if you were to put the object on another object then this could be a problem such as "put book on chair", unless there is a way of changing the in-room description for an object during the game play.

I've just found another problem as I made the book self a container surface container and gave the list prefix text "two books titled Red Rose and Brave Knight". So when I pick up one of the books then look at the book self the book I picked up is still on the book self.
Writing text adventure programs can cause all sorts of unseen problems.


"put book on chair"

This also runs the object's drop script, with the variable destination being the chair. The example script I included above would change the in-room description accordingly. The objects listed in the 'case' blocks can be either containers or rooms.

"two books titled Red Rose and Brave Knight".

I think I can see a way to make that work but I'll reply when I get home, as my phone has a crack right across the keyboard and it's really hard to write code without typos.

If the books have their titles as aliases, and the player can't put other objects on the bookcase, you could make the list prefix: {either ListCount(GetDirectChildren(bookcase))=1:a book:{=ToWords(ListCount(GetDirectChildren(bookcase)))} books} titled
Which should show "a book titled", "two books titled", "three books titled", etc. as appropriate.

Making it group books together would be harder, but should be possible.

EDIT: Not as hard as I thought.
You can use {= in the bookcase's in room description or in its 'look' description to call a function.

For example, the bookcase's in room description:

There is an ornate wooden bookcase in the corner, on which stand dozens of worn old books. {=FilteredContents(bookcase, "{=CapFirst(ToWords(count))} in particular {either plural:catch:catches} your attention, titled {=(list)}.", "isbook", "None of them look particularly interesting", "{=CapFirst(list)} {either plural:are:is} {either twolists:also }perched precariously on the shelves.")}

Then I'd write a function FilteredContents of type "String" with parameters container, format, attribute, empty, and otherformat. The script would be something like (off the top of my head):

all_items = GetDirectChildren (container)
items = FilterByNotAttribute (all_items, attribute, null)
others = ListExclude (all_items, items)
found = NewStringList()
foreach (item, items) {
  item.scenery = true
  item.inroomdescription = ""
  if (HasString (item, "incontainerdescription")) {
    list add (found, item.incontainerdescription)
  }
  else {
    list add (found, GetDisplayName (item))
  }
}
savedvars = NewDictionary()
if (ListCount (items) = 0) {
  result = empty
}
else {
  params = NewDictionary()
  dictionary add (params, "items", items)
  dictionary add (params, "count", ListCount(items))
  dictionary add (params, "plural", not ListCount(items) = 1)
  dictionary add (params, "list", FormatList (found, ", ", ", and", ""))
  dictionary add (params, "twolists", ListCount(items) * ListCount (others) > 0)
  if (not HasAttribute (game, "text_processor_variables")) {
    game.text_processor_variables = NewDictionary()
  }
  foreach (key, params) {
    if (DictionaryContains (game.text_processor_variables, key)) {
      dictionary add (savedvars, key, DictionaryItem (game.text_processor_variables, key))
      dictionary remove (game.text_processor_variables, key)
    }
    dictionary add (game.text_processor_variables, key, DictionaryItem (params, key))
  }
  result = ProcessText (format)
  foreach (key, params) {
    dictionary remove (game.text_processor_variables, key)
  }
}
if (not IsDefined("otherformat")) {
  otherformat = ""
}
if (not TypeOf(otherformat) = "string") {
  otherformat = ""
}
if ((LengthOf (otherformat) > 0) and (ListCount (others) > 0)) {
  found = NewStringList()
  foreach (item, others) {
    item.scenery = true
    item.inroomdescription = ""
    if (HasString (item, "incontainerdescription")) {
      list add (found, item.incontainerdescription)
    }
    else {
      list add (found, GetDisplayName (item))
    }
  }
  params = NewDictionary()
  dictionary add (params, "items", others)
  dictionary add (params, "count", ListCount(others))
  dictionary add (params, "plural", not ListCount(others) = 1)
  dictionary add (params, "list", FormatList (found, ", ", ", and", ""))
  dictionary add (params, "twolists", ListCount(items) * ListCount (others) > 0)
  if (not HasAttribute (game, "text_processor_variables")) {
    game.text_processor_variables = NewDictionary()
  }
  foreach (key, params) {
    if (DictionaryContains (game.text_processor_variables, key)) {
      dictionary add (savedvars, key, DictionaryItem (game.text_processor_variables, key))
      dictionary remove (game.text_processor_variables, key)
    }
    dictionary add (game.text_processor_variables, key, DictionaryItem (params, key))
  }
  result = result + " " + ProcessText (otherformat)
  foreach (key, params) {
    dictionary remove (game.text_processor_variables, key)
  }
}
foreach (key, savedvars) {
  dictionary add (game.text_processor_variabled, key, DictionaryItem (savedvars, key))
}
return (result)

Wow, that took longer to type than I expected!

In any case, that would generate an in-room description like "There is an ornate wooden bookcase in the corner, on which stand dozens of worn old books. Three in particular catch your attention, titled The Origin of Spices, The Two Towers, and Wilbur's Compendium of Naughty Pictures. A globe with one leg broken is also perched precariously on the shelves."


Hi rangel.
Wow that's a lot of code. I'll study it to see how it works. I may prefer to find another way around the problem with less code such as if the player has a certain book then describe the book that's still on the book self when I look at the book self, or have the description displayed once only in describing what books are in the book self and any future description could be "The book self is for storing books". If I type "Get Book" then I get a list of books to choose from that seems to be built into the Quest program as my objects are 'Book titled Red Rose', 'Book titled Brave Knight'.
That also makes me wonder if common commands such as 'look' can be over written by script commands.
if example depending on what the conditions were (flags set etc) I might want a different message when I try to look at an object.
Is this possible?


Yeah… the code came out bigger than I expected because I tried to make a general case that could be used for other objects too; and I didn't want it to mess with text_processor_variables so I saved them before doing the output and restored them later.

To be clear, I would probably not use that code. I'd just stop the player from putting non-book items on the bookshelf.

Or here's an alternative way to do it: In the drop script for the books, check if the other book is in the same location. If so, create a temporary object which is an open container with the alias "two books named X and Y" and move the books into it. That object's look and in-room descriptions could show up instead of the individual ones.

(this is a little like the "stacking" library that a lot of games use to prevent the inventory getting cluttered with a dozen identical potions)
If you end up going down that route, I'd suggest giving the books a script attribute named changedparent; this will be run automatically whenever a book moves to a different location (which means that it will behave correctly wherever they are)


Hi mrangel.
Thanks for your reply.
I was hoping that you could answer my other question. Can common commands such as 'look' can be over written by script commands.
if example depending on what the conditions were (flags set etc) I might want a different message when I try to look at an object.
Is this possible?


Hi mrangel.
Thanks for your reply.
I was hoping that you could answer my other question. Can common commands such as 'look' can be over written by script commands.
if example depending on what the conditions were (flags set etc) I might want a different message when I try to look at an object.
Is this possible?


You can modify the default 'lookat' command if you want; you can copy any of the core functions into your game and modify them.

(Doing this on the web editor is a lot harder, but possible)

However, you usually won't need to.

depending on what the conditions were (flags set etc) I might want a different message when I try to look at an object.

An object's look attribute can be either a string which is displlayed when it is looked at; or a script which is run to display a message.

For example, if my dictionary has a flag burned which is set during the game, I could set its description to:
{either dictionary.burned:A fancy leatherbound dictionary:A charred bundle of pages}


I found that I can add "look at" in the pattern field and then add a condition in a script to determine the resulting message.
But I think it maybe a problem in creating a look command if I want to work on more than one object so maybe your method is better.
It might be possible to have two commands for look if I give each command a different name and in the pattern field give the object name that the look applies to.
I'm thinking that when you do type in a command during game play all the custom commands are considered first before it falls back on default built-in commands.


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

Support

Forums