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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Rugbystyle
Wanderer


Joined: 07 Oct 2001
Posts: 71

PostPosted: Tue Nov 13, 2001 8:40 pm   

Prioritizing Stringlists
 
What I would like to know is how to start a priority stringlist system. That would update and prioritize based on inputs from the mud. Example, if my character went to an alchemist and was given 6 potions. Healing, Wellness, Restore, Vitalize, Vigour, Boost. I want a trigger that would put each potion into a stringlist in predefined order so each time I hit my DrinkPotion macro it would drink the top prioritized potion.

Examples
Danjjir the Alchemist hands you a Healing potion.
237h, 954m
Danjjir the Alchemist hands you a Restore potion.
237h, 954m
Danjjir the Alchemist hands you a Vitalize potion.
237h, 954m
Danjjir the Alchemist hands you a Vigour potion.
237h, 954m
Danjjir the Alchemist hands you a Wellness potion.
237h, 954m
Danjjir the Alchemist hands you a Boost potion.
237h, 954mv

So I want a trigger that would Fire on the msg of {Danjjir the Alchemist hands you a %1 potion.} And stores the potion type in a prioritized stringlist like. Vitalize|Vigour|Healing|Boost|Wellness|Restore.

My problem is getting the varibles to be stored in order, even if they are given to me in a different order. And to complicate it even further...
If I hit my DrinkPotion macro, so it would drink Vitalize, then Vigour (based on the priority stated before). So now the list is
Healing|Boost|Wellness|Restore
And then I am handed another Vitalize potion. I would need the list to reflect the addition in priority. IE the new list for the macro would need to be.
Vitalize|Healing|Boost|Wellness|Restore

I tried to explain how I want the list to work as best as I could. This potion example is just one of many things that I would like a system like this for. If any further explination is needed, I'll do my best. Any help would be greatly appreciated.

Thank you.
Reply with quote
Serentus
Apprentice


Joined: 28 Sep 2001
Posts: 103
Location: USA

PostPosted: Wed Nov 14, 2001 11:02 am   
 
I don't if this it what you are looking for or not, but this is how i have done priority queues in the past.

First make a master list if the potions.
#VAR MastPotionList Vitalize|Vigour|Healing|Boost|Wellness|Restore

then the trigger with this pattern:
Danjjir the Alchemist hands you a (%w) potion.

inside the trigger:

find the postion of the potion you were given in you master list.
@pos = %ismember(%1,@MastPotionList)

next find add that number to name sperated by a "-"
#ADDITEM PotionList {@pos-%1}

last thing in the trigger is to sort the list.
%sort(@PotionList)

This will result in a list that looks like:


This will result in you creating a list that looks like:

1-Vitalize|2-Vigour|3-Healing|4-Boost|5-Wellness|6-Restore

Then when you need to drink a potion you take the number out like this.
@Potion = %item(@PotionList,1)
drink %word(@Potion,2,-)
@DELNITEM @PotionList 1

This will take the first item in the @PotionList and store it in @Potion
Then it will take the second word in @Potion where the words are seperated by a "-"
Then delete the first item in @PotionList.

in other words:

#VAR MastPotionList Vitalize|Vigour|Healing|Boost|Wellness|Restore
#TRIGGER {Danjjir the Alchemist hands you a (%w) potion.} {@pos = %ismember(%1,@MastPotionList);#ADDITEM PotionList {@pos-%1};%sort(@PotionList)}
#ALIAS DrinkNext {@Potion = %item(@PotionList,1);drink %word(@Potion,2,-);@DELNITEM @PotionList 1}

NOTE: I have not tested this code. You may want to check the syntax but the idea does work.





-Serentus-
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion 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