|
Tolkienfan Wanderer
Joined: 07 Apr 2001 Posts: 51 Location: Denmark
|
Posted: Thu Feb 14, 2002 3:54 pm
Variables in Variables |
Im trying to make a "targets" variable containing the names of all my targets. Here is what i did:
I simply made a variable:
#var {targets} {@target1|@target2|@secondarytarget1|secondarytarget2}
buttt that doesent seem to work..is there another way to do it?
Tolkienfan |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Thu Feb 14, 2002 8:59 pm |
So how exactly does it not work? What does it do? What doesn't it do? What do you expect it to? What value do you think the variable should contain? What value does the variable contain which is not what you expect?
Kjata |
|
|
|
Tolkienfan Wanderer
Joined: 07 Apr 2001 Posts: 51 Location: Denmark
|
Posted: Thu Feb 14, 2002 9:21 pm |
Ok ill explain more clearly...
When pking, i use macros for casting different attack spells on different "target" and for this purpose i have made some variables called: target1, target2 and i have made secondarytarget1 and secondarytarget2 for a swapping mechanism which is not relevant here....
When in fight it is a known trick for your enemies/targets to try and use the command follow and thereby follow you when u try to get away from combat...
To prevent this i want to make trigger:
#tr {(%w) starts following you.} {#if (%1=@targets) {lose %1}
What i dont know how to do is make the @targets variable...
I tried making a variable containing following things: @target1|@target2|@secondarytarget1|@secondarytarget2
But this doesent seem to work...
Tolkienfan |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Thu Feb 14, 2002 9:29 pm |
Making the variable, does in fact work. It should make the variable with four items corresponding to the values of @target1, @target, @secondarytarget1, and @secondarytarget2. However, do not expect @targets to be automatically updated when any of this variables change because @targets will contain the value of the variables, not the variables themselves.
What will definetly not work is the trigger. You can't compare something matched with %w to a list because a list contains more than one value separated by | and the test will never be true. You have to options of going about this:
#TRIGGER {({@targets}) starts following you.} {lose %1}
#TRIGGER {(%w) starts following you.} {#IF (%ismember(%1, @targets)) {lose %1}}
The first one will only fire whenever one of the people in @targets starts following you, the second one will fire everytime someone starts following you, and thus it is my opinion that the first method is better. Since the list is surrounded by parentheses in the pattern, whatever value of the list that made the trigger fire is going to get stored in %1.
Kjata |
|
|
|
TonDiening GURU
Joined: 26 Jul 2001 Posts: 1958 Location: Canada
|
Posted: Thu Feb 14, 2002 9:30 pm |
Two ways of doing this:
The ismember function:
#TR {(%w) starts following you.} {#IF (%ismember(%1,@targets)) {lose %1}}
quote:
Syntax: %ismember(s,list)
return 0 (false), if s is not a member of the given string list. Otherwise return the item number (position of s in the list)
Using the string list in the trigger with capture
#TR {({@targets}) starts following you.} {lose %1}
quote:
Pattern Matching:
..
(pattern) save the matched pattern in a parameter %1 though %99
..
{val1|val2|val3|...} match any of the specified strings
TonDiening
Beta Upgrading to 6.26
Heh 45s after Kjata's post
And I need a coffee :) Typoing everywhere.
More like I need a double expresso at this rate. |
|
|
|
|
|