Remaining stackable number||doc135660

September 20, 2022

Format

 item:stack_free() 
  • The class to which the function belongs:item

Description

Get the number of remaining items.


Value Returned

type Description
int Number of remaining items


Code Samples

On the server side of the player entity templatemount script, add the error when the registered player switches hand-held itemCallback, if the new item is not empty, output its remaining item count

Trigger.addHandler(this:cfg(), "HAND_ITEM_CHANGED", function(context)
      local entity = context.obj1
      local newItem = context.item
      print(newItem and newItem:stack_free())     
end)