|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Mon Dec 29, 2003 3:48 pm
Lil sintaxis problem |
Hi,i got a stringlist called objetive,the variable is @objetive.
I want to atack every element on that list,but some words like blood,an,a,or so.
I do:
#loop 1,%numitems(@objetive) {#if (%item(@objetive,%i)="a"|"blood"|"an") {kill %item(@objetive,%i)}}
That will ask to kill "a",and "an" too... Why?
How to get it to do what i want?
Other way could be using "=~ " instead of "=" but in that case,any word containing "a" or "an" will be omitted too.
Thanks for any help. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Mon Dec 29, 2003 3:55 pm |
Well you could just remove the items you dont want to attack from the list. Or if the stuff is needed on the list make a seperate stringlist for the things you do want to kill.
|
|
|
|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Mon Dec 29, 2003 4:07 pm |
The stringlist Objetive is generated everytime I enter a new room,so i cant do that
|
|
|
|
Toetag Magician
Joined: 10 Oct 2000 Posts: 356 Location: USA
|
Posted: Mon Dec 29, 2003 5:50 pm |
This is the simplest way, you could add to it by using a String List to hold things to remove (for exapmle "a|the|an|"
But here's the general idea:
objective = a|blood|monster|the|an
Trigger Value:
loopcount = %numitems( @objective)
#LOOP @loopcount {#IF (%item( @objective, %i)= "a") {
#DELNITEM objective %i
#SHOW %i
}}
#FORALL @objective {#SHOW you kiled: %i}
results in a @object stringlist of: blood|monster|the|an
resulting in an output of:
you kiled: blood
you kiled: monster
you kiled: the
you kiled: an
You'd only have to change the #IF statement to loop through the "exluded" members list. I'm at work and doing this offline. If you need more help let me know and I'll see what i can come up with. |
|
|
|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Mon Dec 29, 2003 6:06 pm |
Thankyou,but i couldnt find out the solution to my problem from that text; Ill ask it other way:
How to do next if does the #echo yes?
#if ("Un"={"Un"|"el"|"la"|"de"}) {#echo yes}
If i substitude = with =~ ,that will work,but will also work everytime any word containing "Un" or "el",etc,is on the list. |
|
|
|
Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Mon Dec 29, 2003 6:07 pm |
You only have a minor syntax error in your IF statement. You have: kill %item(@objetive,%i) in the true field of the if statement.
Just change the IF statement to:
#if (%item(@objetive,%i)="a" OR "blood" OR "an") {} {kill %item(@objetive,%i)}
And it should work. |
|
|
|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Mon Dec 29, 2003 6:32 pm |
It works,thanks u all =)
|
|
|
|
Articnal Apprentice
Joined: 19 Jan 2002 Posts: 107
|
Posted: Mon Dec 29, 2003 8:14 pm |
#if ("Uonjk"="Un" OR "el") {#echo yes}
--> that echos yes
#if ("Un"="Un" OR "el") {#echo yes}
--> that too
What now?? =( |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Dec 29, 2003 9:41 pm |
The best thing to do is make an exclusion list. For example:
#VAR ExcludedObjetives {a|an|the|blood}
Then in your alias to do the attacks:
#IF (%ismember(%item(@Objetive,%i),@ExcludedObjetives)) {#NOOP} {kill %item(@objetive,%i)} |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Dec 29, 2003 11:44 pm |
Something everyone seems to have missed is that no matter whether you use | or OR, each comparison must be done separately. This won't affect Vijilante's solution since he's checking for membership in a list instead of comparing strings.
Original:
#if ("Uonjk"="Un" OR "el") {#echo yes}
Grouped to show actual order of operations:
#if (("Uonjk"="Un") OR ("el")) {#echo yes}
You are checking to see if "Uonjk" matches "Un" (no) or if "el" is a non-null string (yes). Since "el" is always a non-null string, you always have a yes for that side of the OR, so you always #echo yes.
Revised:
#IF ("Uonjk"="Un" OR "Uonjk"="el") {#echo yes} {#ECHO no}
This will now echo no, since "Uonjk" doesn't match either "Un" or "el". |
|
|
|
|
|