 |
Mezekht Newbie
Joined: 26 Mar 2005 Posts: 3
|
Posted: Sat Mar 26, 2005 8:32 pm
List fun! |
I am having some trouble with a trigger I am working on. I have done it successfully using what I will refer to as a "hack" method, but I want to clean it up. The mud I play has a number of different potions, you carry them around in containers, and have a stockpile you fill from in your HQ.
I want to make a trigger that determines what potions I have, and when I "restock" it makes sure I have the predetermined number of potions in my container. Taking out potions if there are too many, and acquiring more if necessary. Here is some of what I am working with.
| Code: |
an ethereal web potion (2)
a sanctuary potion (2)
a demonskin potion
|
I am currently using the following pattern to assign them to a list:
{a|an} (*) potion ~((%d)~)
With this value:
#ADDITEM ContainerItem {%1}
#VAR ContainerQuantity {%additem( %2, @ContainerQuantity)}
I can narrow the potions with two words down to one word, but I am at a loss as to how to compare the lists with my predetermined list of potions and the predetermined list of quanties I want of each. Oh, and to also make sure they stay in order. Any help would be much appreciated. |
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Mon Mar 28, 2005 1:37 am |
Why does everyone always want to supply less then a third of the information required to write a complete script? Anyhow, fundamentally lists are not the best suited type of variable to use. You should use records. I am going to tweak the pattern a little as well. It captures both forms of line. I am not sure if you have preceeding spaces or not since you did not include any surrounding text.
#TRIGGER {^{a|an} (*) potion(*)$} {#ADDKEY ContainerItem {%1} {%if("%2"="",1,%eval(%2))}}
Next you wanted to sort the list. Why you need to do this I do not know. This is best done with this code snippet:
#ADDKEY ContainerSorted {%sort(%expanddb(@ContainerItem,"|","="))}
Where you put that I have no idea, since you didn't supply anything that could be used to trigger based on end of bag.
Now to compare the variables. Again put it in some other trigger you didn't blah blah blah.
#LOOPDB @ContainerItem {#IF (%val<%db(@SomeVariableYouNeverSuppliedANameFor,%key)) {SomeCommandToObtainPotions maybe I should put code to calculate a quantity here %key;put %key in? SomeBagYouNeverSuppliedBlahBlah} {#IF (%val<%db(@SomeVariableYouNeverSuppliedANameFor,%key)) {get maybe I should put code to calculate a quantity here %key from? BlahBlahBlah;SomeMoreBlah %key}}
Of course the many other useful questions are... Do you want the record to track actual stock? Do you just want to update it when you are at the point of restocking? I know I like to keep track of my actual inventory at all times. My autoeat system needs to know when it is out of food, I need a visual warning when I am low. I tend to forget what bag I put things in so it is very nice to be able to just pop up a list of everything I have that tells me where it all is. Just other things to consider.
Oh and the best part is I could have basically written this in 5 minutes if I wasn't trying to be witty and doing all the blah. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
Mezekht Newbie
Joined: 26 Mar 2005 Posts: 3
|
Posted: Mon Mar 28, 2005 4:10 am |
Sorry about my previous posts, I was going to add some clarification, but friends showed up! At any rate, this is a completely different way of going about it than I had intended, and I am sure you are surprised to hear, that it is a better method. (I can be sarcastic too!). To fill in some of the information you requested...
To begin examining the contents of my container: "You take a closer look at Skin of the Innocent in inventory..."
It would end on the first blank line received. The "keywords" for the container would be Skin-Pouch, so far as actually manipulating objects to and from the container. I keep all the potions in a room in HQ, inside a container with the keyword "bier". Basically, I want to go to that room, and type an alias, "restock" or something simple, and have a trigger "exam skin-pouch", determine the quantity of potions stored therein, and then "#(Quantity) get 'xpotion' bier;#(Quantity) put 'xpotion' skin-pouch" as necessary. The mud requires the ' ' around the potion name if it is more than 1 word. I would also like a method of setting the parameters for the number of potions that I would like to keep on me at any given time. As of now, once the item is in my container, I can keep track of it okay. The main point of the trigger would be for restocking items. For instance, I would want to make sure I always had 3 shadowform potions at all times, and 15 true sight potions when I went to restock. The only reason for the sort was because I had planned on storing values with lists, so, as you stated previously, seems pretty useless now! You seem to have the idea though. Basically, check container, count potions, check db and figure out how many potions I need to grab from the bier, and grab them. I hope I was able to include everything, and I really appreciate the insight and help. |
|
Last edited by Mezekht on Mon Mar 28, 2005 5:36 am; edited 1 time in total |
|
|
 |
Mezekht Newbie
Joined: 26 Mar 2005 Posts: 3
|
Posted: Mon Mar 28, 2005 5:31 am |
In retrospect, after playing with the examples above, it would be pretty awesome to have a way to track inventory. "You quaff an eldritch sphere potion." Would be an example of a potion leaving one's inventory. I can certainly see why a DB is a better way to handle this entire process, thanks again for your help.
|
|
|
|
 |
|
|
|
|
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
|
|