dummy.lua 434 B

1234567891011121314151617181920212223242526
  1. function ItemStack(obj)
  2. local name, count
  3. if obj.get_count then
  4. name = obj:get_name()
  5. count = obj:get_count()
  6. else
  7. name, count = string.match(obj, "^([A-Za-z0-9:]+) ([0-9]+)$")
  8. if not name then
  9. name = obj
  10. end
  11. count = tonumber(count or 1)
  12. end
  13. return {
  14. get_name = function(self)
  15. return name
  16. end,
  17. get_count = function(self)
  18. return count
  19. end,
  20. set_count = function(self, v)
  21. count = v
  22. end,
  23. }
  24. end