Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Nov 16, 2008 1:15 am   

Achaea Elixir Brewing & Selling Script 2.xx Series.
 
This is the 2.4 version of the script, which I have written on commission. There are more features planned, but for now this is where it is at. I only anticipate doing bugfixes to the 2.xx series, an I will update this thread every time I do. Once I get the 2.xx series stable I will begin work on the 3.xx which will introduce considerably more feature. For the actual commands and usage instructions, please issue 'elixerhelp' (an alias) after importing. Please PM me with any bugs you find. Thanks.

EDIT: Updated to 2.5
Fixed Bug With s.sname format usage. s. without a prepending number was broken due to a small oversight on my part.

EDIT: Updated to 2.6
Gah!! I missed the end of the inpot commands. Oops.

EDIT: Updated to 2.7
There was a bug in the code that would prevent execution if the process was unnaturally interrupted. I've take this into account with an alias to clear the var that makes things stick. I've also added an #ECHO for the completion, to make it more noticeable that the script if finished. This is especially useful if you're using it to its full capabilities to make a lot of elixirs at once.

Code:
#CLASS {Elixers}
#ALIAS melix {#CLASS {Elixers|Vars};#VAR MelixArgs %subchar( %-1, " ", "|");#VAR MelixArgs %subchar( @MelixArgs, ".", " ");#LOOP %numitems( @MelixArgs) {#IF (%numwords( %item( @MelixArgs, %i)) > 1) {#IF (%rightback( %word( @MelixArgs, 1), 1) = "s") {#IF (%numwords( %remove( s, %item( @MelixArgs, %i))) > 1) {#VAR MelixArgs %replaceitem( %concat( %eval( 4 * %remove( s, %word( %item( @MelixArgs, %i), 1))), " ", %word( %item( @MelixArgs, %i), 2)) , %i, @MelixArgs)} {#VAR MelixArgs %replaceitem( %concat( "4 ", %word( %item( @MelixArgs, %i), 2)) , %i, @MelixArgs)}};#LOOP %eval( %word( %item( @MelixArgs, %i), 1) - 1) {#VAR MelixArgs %additem( %word( %item( @MelixArgs, %i), 2), @MelixArgs)};#VAR MelixArgs %replaceitem( %word( %item( @MelixArgs, %i), 2), %i, @MelixArgs)}};#VAR MelixArgs %countlist( @MelixArgs);#IF (@ElixMake) {#ECHO {Sorry, you're already processing an order. Please wait til it completes and try again.};#ECHO {If there is no processing going on, then you have a blocked up queue. Please use the command 'clrelix' to clear it.};#ABORT 1} {#VAR ElixMake {};#LOOPDB @MelixArgs {#ADDKEY ElixMake %key %val};#VAR CurrElix {};#VAR OpNum {1};#VAR Ingreds {}};#CLASS 0;goff;gen;#WAIT 3000;op @pot;#EXEC DoElixer}
#ALIAS DoElixer {#CLASS {Elixers|Vars};#LOOPDB @ElixMake {#VAR CurrElix %key;#VAR OpNum %val};#VAR Ingreds {};#LOOP @OpNum {#FORALL %db( @Recipes, @CurrElix) {#VAR Ingreds %additem( %j, @Ingreds)}};#VAR Ingreds %countlist( @Ingreds);#CLASS 0;#LOOPDB @Ingreds {#IF (%val > 1) {outr %val %key} {outr %key}};#LOOPDB @Ingreds {#IF (%val > 1) {inpot %val %key in @pot} {inpot %key in @pot}};drop @pot;boil @pot for %db( @RecipeNames, @CurrElix)}
#ALIAS celix {#ECHO %cr;#ECHO {Calculating Herb Requirements For: %-1};#CLASS {Elixers|Vars};#VAR CalcList %subchar( %-1, " ", "|");#VAR CalcList %subchar( @CalcList, ".", " ");#LOOP %numitems( @CalcList) {#IF (%numwords( %item( @CalcList, %i)) > 1) {#IF (%rightback( %word( @CalcList, 1), 1) = "s") {#IF (%numwords( %remove( s, %item( @CalcList, %i))) > 1) {#VAR CalcList %replaceitem( %concat( %eval( 4 * %remove( s, %word( %item( @CalcList, %i), 1))), " ", %word( %item( @CalcList, %i), 2)) , %i, @CalcList)} {#VAR CalcList %replaceitem( %concat( "4 ", %word( %item( @CalcList, %i), 2)) , %i, @CalcList)}};#LOOP %eval( %word( %item( @CalcList, %i), 1) - 1) {#VAR CalcList %additem( %word( %item( @CalcList, %i), 2), @CalcList)};#VAR CalcList %replaceitem( %word( %item( @CalcList, %i), 2), %i, @CalcList)}};#VAR CalcHerbs {};#VAR CalcCost {};#FORALL @CalcList {#FORALL %db( @Recipes, %i) {#CLASS {Elixers|Vars};#VAR CalcHerbs %additem( %j, @CalcHerbs);#CLASS 0};#ADD CalcCost %db( @RecipeCosts, %i)};#VAR CHerbCount %countlist( @CalcHerbs);#ECHO {You Need The Following Herbs To Supply %-1};#LOOPDB @CHerbCount {#ECHO %key %val};#ECHO {For a total cost of: @CalcCost};#CLASS 0}
#ALIAS slelix {#ECHO %cr;#ECHO {--------------------------------------------------};#ECHO {%format( "&-24s &s", "Long Name", "Short Name")};#LOOPDB @RecipeNames {#ECHO {%format( "&-24s &s", %proper( %val), %proper( %key))}}}
#ALIAS elixerhelp {#ECHO %cr;#ECHO {Elixer Creator Version: @ElixerVers};#ECHO {By Ralgith of Zuggsoft Forums};#ECHO {--------------------------------------------------};#ECHO {Commands:};#ECHO {slelix: View the elixer shortlist names compared to their complete names.};#ECHO {melix <[n][s].sname [..]>:};#ECHO {....Adds the argumentlist of elixers to the queue to be made. If the queue was empty, it also starts processing.};#ECHO {....Examples: 3.health will get 3 health fills. 2s.mana will get 2 super (a super is 4 fills) fills.};#ECHO {celix <[n][s].sname [..]>:};#ECHO {....Calculates the number of herbs needed to make the named elixer(s).};#ECHO {....Examples: celix 9.mana 3.imm s.health will list the herbs needed to create 9 mana fills,};#ECHO {....3 immunity fills, and a super health fill.};#ECHO {--------------------------------------------------};#ECHO {TODO:};#ECHO {Add automated needs checking to the celix command. (3.xx)};#ECHO {--------------------------------------------------};%cr}
#ALIAS clrelix {#VAR ElixMake {};#VAR CurrElix {};#VAR OpNum {1};#VAR Ingreds {}}
#TRIGGER {With a sudden slow pulsing of white light} {get @pot;#WHILE (@OpNum > 4) {fill empty from pot 4 times;#CLASS {Elixers|Vars};#VAR OpNum %eval( @OpNum - 4);#CLASS 0};fill empty from @pot @OpNum times;#DELKEY ElixMake {@CurrElix};#IF (@ElixMake) {#EXEC DoElixer} {#VAR CurrElix {};#VAR OpNum {1};#VAR Ingreds {};inp @pot;#ECHO {Elixer Set Completed.}}}
#CLASS 0
#CLASS {Elixers|Vars}
#VAR Recipes {Manaslipper|bellwort|hawthorn|bloodrootImmsac|ash|echinacea|echinaceaSpeedskin|kuzu|goldenseal|gingerHealthvalerian|goldenseal|ginseng|myrrhEpikuzu|kuzu|bloodroot|hawthorn|ginsengVenomsac|cohosh|kelp|skullcapFrostkelp|pear|ginsengCalkuzu|kuzu|valerian|kelp|kelp|bellwortLevpear|feather|kelp|kelpMenddust|kelp|kuzu|ginger|gingerMassmoss|bloodroot|kuzu|dustRestgold|gold|kuzu|kuzu|valerian|bellwort}
#VAR RecipeNames {ManamanaImmimmunitySpeedspeedHealthhealthEpiepidermalVenomvenomFrostfrostCalcaloricLevlevitationMendmendingMassmassRestrestoration}
#VAR RecipeCosts {Mana200Imm300Speed400Health200Epi400Venom400Frost400Cal500Lev700Mend500Mass500Rest900}
#VAR ElixerVers {2.7}
#VAR OpNum {8}
#VAR CalcList {mend|mend|mend|mend}
#VAR CalcHerbs {dust|kelp|kuzu|ginger|ginger|dust|kelp|kuzu|ginger|ginger|dust|kelp|kuzu|ginger|ginger|dust|kelp|kuzu|ginger|ginger}
#VAR CHerbCount {dust4kelp4kuzu4ginger8}
#VAR CalcCost {2000}
#VAR Ingreds {valerian8goldenseal8ginseng8myrrh8}
#VAR MelixArgs {health8mana4}
#VAR ElixMake {}
#VAR CurrElix {health}
#CLASS 0
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate

