add inventory.decrement, inventory.set_count
This commit is contained in:
+10
-1
@@ -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 ---------------------
|
||||
------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user