[Adventuron] Checking if an object is directly carried (not in a container)

Is there a simple way of checking if an object is directly carried by the player (not inside a container that the player is carrying). Something like ‘is_directly_carried’?

I can do this double checking, but it is clunky:

: if (is_carried “magic_wand”) {
: if (!is_within_direct {outer = “bag” inner = “magic_wand” }) {
}
}

This might help …

: if (parent_of "magic_wand" == "inventory") {
   // Do something
}

Ah, thanks. I tried checking if outer = “inventory” but it wasn’t having it. Fussy like that, isn’t it?

The actual name of the inventory slot is the id of the player, which by default is “player” (a reserved id). The documentation for the parent_of “” function states that if the parent is the current protagonist that it will be substituted with “inventory”, which in hindsight is not particularly a good idea. I don’t think I can change it now without the sky falling.

parent_of function description:

“Returns the direct parent of an object or entity (can be a location id, an object id, ‘inventory’, or ‘ether’. If an invalid item is specified, then “unknown” is returned. If the item is carried by the player then ‘inventory’ will be returned. If the item does not exist, then “ether” will be returned.”

It be very handy if there was just a setting to include or exclude items in a container from is_carried, or if there was something like is_holding. I’ve got a bag with things in it that I can only manipulate if they’re out of the bag, and it’s a bit of a pain to have to remember to use if parent_of "x"=="inventory" rather than just if is_carried to check if I’ve got them and they’re out of the container that I’m carrying. What you say above suggests that it is difficult to change the way things are set up, but looking ahead to when containers are a proper thing in Adventuron, this sort of checking is going to be a bit burdensome (for me at least; other people might not give a hoot).

is_holding “object_id” has been added to the new beta.

Docuentation here:

2 Likes

Great! Thanks Chris.