 |
darmir Sorcerer

Joined: 10 Oct 2000 Posts: 706 Location: USA
|
Posted: Sun Oct 03, 2010 4:11 pm
Trigger and mud wrapping issue |
I have a trigger that sometimes it works and sometimes it doesn't. The mud I play auto wraps long sentences and when it is long my trigger doesn't catch.
My trigger:
| Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger priority="620">
<pattern>You ({get|put}) (*) ({from|into}) (*).</pattern>
<value>#print Right hand @wearlocs.right-hand
#if ( "get" =~ %1 ) {
#if (@wearlocs.right-hand =~ " ") {
#addkey wearlocs right-hand %2} {
#addkey wearlocs left-hand %2}
} {
#if (@wearlocs.right-hand =~ " ") {
#delkey wearlocs left-hand } {
#delkey wearlocs right-hand}
}
data</value>
</trigger>
</cmud>
|
Here is example of the mud output for one that wraps and one that doesn't:
| Code: |
You get a generous serving of cooked bulgar wheat from a simple leather
backpack. |
| Code: |
| You get a loaf of rye bread from a simple leather backpack. |
Any ideas how to use the same trigger? |
|
_________________ Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian) |
|
|
 |
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Sun Oct 03, 2010 9:53 pm |
I have no idea how to have a trigger respond to multiple lines intelligently, considering that limitation you could use some sort of multistage alias system.
Basically you would have to move all of your logic to an alias, and have your triggers store the needed values for your logic into global variables. The other thing your trigger would have to do is enable variables to maintain flow control.
So have two special variables that act like true false statements called lock1, and lock2
In the case where everything matches on one line, then have the trigger act as it currently does.
In the case where there is a match for the first part of the trigger on one line, then set the first lock to true or a value of 1, and store the recorded variables.
In the case where there is a match for the second part of the trigger on another line, then set the second lock to true of a value of 1, and store the recorded variables, and call the alias.
Within the alias, before your main logic is executed check that both locks are set to true.(or a value of 1) And after you have completed the desired logic, set both the locks back to false. And clear out the variables.
Its an ugly work around, but it should get the job done. |
|
_________________ <Clever text here> |
|
|
 |
darmir Sorcerer

Joined: 10 Oct 2000 Posts: 706 Location: USA
|
Posted: Sun Oct 03, 2010 10:48 pm |
If I did it how you suggested then I would need to store all the combinations of what I am able to get/put and containers I can get from or put into.. Too messy...
Anybody else have any more ideas? |
|
_________________ Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian) |
|
|
 |
complex Apprentice
Joined: 12 Apr 2004 Posts: 134 Location: USA
|
Posted: Sun Oct 03, 2010 11:21 pm |
I don't know about that. Leave one trigger to match your current set up, so have it be exactly the same.
Then a second trigger
| Code: |
Pattern: You ({get|put}) (*)
#T+ key1
@getputs= %1
|
Then a third trigger
| Code: |
Patter: (*) ({from|into}) (*)
#T+ key2
@frominto = %1
runlogic //what ever the alias name is
|
Then your alias
| Code: |
Name: runlogic
#print Right hand @wearlocs.right-hand
#if( "get" =~ @getputs) {
#if (@wearlocks.right-hand =~ " ") {
#addkey wearlocks right-hand @frominto} {
#addkey wearlocks left-hand @frominto}
} {
#if (@wearlocs.right-hand =~ " ") {
#delkey wearlocs left-hand } {
#delkey wearlocs right-hand}
}
#t- key1
#t- key2
|
You would not need to change anything else because you are just moving your logic around. I its messy, but would work. =)[/code] |
|
_________________ <Clever text here> |
|
|
 |
Moo Apprentice
Joined: 10 Apr 2009 Posts: 145
|
Posted: Mon Oct 04, 2010 10:40 am |
Are you sure there isn't a setting on the MUD that would either let you disable the server wrapping of lines, or perhaps set it to a very long line length so it won't happen?
|
|
|
|
 |
Vijilante SubAdmin

Joined: 18 Nov 2001 Posts: 5187
|
Posted: Tue Oct 05, 2010 6:07 pm |
Use a multistate trigger, and test for the period ending. Off the top of my head something like:
| Code: |
#REGEX "wearloc" {^You (?:(get)|(put)) (.*)} {#IF (%ends(%2,".") {#STATE wearloc 2;#SET wearloc 2 1}}
#COND {(*)} {#STATE wearloc 2;#SET wearloc 2 1}
#COND {} {#LOCAL item,loc,dir,full;#IF (%ends(%t3,".") {$full=%t3} {$full=%concat(%t3," ",%t4);#CALL %regex($full, "(.*?) (from|into) (.*?).",$item,$dir,$loc);#IF (%t1="get") {addkey} {delkey}} {manual} |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
 |
|
|
|