quest: Problems with take ALL and drop ALL (5.8 beta)

Default behavior

You are in a room. You can see a table (on which there is a basket (containing a bag (containing a ball))).

> get all basket: You pick it up. bag: You pick it up. ball: You pick it up.

> drop all basket: You drop it. bag: You drop it. ball: You drop it.

> undo Undo: drop all

> undo Undo: get all

> l You are in a room. You can see a table (on which there is a basket (containing a bag (containing a ball))).

> get basket You pick it up.

> i You are carrying a basket (containing a bag (containing a ball)).

> drop all basket: You drop it. bag: You are not carrying it. ball: You are not carrying it.


My “fixes”

EDIT This is no good!

This may not be the best way to handle this, but it seems to work VERY well UNLESS directly dealing with an object in a held container.


Take

if (multiple and ListCount(object) = 0) {
 msg ("Nothing here to take.")
}
else {
 foreach (obj, object) {
   if (not ListContains(GetAllChildObjects(game.pov),obj)) {
     DoTake (obj, multiple)
   }
 }
}

Drop

if (multiple and ListCount(object) = 0) {
  msg ("You are not carrying anything.")
}
else {
  foreach (obj, object) {
    if (obj.parent = game.pov) {
      DoDrop (obj, multiple)
    }
  }
}

You are in a room. You can see a table (on which there is a basket (containing a bag (containing a ball))).

> get all basket: You pick it up.

> i You are carrying a basket (containing a bag (containing a ball)).

> drop all basket: You drop it.

> i You are not carrying anything.

> l You are in a room. You can see a table and a basket (containing a bag (containing a ball)).

> get all basket: You pick it up.

> i You are carrying a basket (containing a bag (containing a ball)).

> l You are in a room. You can see a table.

> put basket on table Done.

> i You are not carrying anything.

> l You are in a room. You can see a table (on which there is a basket (containing a bag (containing a ball))).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 35 (12 by maintainers)

Commits related to this issue

Most upvoted comments

I think the drop script is fine. Here is a take script; see how it looks to you. Works for me.

if (multiple and ListCount(object) = 0) {
  msg ("Nothing here to take.")
}
else {
  foreach (obj, object) {
    // if this is multiple then we should skip anything in a container that will be taken
    // and anything held by an NPC
    if (not multiple or (not obj.parent.take and not DoesInherit(obj.parent, "npc_type"))) {
      DoTake (obj, multiple)
    }
  }
}

This is the thread: http://textadventures.co.uk/forum/quest/topic/pl1aur8l3usk2lrn_rzy1g/meaning-of-take-all-and-drop-all

See also: https://www.intfiction.org/forum/viewtopic.php?f=6&t=26137&sid=ce7d6e41a03e6386325475824da3bce9

I think we can rearrange it. And use a template:

took_something = false
foreach (obj, object) {
  // if this is multiple then we should skip anything in a container that will be taken
  // and anything held by an NPC
  if (not multiple or (not Contains(game.pov, obj.parent) and not DoesInherit(obj.parent, "npc_type"))) {
    DoTake (obj, multiple)
    took_something = true
  }
}
if (multiple and not took_something) {
  msg ("[NothingToTake]")
}

I have uploaded a modified CoreCommands to Github. I have also modified it so the blocking message is customisable (as a good way to give NPC items is to have the NPC as a transparent container); in a later version I will add something to the editor for that too.

DROP ALL:

That looks good. I was worried that an item that appears in the game file before the container would be listed before the container in object, but that is not the case, so this works as it should.

Sorry, I meant the drop script you have above, not the one in the beta.