Last edited by ralgith on Mon Nov 17, 2008 1:52 am; edited 4 times in total
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Nov 16, 2008 4:25 am   
 
Updated a bug already. Just a small one, but critical. Version 2.5 now. Code block edited in original post.

Thanks Fragen ;)
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Nov 16, 2008 4:44 am   
 
Updated another bug. I had it as 'inpot herbname' instead of 'inpot herbnam in pot'
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Nov 16, 2008 8:59 pm   
 
Wow, this is so much more complex than mine ever was. I just had a bunch of aliases - alias to put all my vials away, alias to inpot however many ingredients were needed to make the elixir and boil it (also putting the price for that many of that elixir into a variable), and an alias to fill vials (from elixlist) and give them back. I had a timer for +60secs that reminded me to reset the price variable when I was done, which I did manually.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sun Nov 16, 2008 11:46 pm   
 
And to think, this isn't even as feature complete as I'd like it to be ;)

This is just version 2, the result of about 4 days of writing and bug testing... took so long with me not being a player there and needing others to do the testing for me.

When I do version 3 it will automatically make sure you have the ingreds both when you use celix and when you use melix.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Mon Nov 17, 2008 1:57 am   
 
I've updated it again to 2.7 - some minor bugs that most people wouldn't even see. But better to fix them than leave them at any rate.

