Multiline trigger and shopkeepers

Posted by John on Wed 27 Apr 2005 12:20 AM — 16 posts, 73,130 views.

Australia #0
I want to have the inventory of a shopkeeper be in a notepad, so how would I do this? The shopkeeper screen looks like this:
The man has the following to sell:
01) a beads for 450 obsidian coins.
02) a braided headband for 683 obsidian coins.

(with numerous other items).

I've got the multi-line ticked (and the value has 100 as a shopkeeper is unlikely to have more then that), and I have "append to notepad", but I still can't get it to work. A shopkeeper lists his inventory on the command "list".

Thanks
Amended on Wed 27 Apr 2005 12:21 AM by John
USA #1
Suggest stop using a multiline trigger, and start using a series of triggers.

One to start:
^The (wo)?man has the following to sell:$
which turns on the next two, one being an item:
^(\d{2})\) (.*) for (\d+) obsidian coins?\.$
and the other being something to end it:
(if there's anything that always ends the list, if not, then a general line that has a higher sequence as the second).

And the first one turns on the second two, and the third turns off the last two (first one stays on, so you can get another list).
And of course, the first two (and possibly the third) send to the notepad window.

There are a couple of examples of this already in the forum (somewhere) but I couldn't find any of them with a bit of searching, perhaps you'll be more fruitful if you need further examples.
Australia #2
Thanks Flannel (seems to be you always answering my questions ;)).

I am having trouble activating the second and third script. Here is what I've done:
First script activates and sends this code to "Script":
EnableTrigger "a", 0
EnableTrigger "End_Shopkeeper", 0

(tried it with)

EnableTrigger "[a]", 0
EnableTrigger "[End_Shopkeeper]", 0

It does activate (because I get it to omit the string that causes it to do so), but it doesn't enable the second and third trigger. Those scripts are called "a" and "End_Shopkeeper" by placing those values in "Label" (without the " ") field. They are unique. Scripting is enabled (I had no script, then I placed "default.vbs").

The second (and apparently third) scripts do work (I don't see why the third one does).

I just spent half an hour searching for ways to fix it. I can't.

[EDIT]: Fixed typo
Amended on Wed 27 Apr 2005 05:36 AM by John
USA #3
To enable, you need to have it be:
EnableTrigger "name", 1
not 0. And it's just a simple string (no fancy brackets or anything)
So if you had a trigger labeled 'MiddleTrigger' then your line would be:
EnableTrigger "MiddleTrigger", 1
to enable, and
EnableTrigger "MiddleTrigger", 0
to disable (as in, EnableTrigger True, and EnableTrigger False)
And they aren't case sensitive.

And it would enable the triggers, not the scripts (correct terminology will prevent lots of confusion later, if not now).

And you don't need a script file, just enabled (of course, this doesn't matter).
Australia #4
Thanks a lot again, you're a big help. That did it :) And now to complicate it further, how do I have two different triggers send to the same notepad file?
Amended on Wed 27 Apr 2005 05:41 AM by John
USA #5
Ummm, well, since you're currently using send to script (right?) and you're using SendToNotepad to send to the notepad (right?, if not, how are you doing it? Send_to=notepad and then a script file? far too complicated).

You just use the same notepad name in both SendToNotepad lines.

So yeah, if you're doing it any other way, you might as well use SendTo:Script (because it keeps you from having to open/edit/save your script file every 5 minutes) and then SendtoNotepad (and EnableTrigger, of course).
Australia #6
It works now :) As for how I did it, I wasn't using a script, so the first thing I did was that.

I was having the middle screen send to a notepad (by having it "Send to" Notepad, rather then, Script). I then wanted the string that starts the first trigger to be placed in the same notepad window, so I created a second trigger that worked on the same string and sent that to a notepad window, only it did so to a unique window (not the same one as the middle trigger).

Thanks again :)
USA #7
Hey guys, This gave me a idea when I was browsing, making a lore file that through the use of a programmer friend of mine, I want him to design a program that searches through this, in pre-empting his questions, I was wondering if I can use this send to notepad to send something from the mud that looks like this


You feel informed:
Object 'axe vallenwood handle'
Item Type: WEAPON
Mat Class: metal Material: iron
Weight : 3 Value : 50

Affects : HITROLL by 1
Affects : skill axes by +3
Item is : MAGIC
Class : hand_axe
Damage : 4D3


I get the idea of muiltiple triggers (but seriosly at a loss of yet as to how to do it, but Im working on that) how do I figure out how to tell it when to stop if every lored item is going to have a differant last line? here's a few more examples if it helps:

You feel informed:
Object 'band stone granite'
Item Type: ARMOR
Mat Class: natural Material: stone
Weight : 5 Value : 75

Affects : HITROLL by 1
Affects : INT by -1
Effects : DETECT_INVISIBLE
Item is : GLOW MAGIC
Apply : 4


You feel informed:
Object 'mace black fluted'
Item Type: WEAPON
Mat Class: metal Material: bronze
Weight : 8 Value : 12

Item is : ANTI_GOOD
Class : mace
Damage : 2D5




If its to complicated, is there a way to use a typed command such as "loreon" to turn on a sendo trigger that captures everything until I type loreoff again? this sounds allot easier for my primitive knowledge.

Thanks a million and one.
Australia Forum Administrator #8
A single multi-line trigger might work for you. Here is one that worked on what you posted here:


<triggers>
<trigger
enabled="y"
group="Multi Line"
lines_to_match="50"
keep_evaluating="y"
match="You feel informed:\nObject '.*'\nItem Type: .*\nMat Class: .* Material: .*\nWeight : .* Value : .*\n\n([A-Za-z0-9 ]+ : .*\n)*\n\Z"
multi_line="y"
regexp="y"
send_to="2"
sequence="100"
>
<send>%0</send>
</trigger>
</triggers>


For this to work properly you need something to "anchor" the start and the end of the multi-line set. I have used "You feel informed:" to indicate the start, and a blank line to indicate the end. This example just sends to the output window, but you could send to notepad, or use scripting to break the text down further.
USA #9
Ummm K, where do I put this so I can use it? do I make a text file and save it somewhere as something?
Australia Forum Administrator #10
See:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4777
USA #11
I did the paste feature, then got this message:

Line 7: Attribute not used: lines_to_match="50" (trigger)
Line 10: Attribute not used: multi_line="y" (trigger)

Any idea? (havent messed with the send to notepad yet)
Australia Forum Administrator #12
What version of MUSHclient do you have? Multi-line triggers were introduced quite a while back.
USA #13
vrs 3.42 this one old?
USA #14
Ok, I downloaded the new version, I must have been running a really old one or something, the new one deffinetly looks clearer, now Im trying to figure out how to send it to notepad, or where its sending it to atm, what its capturing exc.
USA #15
Ok, So Im sold on mushclient now, but a couple things are still a mystery to me, looking into it at work, but can anyone tell me, in the above mentioned script, where do I inster the sendtonotepad command so it will send it to the notepad?

Is it as simple as <send>sendtonotepad</send> or do I make a seperate script and save it, then add it into the script function? Sorry, I found the sendto forum document ounce but havent been able to relocate it.


Thanks.