How to check player's inventory?

I want to check if an item is in player's inventory(player has taken it before).
How can I do this?


Type and enter "i", "inv", or "inventory", or check the "Inventory" pane on the right-hand side.


Io

If it's IN the player's inventory, then the object's inbuilt .parent stat will be Player and you can check for that. For example:

PackOfCigars.parent=Player

As for if it has ever at one point been in the player's inventory, you need custom attributes for that. Like, say, for PackOfCigars have 'BeenPickedUp' as a true/false. And when you pick up the PackOfCigars, under the 'after this item is taken' run:

PackOfCigars.BeenPickedUp=True

Hope this helps.


There's a core function Got.

Example:

if (Got (screwdriver)) {
  msg ("You unscrew the panel")
}
else {
  msg ("You need a screwdriver to do that")
}

You could also do Contains (game.pov, hammer) (this checks if the object is in the player's inventory, even if it's invisible or inside a locked container. game.pov is the current player object) or check if the item is in the list given by the expression ScopeInventory() (which is what Got does)


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

Support

Forums