Default container message

Is it possible to change the default message when taking something out of a container?

Oddly enough, this isn't easy.

The template TakeSuccessful is the default message for taking an object, and you can modify it as easily as any other template (as in, you can do it using the desktop editor but not on the web).

However, specifying 'when taking it out of a container' means it would be somewhat different. This means you'd need to check whether the object is in a container or not and change the message depending on that.

I can think of 3 ways to do that. Either by having a turnscript that modifies the takemsg of objects that are in reachable containers (complex, but can be used on the wweb version), by having objects automatically set their takemsg when they're moved, or by modifying the DoTake function itself (simpler on desktop version, not on the web version)

Changing takemsg (by turnscript)
Giving each object a boolean attribute changed_takemsg to indicate whether we've modified its takemsg. This version also allows containers to have an attribute takefrommsg for taking objects out of them, and objects to have an attribute takemsgfromcontainer for taking them out of a container.
You might want to change the order of some parts of this, depending which message you want to take priority

foreach (object, ScopeReachableNotHeld()) {
  if (not object.parent = game.pov.parent) {
    // it's in a container
    if ((HasString (object, "takemsgfromcontainer") or not HasString (object, "takemsg")) and not GetBoolean (object, "changed_takemsg")) {
      object.changed_takemsg = true
      object.original_takemsg = object.takemsg
    if (GetBoolean (object, "changed_takemsg")) {
      if (HasString (object.parent, "takefrommsg")) {
        object.takemsg = object.parent.takefrommsg
      else if (HasString (object, "takemsgfromcontainer")) {
        object.takemsg = object.takemsgfromcontainer
      else {
        object.takemsg = CapFirst (WriteVerb (game.pov, "take")) + " " + object.article + " out of the {object:" + + "}."
  else if (GetBoolean (object, "changed_takemsg")) {
    // it's not in a container, but we've already changed its takemsg. So change it back
    object.changed_takemsg = false
    object.takemsg = object.original_takemsg

Off the top of my head, not tested yet, but I think it should work.

Thanks - as it's a minor point of a slightly inappropriate message, I'll leave it for the moment.

Log in to post a reply.