Also, here is the code to the final 1.xx version, which is pretty spammy and far from ideal. I'm posting it here just so others can see what I did between the 2 major revision versions and maybe it'll help show someone else the great uses you can put data record vars to. Especially the turning of a stringlist into a data record using %countlist().

Code:
#CLASS {Elixers}
#ALIAS melix {#CLASS {Elixers|Vars};#VAR OpNum {1};#VAR ElixMake %subchar( %1, ".", " ");#CLASS 0;#IF (%lower( %2) = "super") {#CLASS {Elixers|Vars};#VAR OpNum 4;#CLASS 0};#IF (%numwords( @ElixMake) > 1) {#VAR OpNum %eval( @OpNum * %word( @ElixMake, 1));#VAR ElixMake %word( @ElixMake, 2)};goff;gen;#WAIT 3000;op @pot;#LOOP @OpNum {#FORALL %db( @Recipes, @ElixMake) {outr %j}};#LOOP @OpNum {#FORALL %db( @Recipes, @ElixMake) {inpot %j in @pot}};drop @pot;boil @pot for %db( @RecipeNames, @ElixMake)}
#ALIAS celix {#ECHO %cr;#ECHO {Calculating Herb Requirements For: %-1};#CLASS {Elixers|Vars};#VAR CalcList %subchar( %-1, " ", "|");#VAR CalcList %subchar( @CalcList, ".", " ");#LOOP %numitems( @CalcList) {#IF (%numwords( %item( @CalcList, %i)) > 1) {#LOOP %word( %item( @CalcList, %i), 1) {#VAR CalcList %additem( %word( %item( @CalcList, %i), 2), @CalcList)};#VAR CalcList %replaceitem( %word( %item( @CalcList, %i), 1), %i, @CalcList)}};#VAR CalcHerbs {};#VAR CalcCost {};#FORALL @CalcList {#FORALL %db( @Recipes, %i) {#CLASS {Elixers|Vars};#IF (%numwords( %j) > 1) {#LOOP %word( %j, 1) {#VAR CalcHerbs %additem( %word( %j, 2), @CalcHerbs)}} {#VAR CalcHerbs %additem( %j, @CalcHerbs)};#CLASS 0};#ADD CalcCost %db( @RecipeCosts, %i)};#VAR CHerbCount %countlist( @CalcHerbs);#ECHO {You Need The Following Herbs To Supply %-1};#LOOPDB @CHerbCount {#ECHO %key %val};#ECHO {For a total cost of: @CalcCost};#CLASS 0}
#ALIAS slelix {#ECHO %cr;#ECHO {--------------------------------------------------};#ECHO {%format( "&-24s &s", "Long Name", "Short Name")};#LOOPDB @RecipeNames {#ECHO {%format( "&-24s &s", %proper( %val), %proper( %key))}}}
#ALIAS elixerhelp {#ECHO %cr;#ECHO {Elixer Creator Version: @ElixerVers};#ECHO {By Ralgith of Zuggsoft Forums};#ECHO {--------------------------------------------------};#ECHO {Commands:};#ECHO {melix <elixer shortname> [super]:};#ECHO { This will make the elixer specified via shortname. If you specifiy super, it will make};#ECHO { a completely fulled vial (4 standard fills) instead. You can also use n.sname to make a 'multi'};#ECHO { batch. This format can also be combined with super to make batches of 'super' potions.};#ECHO { example, melix 11.health would make 2 full vials of health and a 3rd vial that is 3/4 full,};#ECHO { while melix 11.health super would make 11 full vials. This supplants the previous 'multi' keyword.};#ECHO {slelix: View the elixer shortlist names compared to their complete names.};#ECHO {celix <elixer shortname(s)>: Calculates the number of herbs needed to make the named potion(s).};#ECHO { celix can take multiple short names and parse them all. For example celix imm imm health mana};#ECHO { would tell you what herbs are required to make 2 immunity and 1 each of health and mana.};#ECHO { New celix format allowed also, using n.sname. For example celix 2.imm health mana.};#ECHO {--------------------------------------------------};#ECHO {TODO:};#ECHO {Add multi-elixer support to the melix command, and a queue system to backend said support. (2.0)};#ECHO {Add automated needs checking to the celix command. (2.xx)};#ECHO {Combine herb outr/inpot into a smaller loop set for less spam. (3.0)};#ECHO {Upgrade the n.sname to n[s].sname and remove the 'super' keyword.};#ECHO {--------------------------------------------------};%cr}
#TRIGGER {With a sudden slow pulsing of white light} {get @pot;#WHILE (@OpNum > 4) {fill empty from pot 4 times;#CLASS {Elixers|Vars};#VAR OpNum %eval( @OpNum - 4);#CLASS 0};fill empty from pot @OpNum times;inp @pot}
#CLASS 0
#CLASS {Elixers|Vars}
#VAR Recipes {Manaslipper|bellwort|hawthorn|bloodrootImmsac|ash|2 echinaceaSpeedskin|kuzu|goldenseal|gingerHealthvalerian|goldenseal|ginseng|myrrhEpi2 kuzu|bloodroot|hawthorn|ginsengVenomsac|cohosh|kelp|skullcapFrostkelp|pear|ginsengCal2 kuzu|valerian|2 kelp|bellwortLevpear|feather|2 kelpMenddust|kelp|kuzu|2 gingerMassmoss|bloodroot|kuzu|dustRest2 gold|2 kuzu|valerian|bellwort}
#VAR RecipeNames {ManamanaImmimmunitySpeedspeedHealthhealthEpiepidermalVenomvenomFrostfrostCalcaloricLevlevitationMendmendingMassmassRestrestoration}
#VAR RecipeCosts {Mana200Imm300Speed400Health200Epi400Venom400Frost400Cal500Lev700Mend500Mass500Rest900}
#VAR ElixerVers {1.7}
#VAR OpNum {4}
#VAR Mode {1}
#VAR CalcList {4|imm|imm|imm|imm}
#VAR CalcHerbs {sac|ash|echinacea|echinacea|sac|ash|echinacea|echinacea|sac|ash|echinacea|echinacea|sac|ash|echinacea|echinacea}
#VAR CHerbCount {sac4ash4echinacea8}
#VAR CalcCost {1200}
#VAR ElixMake {imm}
#CLASS 0
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net