|
KMecha Newbie
Joined: 15 Jan 2002 Posts: 4 Location: USA
|
Posted: Tue Jan 15, 2002 2:29 am
Text Capturing problem |
Hello all,
I need a little help with some text capturing…
What I am trying to do is make a string of the spells that I am affected by. Take that string and compare it to a list of spells the character has and cast the missing spells. I am having trouble figuring out how to do the capture since the spell affects can be anywhere from one to three lines in length. Below are two samples of how the spells show up in my “score” command. The numbers on the bottom of each sample represent my prompt.
~<snip~>
You are not hungry.
You are slightly parched.
You are affected by:
Armor, Faerie Fog, Fly, No Summon, Waterwalk
491/491H 626/626M 449/449Mv 13020070X>
~<snip~>
You could use a small snack.
You are slightly parched.
You have a very faint aura of light surrounding you.
You are affected by:
Armor, Avatar Sight, Bless, Detect Alignment, Detect Magic, Detect Poison
Faerie Fog, Fly, Heroism, No Summon, Protection from Cold, Protection from Evil
Sanctuary, Vitality, Waterwalk
591/591H 607/626M 449/449Mv 13020070X>
Thanks
KMecha
"I say nuke the sight from Orbit. Its the only way to be sure!" |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Tue Jan 15, 2002 4:33 am |
#ALIAS sc {#T+ SpellCap;score}
#CLASS SpellCap {disable}
#VAR ActiveSpells {}
#TRIGGER {^You are affected by~:} {T+ CapturingSpells;ActiveSpells=""}
#TRIGGER "CapturingSpells" {^*$} {#IF (%pos("/",%trigger)) {#T- CapturingSpells;ParseSpells} {ActiveSpells=%concat(@ActiveSpells,"|",%trigger)}}
#ALIAS ParseSpells {#IF (@ActiveSpells!="") {ActiveSpells=%sort(%delitem("",%dups(%replace(@ActiveSpells,", ","|"))));#NOOP Add other commands here!;#T- SpellCap}}
#CLASS 0
That gives you a list you can use with #FORALL and %ismember |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Tue Jan 15, 2002 7:38 pm |
You can use the intro line "You are affected by" to enable a class and use your prompt to disable it. Within the class, you can have triggers for each affect you are interested in. Here's my suggestion, I've started with a stringlist of all desired spells and used triggers to remove the existing ones, then cast whichever spells are still in the list:
#TR {^You are affected by} {#VAR spellup {Armor|Avatar Sight|Bless|Detect Alignment| Detect Magic|Detect Poison
Faerie Fog|Fly|Heroism|No Summon|Protection from Cold|Protection from Evil
Sanctuary|Vitality|Waterwalk};#T+ spellup}
#CLASS spellup
#TR {Armor} {#DELITEM spellup Armor}
#TR {Avatar Sight} {#DELITEM spellup {Avatar Sight}}
#TR {Bless} {#DELITEM spellup Bless}
.
.
.
#TR {Waterwalk} {#DELITEM spellup Waterwalk}
#TR {^%n/%dH %n/%dM %n/%dMv %dX} {#T- spellup;#IF (@spellup) {#FORALL @spellup {cast '%i'}}} {} {nocr|prompt}
#CLASS 0
LightBulb
All scripts untested unless otherwise noted |
|
|
|
KMecha Newbie
Joined: 15 Jan 2002 Posts: 4 Location: USA
|
Posted: Sun Jan 20, 2002 1:46 am |
Hello again and thanks for all your help so far. I have made a string called “spellcast” that has all the spells that the character can cast. The string “activespells” is just a mirror of “spellcast” before triggers remove the active spells. I am having a problem that when “activespells” is empty I still try to cast something. I believe the problem is the #if function but cant seem to get the syntax right for some reason. The if statement is exactly how it looks in my zmud “value” box.
Class: ac1
#trigger You are affected by~:
#var activespells {@spellcast}
#t- ac1
#t+ spellup
Class: spellup
#Trigger (%d)/(%d)H (%d)/(%d)M
#if @activespells
#forall {@activespells} {pray '%i'}
#t- spellup
#t- ac1
The result when there are no spells to cast:
pray ''
Pray what?!?
Also on a completely unrelated topic. How would I go about sending a carriage return to the mud when a certain trigger is met.
example:
#trigger PRESS RETURN~:
<%char(13)>
I try this and nothing happens until I hit “enter” and then it seems like I do a double “enter”.
Thanks Kmecha
"I say nuke the sight from Orbit. Its the only way to be sure" |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Jan 20, 2002 2:09 am |
Find the changes:
Class: spellup
#Trigger (%d)/(%d)H (%d)/(%d)M
#if @activespells {
#forall @activespells {pray '%i'}
#t- spellup
#t- ac1
}
The solution to the other question.
#trigger {PRESS RETURN~:} {%null} "" {"nocr"|"prompt"} |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Sun Jan 20, 2002 4:54 pm |
The #FORALL needs to be part of the #IF. According to your script, it's a separate command.
LightBulb
All scripts untested unless otherwise noted |
|
|
|
KMecha Newbie
Joined: 15 Jan 2002 Posts: 4 Location: USA
|
Posted: Sun Jan 20, 2002 6:58 pm |
Thanks for the posts Vijilante and LightBulb,
I implemented your corrections and now the triggers work as advertised. I was looking over your #if command Vijilante and had to copy and paste it into zmud to get it to work for me. I have read the help files concerning the #if command and still cant seem to get the syntax right. I was wondering if anyone could give this newbie an in depth example on how to put multiple commands into the true/false sections of the #if command.
Thanks again
Kmecha
"I say nuke the site from Orbit. Its the only way to be sure" |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Jan 20, 2002 9:00 pm |
Basic format:
#IF (condition) {true commands} {false commands}
In this case condition is a simple x=y, x<y, x>y, x!=y
More complex format:
Is really more of the same but adds the OR(|) and AND(&) operators
#IF (condition1|condition2) {true commands} {false commands}
#IF (condition1&condition2) {true commands} {false commands}
Personally I like to seperate each condition in ()'s even though it is not really necessary so:
#IF (((condition1)|(condition2)&(condition3))|!(condition4)) {true} {false}
Note how the ()'s are used to group 1-3, and the addition of the NOT(!) operator.
You can get all this and more by looking in the help for "Expressions"
As for multiple commands you have choices of how to do it:
#IF (conditions) {command1;command2;command3;...} {...}
or
#IF (conditions) {
command1
command2
command3
...
} {
...
} |
|
|
|
|
|