|
Yamabushi Apprentice
Joined: 29 Jul 2003 Posts: 101 Location: USA
|
Posted: Tue May 18, 2004 9:18 am
tracking multiple targets |
Ok I have 5 targets tar1-tar5 and a variable called 'robber' to steal from a selected victim.
The default for any target is 'empty'.
Here's what I'm wanting to do. I'd like to use 'settar' to put a name into the list of targets, but it will have to look for the first empty target starting at 1 to put the target in.
And if the list of targets is full will return to clear the first target, 'tar1'.
Then I'm planning on using a couple of binded keys to move targets into the 'robber' variable.
So the things I can't figure out, is how to look for an empty target and place the name into that location. Also how to cycle up and down my target list using binded keys.
Thanks for any help on this project. |
|
|
|
Serentus Apprentice
Joined: 28 Sep 2001 Posts: 103 Location: USA
|
Posted: Tue May 18, 2004 12:15 pm |
If you dead set on having five variables I would suggest a variable list of targets and an index variable something like this.
#VAR Targets {} {}
#VAR TargetIndex {1} {1}
#FUNC tar {%item(@Targets,@TargetIndex)}
#ALIAS settar {#IF (%numitems(@Targets)<=5) {#ADDITEM Targets "%1"} {%replaceitem("1",1,@Targets)}}
#ALIAS NextTarget {#IF (@TargetIndex>=5) {#VAR TargetIndex {1}} {#ADD TargetIndex 1}
#ALIAS PrevTarget {#IF (@TargetIndex<=1) {#VAR TargetIndex {5}} {#ADD TargetIndex -1}
To use this you type
settar goblin
settar guard
etc.
the function @tar will return the target that @TargetIndex is pointing to.
to change which target it points to just change the value of @TargetIndex.
PrevTarget and NextTarget cycle through the list. YOu can assign the targets to @Robber with @Robber=@tar, or just use tar without having @Robber. |
|
|
|
Yamabushi Apprentice
Joined: 29 Jul 2003 Posts: 101 Location: USA
|
Posted: Wed May 19, 2004 3:39 am |
Ok can't get that to work at all :(
|
|
|
|
Serentus Apprentice
Joined: 28 Sep 2001 Posts: 103 Location: USA
|
Posted: Wed May 19, 2004 5:49 am |
Ok, let me fix my errors ... and there wer several
Change
#ALIAS settar {#IF (%numitems(@Targets)<=5) {#ADDITEM Targets "%1"} {%replaceitem("1",1,@Targets)}}
To
#ALIAS settar {#IF (%numitems(@Targets)<5) {#ADDITEM Targets "%1"} {#VAR Targets {%replaceitem("%1",1,@Targets)}}}
Change
#ALIAS NextTarget {#IF (@TargetIndex>=5) {#VAR TargetIndex {1}} {#ADD TargetIndex 1}
#ALIAS PrevTarget {#IF (@TargetIndex<=1) {#VAR TargetIndex {5}} {#ADD TargetIndex -1}
To
#ALIAS NextTarget {#IF (@TargetIndex>=5) {#VAR TargetIndex {1}} {#ADD TargetIndex 1}}
#ALIAS PrevTarget {#IF (@TargetIndex<=1) {#VAR TargetIndex {5}} {#ADD TargetIndex -1}}
Sorry about that. |
|
|
|
Yamabushi Apprentice
Joined: 29 Jul 2003 Posts: 101 Location: USA
|
Posted: Wed May 19, 2004 7:27 pm |
Ok i have an error that I can't go up and down on the PrevTarg and NextTarg.
|
|
|
|
Serentus Apprentice
Joined: 28 Sep 2001 Posts: 103 Location: USA
|
Posted: Fri May 21, 2004 6:58 am |
I'm not sure what you mean by can't go up and down using Prev and Next, is there an error in the setting editor? or dose it not move TargetIndex? does it give funny looking outputs?
to test fill the @Targets list using 'settar' alias then execute this a few times
NextTarget;#ECHO @Targets (@TargetsIndex - @Tar)
and then do this one a few times
PrevTarget;#ECHO @Targets (@TargetIndex - @Tar)
Let me know what these show. |
|
|
|
|
|