How to check player's inventory?
StrangeCloud9
28 Jan 2019, 21:03I want to check if an item is in player's inventory(player has taken it before).
How can I do this?

Dcoder
28 Jan 2019, 21:08Type and enter "i", "inv", or "inventory", or check the "Inventory" pane on the right-hand side.

Io
28 Jan 2019, 21:21If 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.
mrangel
28 Jan 2019, 21:26There'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)