how do I check multiple lines

Posted by Warbit on Wed 17 Aug 2011 10:08 PM — 20 posts, 81,939 views.

USA #0
I want to display my score (character sheet)
I want to check to see if the Armor spell is on.
if not I want to automatically cast the Armor spell

here is how my character sheet looks

_____________________________________________
Warbit * (level: 20)
Your levels: Wa: 20 Th: 20 Mo: 17 Ba: 10 Dr: 9 Ne: 9 Cl: 8 Ma: 7
You are 23 years, 15 months, 14 days old.
You are a citizen of Valkyre.
You are a devout worshipper of Nia.
Your throat is starting to get dry.
You have a heart of blackest evil.
You are quite familiar with most of this area.
You have 514(514) hit, 27(89) mana and 255(255) movement points.
Your armor class is -5.4.
You have 33043 gold coins.
You have thirty drachma.
You have 5881020 unused experience points.
You have been playing for 22 days, 19 hours, 56 minutes.
Str: 18[18], Int: 9[9], Wis: 13[13], Dex: 18[18], Con: 16[16]
You are standing.
You are singing 'lion chorus'.
You are affected by the following spells:
Resist Cold
Armor
Bless
Water Breathing
Lion Chorus
____________________________________________________________

that's with the armor spell on. Though with Aegis or other spells Armor can be anywhere in the list.


I would like to see if I am affected by the Armor spell.
(see if it is on the list)

and if its not on the list I would like for my guy to automatically cast the armor spell.

_______________________________________________


How do i do that?

What would go in the trigger box?

What would go in the send box?

I am guessing because it with most likely be a script in send box.

that i will be using

the send to script selection, from drop down box.




thanks again !!!


Australia Forum Administrator #1
Template:faq=37
Please read the MUSHclient FAQ - point 37.
USA #2
reading it now , but it seems like that might be what I am looking for thanks Nick!



<triggers>

<!-- trigger to match start of inventory -->

  <trigger
   enabled="y"
   match="You are carrying:"
   send_to="12"
   sequence="100"
  >
  <send>
inventory_table = {}
EnableTrigger ("inventory_line", true)
EnableTrigger ("inventory_stopper", true)
</send>
  </trigger>






<!-- trigger to match an inventory line -->

  <trigger
   match="*"
   name="inventory_line"
   send_to="12"
   sequence="50"
  >
  <send>
  table.insert (inventory_table, "%0")  -- add inventory item to our table
  </send>
  </trigger>








<!-- trigger to match end of inventory -->
  
  <trigger
   match="(^&lt;)|^$"
   name="inventory_stopper"
   regexp="y"
   send_to="12"
   sequence="40"
  >
  <send>
-- don't need to track inventories any more
EnableTrigger ("inventory_line", false)
EnableTrigger ("inventory_stopper", false)

-- in case no table yet
inventory_table = inventory_table or {}

table.sort (inventory_table)

print ("In your inventory is:")

for _, item in ipairs (inventory_table) do
  print (item)
end -- for

  </send>
  </trigger>
    
</triggers>





ok What does this mean?

   send_to="12"
   sequence="100"


