add inventory.decrement, inventory.set_count

This commit is contained in:
MihailRis
2025-02-20 19:47:50 +03:00
parent 12105c2933
commit 8fecc70e05
2 changed files with 20 additions and 1 deletions
+10 -1
View File
@@ -102,7 +102,6 @@ function inventory.get_uses(invid, slot)
return uses
end
function inventory.use(invid, slot)
local itemid, count = inventory.get(invid, slot)
if itemid == nil then
@@ -119,6 +118,16 @@ function inventory.use(invid, slot)
end
end
function inventory.decrement(invid, slot, count)
count = count or 1
local itemid, itemcount = inventory.get(invid, slot)
if itemcount <= count then
inventory.set(invid, slot, 0)
else
inventory.set_count(invid, slot, itemcount - count)
end
end
------------------------------------------------
------------------- Events ---------------------
------------------------------------------------