ScriptUO

Scripting Resources & Utilities => Stealth Client => Stealth Snippets\Library => Topic started by: JlM on December 19, 2018, 05:44:59 AM

Title: Python item counter, for backpack
Post by: JlM on December 19, 2018, 05:44:59 AM
I have a def that will work if I reach a certain weight. I'm needing one for item count in my backpack. Can someone shoot me in the direction of a example or some documentation. Any help would be appreciated.
Title: Re: Python item counter, for backpack
Post by: ZeroDX on December 19, 2018, 08:05:06 AM
here you are
CountEx (http://stealth.od.ua/Doc:Api/CountEx)
Count (http://stealth.od.ua/Doc:Api/Count)
Title: Re: Python item counter, for backpack
Post by: JlM on December 19, 2018, 09:20:34 AM
Thank you for the response.

To be more descriptive. I need to know when I'm close to over item count ie 120 items in my backpack. I have the ability to do it based on weight, but with certain items I will not be over weight but reach the item limit.

Post Merge: December 19, 2018, 09:25:56 AM
For instance a bod book. Full of bods
Title: Re: Python item counter, for backpack
Post by: ZeroDX on December 19, 2018, 11:31:18 AM
Code: Python
  1. LIMIT = 120
  2.  
  3. if Count(-1) > LIMIT:
  4.     pass  # items quantity in a backpack more than 120
  5.  
Title: Re: Python item counter, for backpack
Post by: JlM on December 19, 2018, 04:11:08 PM
LIMIT = 100

if Count(-1) > LIMIT:
  pass
  print("Overweight")


It prints a blank with no words when i hit play and have more or less than 100 items in bag.
Title: Re: Python item counter, for backpack
Post by: ZeroDX on December 19, 2018, 08:25:28 PM
Code: Python
  1. LIMIT = 100
  2.  
  3. def get_count(type=-1, color=-1, container=Backpack(), recurse=False):
  4.     FindTypeEx(type, color, container, recurse)
  5.     return FindCount()
  6.  
  7. total = Count(-1)  # total items quantiry (if you have only 100gp in your pack, this will return 100)
  8. if total > LIMIT:
  9.     AddToSystemJournal("total quantity: " + str(total) + " greater than LIMIT: " + str(LIMIT))
  10. count = get_count()
  11. if count > LIMIT:
  12.     AddToSystemJournal("quantity: " + str(count) + " greater than LIMIT: " + str(LIMIT))
  13.  
Title: Re: Python item counter, for backpack
Post by: JlM on December 20, 2018, 12:38:15 AM
Thank you for all the help!