|
Laveciar Newbie
Joined: 07 Apr 2005 Posts: 4
|
Posted: Tue Aug 23, 2005 8:28 pm
String/Variables/Lists Help. |
Ok I have read everything I can possibly can, to try to figure this out, I guess I am just not that compentant sometimes, so I am searching for someone that can lend me a hand. Here is my dilemma
#VAR checkitem {ax|sword|whip|knife}
#VAR itemvalue {10|20|30|40}
#VAR itemcount {10|10|10|10}
#TRIG {%e[1;33m%1 gives you %2 coins} {#VAR buyer %1;#VAR given %2;checkstatus}
#ALIAS checkstatus ?
Now here is where I have absolutely confused myself to no end.
I want it to take the value of %2, look for it in @itemvalue, then find the corresponding word in @checkitem, then I want it to fire giving that item to the %1. But if the %2 doesn't match anything on @itemvalue, then it gives %2 back the %1. And if it matches the item and gives it to them I want it to subract 1 from the corresponding itemcount. And if the itemcount = 0 then it returns the money and says sorry none left. This is basically I guess you could call it a sellbot but its just something I have been working on forever, and just can never seem to get it right, I wanted to learn all I could about it before I even attempt at messing with them. Would appreciate any comments suggestions or help that anyone could render a pathetic old fool like myself. Thanks.
Laveciar the old bum. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Tue Aug 23, 2005 11:42 pm |
First step is to fix your trigger.
#TRIG {^%e[1;33m(%w) gives you (%d) coins} {#VAR buyer {%1};#VAR given {%2};checkstatus} "" {color}
Next the alias I will include listing items and prices. What I am not sure of is the proper give command on your mud.
#ALIAS checkstatus {TempShop=%ismemeber(@given,@itemvalue);#IF (@TempShop) {#IF (%item(@itemcount,@TempShop) {give %item(@checkitem,@TempShop) to @buyer;itemcount=%replaceitem(@itemcount,@Tempshop,%eval(%item(@itemcount,@TempShop)-1))} {checkstatuserr}} {checkstatuserr}}
#ALIAS checkstatuserr {give @given coins to @buyer;say There was a problem in your purchase. I currently sell %expandlist(@checkitem,", ") at %expandlist(@itemvalue,", ") and have %expandlist(@itemcount,", ") in stock.} |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Laveciar Newbie
Joined: 07 Apr 2005 Posts: 4
|
Posted: Wed Aug 24, 2005 2:12 am |
#ALIAS checkstatus {TempShop=%ismemeber(@given,@itemvalue);#IF (@TempShop) {#IF (%item(@itemcount,@TempShop) {give %item(@checkitem,@TempShop) to @buyer;itemcount=%replaceitem(@itemcount,@Tempshop,%eval(%item(@itemcount,@TempShop)-1))} {checkstatuserr}} {checkstatuserr}}
Thanks for the quick repsone Viji, appreciate it but I get a syntax error in the alias at the second #IF on the {give. the syntax error
says theres something wrong with the bracket, i have tried redoing it to no avail, any suggestions?
BTW its just simply give object person, no need for the to. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Wed Aug 24, 2005 8:12 am |
Missing a closing parenthesis.
#ALIAS checkstatus {TempShop=%ismemeber(@given,@itemvalue);#IF (@TempShop) {#IF (%item(@itemcount,@TempShop)) {give %item(@checkitem,@TempShop) to @buyer;itemcount=%replaceitem(@itemcount,@Tempshop,%eval(%item(@itemcount,@TempShop)-1))} {checkstatuserr}} {checkstatuserr}} |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Ikyu Beginner
Joined: 27 Feb 2005 Posts: 24
|
Posted: Wed Aug 24, 2005 6:14 pm |
maybe also change %ismemeber to %ismember :)
|
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Wed Aug 24, 2005 6:37 pm |
Food for thought
For something like this trying to keep track of item, quanity, price I would prolly use a Data record, or even the Database itself. Both offer more flexibilty and less chance of an error then managing 3 stringlists.
If your using a data record Prolly something like
Var Item
Key=Itemname
Value="cost|quanity" This being a 2 item stringlist
Remember this is just something to think about! |
|
|
|
|
|
|
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
|
|