Capturing number of certain vials and sending a world.note

Posted by Natasi on Sun 20 Feb 2005 03:30 AM — 5 posts, 25,395 views.

#0
Ok, trying to set it so when I check my vial list I receive a world.note telling me how many of each vial type I have....for example...I type POTIONLIST and I would see this...



*******************************************************************************
Id       Vial                           Potion                   Sips   Months 
-------------------------------------------------------------------------------
9402     a sapphire vial                a melancholic purgat        9       51
10969    a coral vial                   a sanguine purgative       30       22
11582    a ruby vial                    a potion of allheale       55       81
14275    a ruby vial                    a potion of allheale       60       81
18626    a coral vial                   a sanguine purgative       50       22
20883    a vial                         a potion of frost           5       30
61868    a ruby vial                    a potion of healing        60       56
Type MORE to continue reading. (97% shown)
more
3583h, 2793m, 2779e, 10p ex-
54854    a ruby vial                    a potion of healing        60       61
*******************************************************************************
Total Vials: 8



and I want a world.note that shows something like this, which would also catch vials I'm missing....

Healing 2
Melancholic 1
Sanguine 2
Allheale 2
Frost 1
Quicksilver 0
Mana 0
Amended on Sat 26 Feb 2005 09:17 PM by Nick Gammon
#1
hmmm, it kinda crunched those together...it' usually spaced out pretty well in the Mud
USA #2
Need a [code] tag if you want to keep proper spacing, the forum is designed to strip whitespace otherwise.
Amended on Sun 20 Feb 2005 05:34 AM by Meerclar
#3
Ok, I rememebr working in OLC and it seemed alot like VBscript. There was a way there to set up a capture that would have a variable it would update everytime another number was added....so when it sees the first vial, it sends a 1 to the variable, when it sees the second vial, it sends another 1, which is added to the 1 already there making it a two...so a counter. you know, I just confused myself...
Russia #4
You'd need two triggers: one for capturing the vial info, and the second one to match on the prompt and disable both itself and the vial trigger. Place them in one group, named "PotionList" for example. Then add an alias to match on "potionlist" or whatever command you want to use for that skill. Have the potionlist alias send the following to script (if you use vbscript):


EnableTriggerGroup "PotionList", 1
Send "config pagelength 250"
Send "potionlist"


Then have the prompt trigger send to script also:


EnableTriggerGroup "PotionList", 0
Send "config pagelength 25"
EndVials


"config pagelength" commands will allow you to avoid the MORE's unless you have more than 250 vials. The following script keeps track of how many vials with each type of potion you have and how many total sips you have of each potion:


dim vails, sips
Set vials = CreateObject("Scripting.Dictionary")
Set sips = CreateObject("Scripting.Dictionary")

sub GotVial(name, output, wildcs)
   dim potion_name, sips_num
   potion_name = wildcs(1)
   sips_num = wildcs(2)
   if vials.Exists(potion_name) then
      vials.Item(potion_name) = vials.Item(potion_name) + 1
   else
      vials.Item(potion_name) = 1
   end if
   if sips.Exists(potion_name) then
      sips.Item(potion_name) = sips.Item(potion_name) + cint(sips_num)
   else
      sips.Item(potion_name) = cint(sips_num)
   end if
end sub

sub EndVials
   ReportVials 
   vials.RemoveAll
   sips.RemoveAll
end sub

sub ReportVials
   dim report
   report = ""
   for each key in vials.Keys
      report = report & key & ": vials=" & vials.Item(key) & ", sips=" & sips.Item(key) & vbCRLF
   next
   Note report 
end sub


The most import part is the trigger that matches on the lines containing the vial info. That trigger should capture exactly 2 wildcards: the first one should contain the potion name, and the second - amount of sips left. The trigger match should be something like:

"^\d+\s+[a-z]+?(melancholic|sanguine|allheale|frost|healing|mana)[a-z]*?\s+(\d{1,3})\s+\d+$"

The first parenthesized group contains all the potion names as they appear on potionlist and that will be used inside the script. I'd put this into a plugin, but as I don't have POTIONLIST yet myself, testing it would be somewhat problematic.