|
nostra Wanderer
Joined: 23 May 2001 Posts: 68 Location: Sweden
|
Posted: Mon Jun 09, 2003 9:21 pm
Comparing string lists... |
Hi,
I have two string_lists.
String_list1 consists of my current beneficiary spell-affects.
String_list2 contains all beneficiary spell-affects.
Since my character now and then is dispelled of these beneficiary spells I want to write a trigger that can check current spell-affects and store each affect in stringlist1. These values is to be compared with a "master list" (stringlist2).
If there is a value in stringlist2 that is not in a member of stringlist1 (that is, I'm missing a beneficiary spell) I want the trigger to cast that spell.
Problem:
I need a trigger that cast any spell that is a member of stringlist2 but not stringlist1.
Any ideas? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Jun 09, 2003 11:45 pm |
#FORALL @stringlist2 {#IF (%ismember( {%i}, @stringlist1)) {} {cast %i}}
LightBulb
Advanced Member |
|
|
|
nostra Wanderer
Joined: 23 May 2001 Posts: 68 Location: Sweden
|
Posted: Tue Jun 10, 2003 2:45 pm |
Typical me I thought I had it covered but this turned out to be more complicated than I first thought.
The trigger works like a charm but there is another script that is lurking in the shadows that automatically finds the correct spellbook for each spell I'm trying to cast.
Since #FORALL "spams" all %i spells in one row it sets of a loop of chainreactions that are impossible to cover.
What I need (if it's possible) is a way for the script to pause after each executions of %i values and wait for a "go" from me before executing next %i value.
For example, if #FORALL %i is:
bless
armor
shield
I want the script to execute the first one (bless)
c 'bless'
Then wait for:
You have completed your spell.
Then cast next value (armor)
cast 'armor'
etc,... until it has looped through all values in %i.
Is it possible? |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Jun 10, 2003 8:14 pm |
#FORALL, or any loop command for that matter, isn't really suited to delaying actions. Instead you'll want to use a counting variable and step through the list yourself.
#VAR ListIndex 1
#AL SpellupLoop {#IF (%ismember( %item( @stringlist2, @ListIndex), @stringlist1)) {#ADD ListIndex 1;#IF (@ListIndex <= %numitems( @stringlist2)) {SpellupLoop} {#VAR ListIndex 1}} {cast '%item( @stringlist2, @ListIndex)'}}
#TR {You have completed your spell.} {#ADD ListIndex 1;#IF (@ListIndex > %numitems( @stringlist2)) {#VAR ListIndex 1} {SpellupLoop}}
LightBulb
Advanced Member |
|
|
|
nostra Wanderer
Joined: 23 May 2001 Posts: 68 Location: Sweden
|
Posted: Thu Aug 21, 2003 2:40 am |
Well, I have now looked hard on or your suggestion but the result is a bit weird.
To keep it simple; I have as above two stringlists @stringlist1 and @stringlist2
stringlist1 contains my current spell affects, example:
armor
bless
stone skin
stringlist2 contains all possible spell affects, example:
bless
armor
stone skin
armor
shield
detect alignment
detect invisibility
Now, I want the script to compare stringlist1 with stringlist2 and all spells from list2 that are not included in list1 should be casted.
I have tried your script but it only tries to cast one spell and it confuses me...
Any ideas[?] |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Aug 21, 2003 7:54 am |
I just tested the script I suggested, using your values for the variables. It works, casting shield, detect alignment, and detect invisibility. I suspect the problem is that "You have completed your spell." isn't the real message you see after each casting.
I'm sorry my script confuses you. It would be better if you could write your own, which you would understand. Mine is quite simple actually:
The alias:
Check if current item in stringlist2 is in stringlist1.
If it is, go on to the next item in stringlist2.
If it's not, cast it.
The trigger:
When "You have completed your spell." is received
If all items in stringlist2 have been checked, then reset the index variable to 1
If not, then use the alias to check the next item in stringlist2
It's written to do exactly what you asked, using the exact information you supplied. I'd suggest you use it as the basis for writing your own, using the actual spells, messages, etc. from the MUD. |
|
|
|
|
|