Generic Categoriser/Inventory or Contents Lister - with colours

Share your scripts and packages with other Mudlet users.
Post Reply
User avatar
ulysses
Posts: 42
Joined: Fri Jan 05, 2018 7:43 pm

Generic Categoriser/Inventory or Contents Lister - with colours

Post by ulysses » Sat Mar 10, 2018 10:02 am

Hi,

Here is a script I wrote for CthulhuMUD (www.cthulhumud.org) but could easily be adapted for other MUDs. The idea is to process a list of items, categorise them using pre-defined strings (which you will need to maintain) then output them by category in alphabetical order. Here it is:
ContentsLister-v1.0.xml
(9.63 KiB) Downloaded 30 times
Notes:
  1. For other muds besides CthulhuMUD you will need to change the trigger from 'It contains:' to whatever the starting string is for the start of your list.
  2. If you've changed the trigger string, then also put that in the top line of the third script 'called 'Contents Lister', the one that looks like this:

    Code: Select all

    if not string.match(line, 'It contains') then
    This is necessary to prevent the gate opening and closing too quickly if the 'It contains' appears on the same line as the prompt, which it can do on CthulhuMUD. On other MUDs this might not be an issue, if you can guarantee that the prompt has a newline character after it.
  3. Your prompt match will probably need changing in the 'Contents Lister' trigger (the one that closes the gate). Also I wrote a another function isMyPrompt (defined at the end of ContentGate) which matches my prompt, since the in-built isPrompt does not work on CthulhuMUD. If your MUD supports isPrompt, then you can replace both the perl regex and the function with isPrompt.
  4. Other parts of the script should be portable, except perhaps the read quantity part in CaptureContents (line 35ff).
  5. There is a separate category OTHER (which is distinct from MISC), which is ideally empty. The idea is that you stand in front of your locker/chest/whatever, repeatedly listing the contents, then adding items which appear in OTHER to the various categories defined in ContentGate, until OTHER is empty. The purpose of this is to ensure that no items are uncategorised and that all items that are purposefully MISC are put there. I didn't want to miss that all-important item lurking in a big MISC category just because I hadn't spotted it.
  6. All strings are lower case in the categories. The script takes case of variations in case in the items being matched.
  7. There is a pecking order in the matching, so weapons come first, then armor and so on, with misc and other last. You might find you need to shuffle the order around to get items properly categorised.
  8. If you want to add a new category, it's very easy. Add the strings at the top of ContentGate, an empty table called my<NAME>. Add a new branch to the if statement on line 80 of CaptureContents and finally add a call to the print function at the end of Contents Lister.
  9. Pleeeease reply if you have any issues with this script, or have any suggestions for improvement. If generic I will happily make improvements.
Enjoy,
Ulysses
Last edited by ulysses on Sun Mar 11, 2018 5:58 pm, edited 1 time in total.
Wod :mrgreen:
CthulhuMUD
www.cthulhumud.com
A hugely entertaining MUD based on the horror writings of HP Lovecraft.

User avatar
Vadi
Posts: 4551
Joined: Sat Mar 14, 2009 3:13 pm

Re: Generic Categoriser/Inventory or Contents Lister - with colours

Post by Vadi » Sun Mar 11, 2018 3:38 am

Nice! Could you show a screenshot?

User avatar
ulysses
Posts: 42
Joined: Fri Jan 05, 2018 7:43 pm

Re: Generic Categoriser/Inventory or Contents Lister - with colours

Post by ulysses » Sun Mar 11, 2018 6:17 pm

Vadi wrote:
Sun Mar 11, 2018 3:38 am
Nice! Could you show a screenshot?
Thanks, Vadi. Here's a screenshot of the first part of the listing:
Screenshot 2018-03-11 18.08.19.png
And another a bit further down:
Screenshot 2018-03-11 18.27.42.png
I'm thinking that a two-column (or N-column) output might be a next big improvement. Just having things categorised and sorted alphabetically is a massive bonus - before it was a complete jumble and very time consuming to find one particular item. I just noticed that all the keyrings end up in JEWELS not KEYS because of 'ring' - something to fix!
Wod :mrgreen:
CthulhuMUD
www.cthulhumud.com
A hugely entertaining MUD based on the horror writings of HP Lovecraft.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests