Check for an empty inventory in PunyInform / Inform6

I check for an item in my inventory using

if (IndirectlyContains(player, hiking_clothes))

How can I check if my inventory is completely empty?

Best wishes for the weekend!

Thomas

children(obj) will return the number of children of the object.

I think children(player) will return everything directly in the player; you may need to account for worn items if you just want held items.

you could also loop through everything directly contained in the player with an object loop. something like:

objectloop (x in player) {
     if(x hasnt worn)
     {
         (increment some counter variable here)
     {
}

this will give you the count of everything directly held but not include worn items.

What @cfmoorz2 says is correct.

However, the fastest way to check if the player’s inventory is empty is to check the object number of the first child. If there are no children, 0 is returned.

if(child(player) == nothing)
  "You're empty handed!";

(nothing has the value 0 in Inform 6)

1 Like