Combine down your vial contents

by Lendren

Back to Mechanic's Corner.

Lendren2009-02-14 21:33:09
A simple bit of scripting for zMUD that will combine down your vial contents, or "defrag" them, to maximize the number of empty vials you have. For instance, if you have two half-full vials, or three two-thirds-full vials, you'll end up with empties when you're done.

There are some big limitations to this freebie script. First, this script's not smart enough to handle a mix of regular and artifact vials. (If you have artifact vials, change iDefragVialSize to 110.) Second, the script makes no attempt to address the lifespan of vials: it'll just fill into the earliest vials you have, but it's easy to pour on from there. Third, you have to have Potionlist. Fourth, if you have more vials than fits in one screenful of your potionlist at your pagelength, you'll need to add some lines to automatically do "More", or change the pagelength.

CODE
#CLASS {Equipment|Vials}
#ALIAS defragvials {#if (%trim( %1) = "") {dDefragVials = "";#t+ "tDefragVialsCapture";#temp {^-------------------------------------------------------------------------------$} {#temp {^~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*
~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*$} {#t- "tDefragVialsCapture";defragvials next} "Equipment|Vials"} "Equipment|Vials";pl};#if (%1 == next) {#if (@dDefragVials = "") {#show %ansi( blue, bold, white)Defragmentation of vials is done.} {ScratchVar = "";ResultVar = 0;LabelVar = 0;sCraftStr1 = "";#loopdb @dDefragVials {#if (@ScratchVar = "") {ScratchVar = %word( %val, 1)};#if (@ScratchVar = %word( %val, 1)) {#add ResultVar 1;#add LabelVar %word( %val, 2);#additem sCraftStr1 %key}};#if (@ResultVar > 1 and @LabelVar < (@iDefragVialSize * @ResultVar)) {ScratchVar = %eval( @LabelVar / @iDefragVialSize + 1);ResultVar = @sCraftStr1;#loop 1,@ScratchVar {LabelVar = %pop( ResultVar);#forall @ResultVar {pour %j into @LabelVar}}};#forall @sCraftStr1 {#delkey dDefragVials %i};defragvials next}}}
#VAR dPLVialTypes {}
#ADDKEY dPLVialTypes {a phlegmatic purgati} {phlegmatic}
#ADDKEY dPLVialTypes {a potion of allheale} {allheale}
#ADDKEY dPLVialTypes {a potion of bromides} {bromides}
#ADDKEY dPLVialTypes {a potion of fire} {fire}
#ADDKEY dPLVialTypes {a potion of frost} {frost}
#ADDKEY dPLVialTypes {a potion of healing} {healing}
#ADDKEY dPLVialTypes {a potion of mana} {mana}
#ADDKEY dPLVialTypes {a regeneration salve} {regeneration}
#ADDKEY dPLVialTypes {a sanguine purgative} {sanguine}
#ADDKEY dPLVialTypes {an antidote potion} {antidote}
#ADDKEY dPLVialTypes {empty} {empty}
#ADDKEY dPLVialTypes {liniment} {liniment}
#ADDKEY dPLVialTypes {magical salt} {salt}
#ADDKEY dPLVialTypes {magical sulfur} {sulfur}
#ADDKEY dPLVialTypes {quicksilver} {quicksilver}
#ADDKEY dPLVialTypes {elixir vitae} {vitae}
#ADDKEY dPLVialTypes {a love potion} {love}
#ADDKEY dPLVialTypes {the poison aleutian} {aleutian}
#ADDKEY dPLVialTypes {the poison anatine} {anatine}
#ADDKEY dPLVialTypes {the poison anerod} {anerod}
#ADDKEY dPLVialTypes {the poison botulinum} {botulinum}
#ADDKEY dPLVialTypes {the poison calcise} {calcise}
#ADDKEY dPLVialTypes {the poison chansu} {chansu}
#ADDKEY dPLVialTypes {the poison charybdon} {charybdon}
#ADDKEY dPLVialTypes {the poison contortrin} {contortrin}
#ADDKEY dPLVialTypes {the poison crotamine} {crotamine}
#ADDKEY dPLVialTypes {the poison dendroxin} {dendroxin}
#ADDKEY dPLVialTypes {the poison dulak} {dulak}
#ADDKEY dPLVialTypes {the poison escozul} {escozul}
#ADDKEY dPLVialTypes {the poison hadrudin} {hadrudin}
#ADDKEY dPLVialTypes {the poison ibululu} {ibululu}
#ADDKEY dPLVialTypes {the poison inyoka} {inyoka}
#ADDKEY dPLVialTypes {the poison mactans} {mactans}
#ADDKEY dPLVialTypes {the poison mantakaya} {mantakaya}
#ADDKEY dPLVialTypes {the poison mellitin} {mellitin}
#ADDKEY dPLVialTypes {the poison morphite} {morphite}
#ADDKEY dPLVialTypes {the poison niricol} {niricol}
#ADDKEY dPLVialTypes {the poison saxitin} {saxitin}
#ADDKEY dPLVialTypes {the poison senso} {senso}
#ADDKEY dPLVialTypes {the poison tetrodin} {tetrodin}
#ADDKEY dPLVialTypes {a melancholic purgativ} {melancholic}
#ADDKEY dPLVialTypes {a choleric purgative} {choleric}
#ADDKEY dPLVialTypes {a mending salve} {mending}
#ADDKEY dPLVialTypes {a phlegmatic purgative} {phlegmatic}
#VAR dDefragVials {}
#VAR iDefragVialSize {60}
#TRIGGER "tDefragVialsCapture" {^(%d)%s*vial%s(*)%s(%d)%s{~*|%d}$} {#addkey dDefragVials %1 %concat( %db( @dPLVialTypes, %2), " ", %3)} "" {disable}
#CLASS 0

Enjoy.
Vionne2009-02-14 21:35:31
Thanks!
Shaddus2009-02-14 21:36:46
Any way you can get this to work for Mush?

EDIT: Also, where do you put this in Cmud?
Lendren2009-02-14 22:01:00
I don't know if it'll work in CMUD. In zMUD, either paste it into your entry buffer, or save it to a text file (be sure you don't add wordwrapping) and import it. As for MUSHclient, I'll leave it to someone who does MUSHclient coding to do that. I've done just enough to find it frustrating and yet productive. Someday when I have time to kill (hah!) I will evaluate the mapper add-ons for MUSHclient and decide what to migrate away from zMUD to.

By the way, if you don't already have any Workbench stuff, this will create some scratch variables somewhere, since I used some of the same scratch variables I use in Workbench. No harm will be done, just so you know that's what those are.