I am guessing sequence it the order of trigger firing
(but the order is reverse (highest number first.)


have no idea what send_to 12 is.
I see the send to box
and have learned here that
Send("cast 'armor'") will send my command to the mud world.






I will chance this

<triggers>

<!-- trigger to match start of inventory -->

  <trigger
   enabled="y"
   match="You are carrying:"
   send_to="12"
   sequence="100"
  >
  <send>
inventory_table = {}
EnableTrigger ("inventory_line", true)
EnableTrigger ("inventory_stopper", true)
</send>
  </trigger>


to this?

trigger box
You are affected by the following spells:


<triggers>

<!-- trigger to match start of inventory -->

  <trigger
   enabled="y"
   match="You are affected by the following spells:"
   send_to="12"
   sequence="100"
  >
  <send>
inventory_table = {}
EnableTrigger ("inventory_line", true)
EnableTrigger ("inventory_stopper", true)
</send>
  </trigger>


where inventory_line is do I put the word

Armor

for the name of the spell I want to check is there?


for inventory_stopper can i use my prompt?

<514/514hp 67/89ma 255/255mv>

but change it to
<*/*hp*/*ma*/*mv>



I am in the Edit Trigger Section
of the mushclient.

Where do I put send_to="12"



  <trigger
   enabled="y"
   match="You are affected by the following spells:"
   send_to="12"
   sequence="100"
  >
  <send>
inventory_table = {}
EnableTrigger ("inventory_line", true)
EnableTrigger ("inventory_stopper", true)
</send>
  </trigger>



all the above goes in the send section right?

in trigger box also goes
You are affected by the following spells:



If I am right I think I might have it.


Nope it only got me disconnected from mud.

my guess you can't use the prompt to stop trigger.


Here is what I put just in case someone has answer before i find it out.

Think I am going to have to use the wait command, I thought I read.


Trigger 1
You are affected by the following spells:


in send box


<trigger
   enabled="y"
   match="You are affected by the following spells:"
   send_to="12"
   sequence="100"
  >
  <send>
inventory_table = {}
EnableTrigger ("Armor", true)
EnableTrigger ("<*/*hp*/*ma*/*mv>", true)
</send>
  </trigger>




send to box
Script

Sequence box
100


____________________________________________

trigger 2

Trigger box
Armor


send box


<trigger
   match="*"
   name="Armor"
   send_to="12"
   sequence="50"
  >
  <send>
  table.insert (inventory_table, "%0")  -- add inventory item to our table
  </send>
  </trigger>



Send to box
script

Sequence box
50

__________________________________________________

trigger 3

trigger box
<*/*hp*/*ma*/*mv>


Send box

<trigger
   match="(^&lt;)|^$"
   name="<*/*hp*/*ma*/*mv>"
   regexp="y"
   send_to="12"
   sequence="40"
  >
  <send>
-- don't need to track inventories any more
EnableTrigger ("Armor", false)
EnableTrigger ("<*/*hp*/*ma*/*mv>", false)

-- in case no table yet
inventory_table = inventory_table or {}

table.sort (inventory_table)

print ("In your inventory is:")

for _, item in ipairs (inventory_table) do
  print (item)
end -- for

  </send>
  </trigger>
    
</triggers>



Send to box
Script

Sequence box
40
Amended on Thu 18 Aug 2011 12:00 AM by Warbit
USA #3
Those wait instructions seem to involve a lot of stuff i do not understand.

So I will check back here today and read the replies.

Thanks again.

My bandwidth is capped the rest of this month so I would have to wait till the 23 to view the youtube video.
USA #4
My issue still not resolved.
Thanks in advance to any willing to help.
USA #5
Changed code to this but it still isn't working.


Trigger

You are affected by the following spells:* /n * /n * /n * /n * /n * /n * /n * /n * /n * /n



Send

Armor = False

if %1 ="Armor" then
 Armor = True
else
 if %2 ="Armor" then
 Armor = True
else
 if %3 ="Armor" then
 Armor = True
else
 if %4 ="Armor" then
 Armor = True
else
 if %5 ="Armor" then
 Armor = True
else
 if %6 ="Armor" then
 Armor = True
else
 if %7 ="Armor" then
 Armor = True
else
 if %8 ="Armor" then
 Armor = True
else
 if %9 ="Armor" then
 Armor = True
else
 if %10 ="Armor" then
 Armor = True
end--if

if Armor = False then
Send("cast 'Armor' ")
end--if


{/code]





USA #6
\n, not /n.
USA #7
Thanks twisol.
Amended on Thu 18 Aug 2011 04:06 PM by Warbit
USA Global Moderator #8
Please don't double, triple, and quadruple space the lines n your posts. It's REALLY difficult to read what you write when the line spacing isn't logically coherent.

Warbit said:
ok What does this mean?
send_to="12"
sequence="100"
I am guessing sequence it the order of trigger firing
(but the order is reverse (highest number first.)


The meanings of the "send-to" field are:

0: World
1: Command window
2: Output window
3: Status line
4: Notepad (new)
5: Notepad (append)
6: Log File
7: Notepad (replace)
8: Command queue
9: Send To Variable
10: Execute (re-parse as command)
11: Speedwalk (send text is speedwalk, queue it)
12: Script (send to script engine)
13: Immediate (send to world in front of speedwalk queue)
14: Script - after omit

And sequence is lower number first. 100 just gives you room to insert smaller numbers below it later.


Warbit said:
where inventory_line is do I put the word
Armor
for the name of the spell I want to check is there?

Down in inventory_stopper, instead of
print(item)
you want to check if the item == "Armor" and then do something depending on the answer


Warbit said:
for inventory_stopper can i use my prompt?
<514/514hp 67/89ma 255/255mv>
but change it to
<*/*hp*/*ma*/*mv>

You can use whatever you want, as long as it makes sense.


Quote:
all the above goes in the send section right?

FAQ entry 37 already tells you how to copy/paste the code into MUSHclient.
Amended on Thu 18 Aug 2011 05:19 PM by Fiendish
USA #9
thanks again appreciate it.
I will work on it, and get back to you with how it went.
Australia Forum Administrator #10
Warbit said:

Changed code to this but it still isn't working.

Send

Armor = False

if %1 ="Armor" then
 Armor = True
else
 if %2 ="Armor" then
 Armor = True
else
 
...





Template:faq=32
Please read the MUSHclient FAQ - point 32.


Also it is == for comparisons not = (but still read the FAQ item).
Amended on Thu 18 Aug 2011 09:05 PM by Nick Gammon
USA #11
Thanks Nick looking at it now.
USA #12
Screen shows

Warbit ...  (level: 20)
Your levels:  Wa: 20 Th: 20 Mo: 20 Ba: 17 Dr: 11 Ne: 12 Cl: 8 Ma: 7 
You are 28 years, 10 months, 17 days old.
You are a citizen of Valkyre.
You are a devout worshipper of Vom.
You are an example to us all.
You are quite familiar with most of this area.
You have 532(532) hit, 100(100) mana and 302(302) movement points.
Your armor class is -4.0.
You have 153971 gold coins.
You have seventy drachma.
You have eighty-six honor.
You have 11415869 unused experience points.
You have been playing for 38 days, 9 hours, 37 minutes.
Str: 18[18], Int: 9[9], Wis: 13[13], Dex: 18[18], Con: 16[16]
You are standing.
Your song can affect as many as two people.
You are affected by the following spells:
   Resist Fire                      
   Resist Cold                      
   Water Breathing                  
You are imbued with the following spells:
   call lightning (3 charges)
   magic missile (5 charges)
   demon bind (4 charges)

The You are imbued with the following spells: part is not guaranteed to be there it goes away.
My Trigger is

<triggers>
  <trigger
   enabled="y"
   match="*You are affected by the following spells:*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"
   send_to="12"
   sequence="100"
  >
  <send>if %1 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %2 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %3 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %4 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %5 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %6 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %7 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %8 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %9 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %10 == "Resist Fire" then
Send("Say Resist Fire")
end--if
if %11 == "Resist Fire" then
Send("Say Resist Fire")
end--if</send>
  </trigger>
</triggers>


Already looked at help you gave other guy with his multi-line trigger.
Looked at http://mushclient.com/forum/?id=7794#37
Don't see why it is not seeing Resist Fire.
Amended on Wed 21 Sep 2011 12:40 PM by Warbit
Australia Forum Administrator #13
Because this:


if %2 == "Resist Fire" then
  Send("Say Resist Fire")
end--if


Expands out to:


if Resist Fire == "Resist Fire" then
  Send("Say Resist Fire")
end--if


That doesn't make syntactic sense.

It needs to be:


if "%2" == "Resist Fire" then
  Send("Say Resist Fire")
end--if

USA #14
Thanks Nick, made the changes. Turned echo on , but still can't see me saying Resist fire. Here is the current trigger


<triggers>
  <trigger
   enabled="y"
   group="Spellz"
   match="*You are affected by the following spells:*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n"
   send_to="12"
   sequence="100"
  >
  <send>if "%1" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%2" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%3" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%4" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%5" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%6" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%7" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%8" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%9" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%10" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%11" == "Resist Fire" then
Send("Say Resist Fire")
end--if</send>
  </trigger>
</triggers>

There are no error messages it just does nothing visible.
Australia Forum Administrator #15
I would put some debugging displays in there. Assuming the trigger fires, and I wouldn't be too confident, then you will probably find that it is getting:


"   Resist Fire"


(note the spaces). Thus " Resist Fire" won't match "Resist Fire".
USA #16
I see a * at the beginning of the trigger. Wouldn't that offset everything, making %2 the first Resist capture?
Australia Forum Administrator #17
Yes I noticed that too, but since he is checking %1 through %11 maybe that isn't a big issue.

However this is:


if "%10" == "Resist Fire" then
Send("Say Resist Fire")
end--if
if "%11" == "Resist Fire" then
Send("Say Resist Fire")
end--if


The normal %1 etc. only works from %0 to %9. After that you need to use the < and > symbols, like this:


if "%<10>" == "Resist Fire" then
  Send("Say Resist Fire")
end--if
if "%<11>" == "Resist Fire" then
  Send("Say Resist Fire")
end--if


There are probably better ways of doing this than testing 11 things like that.
Amended on Fri 23 Sep 2011 07:55 AM by Nick Gammon
USA #18
thanks you two I will add spaces in front of it to test to see if it fires.

I will have to read the debug display info. to see how to do that if this doesn't work.

Will get back to you all, with my results.
USA #19
Sorry tried it it did work.
then tried with forward and backward spacing add. buy in trigger box it made every

if "%1" == "   Resist Fire                             
 "  then

fall onto two line, out i figured out another way to do what i wanted to do.
So I believe I am going to let this question, die. unless something else pops up, that I need to figure out how it works. Thanks Nick and all you people for attempting to help me solve my issue.