adding an adjective to an object after an interation

Hi, completely new to this kind of thing. How might I change an adjective on an object after an interaction? For instance, I'd like the player's clothes to become dirty after digging in the dirt. Is something like that possible?


Depends on what your end goal is. I would create two objects. A shirt being worn by the player and a dirty shirt stored in an “item warehouse” (a room ONLY used to store items for moving them around). When the player digs, just move object shirt to the warehouse and move dirty shirt to the player. The player of your game won’t even know there are actually two shirts. It will only appear there is one.

The other option is to change the object description with a flag. In the look at part of the object, insert an IF script. If shirt has flag “dirty”, then print message “The shirt is dirty.” Else, print message “The shirt is clean.” When the player digs, run a script to set object flag and name the flag “dirty”. If the player can clean the shirt, unset the flag dirty.

Ask if you have questions.


Thank you!


I'd be more likely to give the object a flag dirty and a script attribute changeddirty which looks like this:

if (this.dirty) {
  if (not HasString (this, "alias")) {
    this.alias = this.name
  }
  foreach (attr, Split ("alias;listalias;original_alias;original_listalias")) {
    if (HasString (this, attr)) {
      set (this, attr, "dirty " + GetString (this, attr))
    }
  }
}
else {
  foreach (attr, Split ("alias;listalias;original_alias;original_listalias")) {
    if (HasString (this, attr)) {
      set (this, attr, Replace (GetString (this, attr), "dirty ", ""))
    }
  }
}

(The 'else' part is only necessary if you're going to have the option to wash the shirt again)
(This code is slightly more complex than it would be for a regular object, because I wanted it to work around the code that adds "(worn)" to the end of an object's alias, so the shirt doesn't become clean again when the player takes it off)

This code will cause the object's alias to change any time its dirty flag is set or unset. You could also use something like {if dirty:It's covered in mud.} in the object's "look at" description.

I think you might be able to do the same using the "multistate" feature of the clothing library, which allows you to add more descriptors using the same system as the 'worn' modifier, but I'm not entirely sure how that works.


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

Support

Forums