|
saplingg Novice
Joined: 06 Oct 2005 Posts: 31
|
Posted: Sun Nov 20, 2005 3:24 pm
Stringlists and positions |
I'm wondering is there a command that you can enter a string, and it will search a stringlist for it, and give you the position of that string?
For example, I have the array
#VAR numbers {zero|one|two|three|four}
I want a command which can enable me to type in "three" and get the corresponding number "4" in return.
An opposite of %arrget, if you would. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Nov 20, 2005 5:18 pm |
%ismember("text item to search for", "stringlist to search"). If it's not found in the list, returns 0 otherwise returns element position.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
saplingg Novice
Joined: 06 Oct 2005 Posts: 31
|
Posted: Sun Nov 20, 2005 7:28 pm |
edit: PROBLEM SOLVED, I put in ()'s around %w =/
Thank you! I asked because I am making a money counting code.
In the MUD I play, your money is presented to you as shown
Quote: |
This is a pile of various types of coins, including three silver moons, three
copper pennies, twelve silver shillings, and one copper farthing. |
This can be quite confusing as the currency system is not as easy as I'd like ( (1 penny = 5, 1 shilling = 25, 1 moon = 125, 1 ignoble = 625) so I am trying to make something which will calculate it for me. This is what I've got so far.
Code: |
#CLASS {MoneyCount}
#TRIGGER {(%w) silver moon} {#MATH moons (%ismember( "%1", "@moneylist"))*4}
#TRIGGER {(%w) copper farthing} {#MATH farthings (%ismember( "%1", "@moneylist"))*1}
#TRIGGER {(%w) silver shilling} { #MATH shillings (%ismember("%1", "@moneylist"))*25 }
#TRIGGER {(%w) copper penn} {#MATH pennies (%ismember( "%1", "@moneylist"))*5}
#TRIGGER {(%w) gold ignoble} {#MATH ignobles (%ismember( "%1", "@moneylist"))*625}
#CLASS 0
|
In my code, I am simply trying to save all the valuew into their corresponding variables. Later on, I will have a trigger that switches the counter on when you look at money, adds up all the variables (moons, farthings, shillings, etc) together, and displays them and then turns the counter off.
However, while I am able to save the %w variable, the %ismember command is not working for me. Can anyone pinpoint the mistake? |
|
|
|
|
|
|
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
|
|