diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-02-28 09:32:08 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-02-28 09:32:08 -0500 |
| commit | a77ee4ce201de757ce4c5958d9e499a65b2cf416 (patch) | |
| tree | 4bce3e93d007a6ec7b09330e25f767c72cd96f90 /gamemode/core/inventory | |
| parent | 93c55ed064591eb4b6f582f09adfe27e6af3c05e (diff) | |
| download | artery-a77ee4ce201de757ce4c5958d9e499a65b2cf416.tar.gz artery-a77ee4ce201de757ce4c5958d9e499a65b2cf416.tar.bz2 artery-a77ee4ce201de757ce4c5958d9e499a65b2cf416.zip | |
Generalize the ply:Has() function
Allow ply:Has() to accept functions (it already did, but now the
documentation matches to explicitly allow it), and the variable names
are not misleading.
Diffstat (limited to 'gamemode/core/inventory')
| -rw-r--r-- | gamemode/core/inventory/sv_invtracker.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/gamemode/core/inventory/sv_invtracker.lua b/gamemode/core/inventory/sv_invtracker.lua index 88de42e..257410b 100644 --- a/gamemode/core/inventory/sv_invtracker.lua +++ b/gamemode/core/inventory/sv_invtracker.lua @@ -207,13 +207,13 @@ end local plymeta = FindMetaTable("Player") ---A shortcut to check if a player has an item. --- Checks if a player has an item ---@metamethod player:HasItem(str) ---@tparam string str The name of the item to look for +-- Checks if a player has an item. This method will only return the position of the FIRST item found that matches. The player MAY have other items which match. +--@metamethod player:HasItem(ptr) +--@tparam (string|function) ptr If ptr is a string, looks for an item with the same name, ptr may also be a function that takes 1 argument (an item) and returns true if the item is what you're looking for. --@treturn table|false Returns the position if the player has the item, false if they don't -function plymeta:HasItem(str) +function plymeta:HasItem(ptr) for k,v in pairs(self.data.inventories) do - local p = v:Has(str) + local p = v:Has(ptr) if type(p) == "table" then return {k,p} end |
