Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUSHclient
➜ Suggestions
➜ world.substitute() method
world.substitute() method
|
Posting of new messages is disabled at present.
Refresh page
Pages: 1 2
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Fri 26 Jun 2009 01:29 AM (UTC) |
Message
| Hello,
I've seen other clients that do this, but I haven't been able to replicate this functionality in MUSHclient.
Basically what I'd like to see is a way to match on a line of text, and be able to parse crucial information out of that line of text and into variables, then substitute the old line of text with a new, shorter one, for example.
I've tried doing this by checking "omit from output", but calls to world.simulate() do nothing when this option is checked, at least as far as I can tell. | Top |
|
Posted by
| WillFa
USA (525 posts) Bio
|
Date
| Reply #1 on Fri 26 Jun 2009 01:47 AM (UTC) |
Message
| Make your trigger with a low priority.
Send to Script After Omit
Simulate away!
| Top |
|
Posted by
| Fadedparadox
USA (91 posts) Bio
|
Date
| Reply #2 on Fri 26 Jun 2009 01:49 AM (UTC) Amended on Fri 26 Jun 2009 02:00 AM (UTC) by Fadedparadox
|
Message
| To keep colours, if you send to 'script (after omit)' it will save the line in a table called TriggerStyleRuns, which you can use like this to replicate the line:
for k, v in ipairs (TriggerStyleRuns) do
ColourTell (RGBColourToName (v.textcolour),
RGBColourToName (v.backcolour),
v.text)
end -- for
Note ("")
You can, anywhere within this, modify the line however you wish by adding a tell before it, modifying v.text in the tell for a certain section, or adding to the end by adding to the note.
Just noticed you said 'world.' so I'm guessing you're not using Lua. That's how I'd do it in Lua, not sure about your language. | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #3 on Fri 26 Jun 2009 04:10 AM (UTC) |
Message
| Ahh, I had forgotten that "script (after omit)" was an option.
Thanks all! | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #4 on Fri 26 Jun 2009 04:27 AM (UTC) |
Message
| Ok, I had to use tell instead of simulate (simulate still refused to do anything), but it seems to work now. Awesome. Thanks again. | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #5 on Fri 26 Jun 2009 04:36 AM (UTC) |
Message
| Hrm, maybe there's a bug after all.
I noticed that If I try to use two triggers to change two lines that are close together, a score display, for example, the first trigger works fine, but the second doesn't even execute, for some reason.
In the MUD I'm playing, the verbose score display is written in sentence format. Just to test, I tried setting up some substitution triggers for the first two lines. The first trigger works, getting variables with the current/max HP, guild points, quest points, achievement points etc, but the second line that's supposed to tell me my XP, guild level and rating shows up as normal, instead of being substituted. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #6 on Fri 26 Jun 2009 04:43 AM (UTC) |
Message
| I would be cautious about using Simulate, that was really intended for debugging. ColourNote, ColourTell etc. are the way to go for putting stuff back into the output window.
As for your trigger problems, triggers work pretty reliably. It is most likely that your matching is off. Try posting the example MUD output, and your exact triggers, see: http://mushclient.com/copying |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #7 on Fri 26 Jun 2009 08:08 PM (UTC) |
Message
| Ok, here's the text that I'm trying to substitute. Just FYI, I'm using VBScript in the triggers.
"
You have 1919 (1919) hit points, 120 (349) guild points, 410 (679) quest points, 128 (1021) achievement points and 500 (500) social points.
Your current experience is 65690 and you are level 246 in Mrs. Widgery's Lodgers; your overall rating is 95476.
"
The XML for the triggers is:
<trigger
enabled="y"
group="score"
keep_evaluating="y"
match="You have * (*) hit points, * (*) guild points, * (*) quest points, * (*) achievement points and * (*) social points."
omit_from_output="y"
send_to="14"
sequence="1"
>
<send>world.tell "HP: %1/%2. GP: %3/%4. QP: %5/%6. AP: %7/%8." + vbcrlf</send>
</trigger>
<trigger
enabled="y"
group="score"
keep_evaluating="y"
match="Your current experience is * and you are level * in *; your overall rating is *."
omit_from_output="y"
send_to="14"
sequence="1"
>
<send>world.tell "XP: %1. LVL: %2 (%3). RT: %4." + vbcrlf</send>
</trigger>
If I turn both triggers on, the first line gets modified the way I want it, but the second line remains unchanged. Once I disable the first trigger, the second one works. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #8 on Fri 26 Jun 2009 08:56 PM (UTC) |
Message
| I just tested what you pasted there and both lines got modified. What version of MUSHclient are you using?
One change I would suggest is changing:
<send>world.tell "HP: %1/%2. GP: %3/%4. QP: %5/%6. AP: %7/%8." + vbcrlf</send>
to:
<send>Note "HP: %1/%2. GP: %3/%4. QP: %5/%6. AP: %7/%8."</send>
(The world. part isn't necessary these days).
The more important point is that Tell is for partial lines, and Note is to have the client complete the line for you (in which case you don't need the vbcrlf).
Note only is that shorter and neater, I think earlier versions got a bit confused with the transitions from Note lines to MUD output, so it possibly didn't recognize the second line as MUD output, and therefore something to be triggered from. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #9 on Fri 26 Jun 2009 09:18 PM (UTC) |
Message
| Ahh, I didn't know that "world." was no longer required. I'm using version 4.41. I'll try the modifications you suggested.
Thanks a lot. | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #10 on Fri 26 Jun 2009 09:22 PM (UTC) |
Message
| Odd... Tried those suggestions, but the same thing happened. | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #11 on Fri 26 Jun 2009 09:59 PM (UTC) |
Message
| Maybe another trigger is matching? Try giving both triggers a name (put something in the "Label" box) and then turn on trace: Game menu -> Trace.
That will show which, if any, triggers match.
The trace output might be omitted from output too, try redirecting to a miniwindow. To do that, install this plugin:
http://www.gammon.com.au/forum/?id=9218 |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #12 on Fri 26 Jun 2009 11:24 PM (UTC) |
Message
| Ok...
I did that, and with both triggers enabled, got the following:
Matched trigger "You have * (*) hit points, * (*) guild points, * (*) quest points, * (*) achievement points and * (*) social points."
However, the second trigger didn't match, as if the first one was somehow preventing the second one from being matched on or executing.
When I disabled the first, I got this instead:
Matched trigger "Your current experience is * and you are level * in *; your overall rating is *." | Top |
|
Posted by
| Nick Gammon
Australia (23,122 posts) Bio
Forum Administrator |
Date
| Reply #13 on Sat 27 Jun 2009 12:31 AM (UTC) |
Message
| Trigger matching is atomic on lines. There is no behaviour that, if one line matches, it somehow prevents future lines matching (unless, of course, the first match executes a script that disables triggers).
I am starting to wonder about your "lines". That is why I queried the use of world.Tell instead of world.Note.
Since my test worked, that confirms that your triggers are OK, and the client is OK. Now we have to wonder about the input data. ;_)
Can you please go the Edit menu and turn on Debug Packets? Then reproduce the problem. Turn Debug Packets off or the packet debug will get very large. In the resulting packet debug window, find the packet or packets that contain the problem lines, and post them here. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Coderunner
USA (27 posts) Bio
|
Date
| Reply #14 on Sat 27 Jun 2009 02:09 AM (UTC) Amended on Sat 27 Jun 2009 02:20 AM (UTC) by Nick Gammon
|
Message
| Incoming packet: 16 (958 bytes) at Friday, June 26, 2009, 9:06:37 PM
You have .[4z<!E 59 6f 75 20 68 61 76 65 20 1b 5b 34 7a 3c 21 45
N hp 1919 publis 4e 20 68 70 20 31 39 31 39 20 70 75 62 6c 69 73
h>1919 (.[4z<!EN 68 3e 31 39 31 39 20 28 1b 5b 34 7a 3c 21 45 4e
maxhp 1919 publ 20 6d 61 78 68 70 20 31 39 31 39 20 70 75 62 6c
ish>1919) hit po 69 73 68 3e 31 39 31 39 29 20 68 69 74 20 70 6f
ints, .[4z<!EN g 69 6e 74 73 2c 20 1b 5b 34 7a 3c 21 45 4e 20 67
p 349 publish>34 70 20 33 34 39 20 70 75 62 6c 69 73 68 3e 33 34
9 (.[4z<!EN maxg 39 20 28 1b 5b 34 7a 3c 21 45 4e 20 6d 61 78 67
p 349 publish>34 70 20 33 34 39 20 70 75 62 6c 69 73 68 3e 33 34
9) guild points, 39 29 20 67 75 69 6c 64 20 70 6f 69 6e 74 73 2c
410 (679) quest 20 34 31 30 20 28 36 37 39 29 20 71 75 65 73 74
points, 128 (10 20 70 6f 69 6e 74 73 2c 20 31 32 38 20 28 31 30
21) achievement 32 31 29 20 61 63 68 69 65 76 65 6d 65 6e 74 20
points and .[4z< 70 6f 69 6e 74 73 20 61 6e 64 20 1b 5b 34 7a 3c
!EN sp 493 publi 21 45 4e 20 73 70 20 34 39 33 20 70 75 62 6c 69
sh>493 (.[4z<!EN 73 68 3e 34 39 33 20 28 1b 5b 34 7a 3c 21 45 4e
maxsp 493 publi 20 6d 61 78 73 70 20 34 39 33 20 70 75 62 6c 69
sh>493) social p 73 68 3e 34 39 33 29 20 73 6f 63 69 61 6c 20 70
oints..[4z<BR>Yo 6f 69 6e 74 73 2e 1b 5b 34 7a 3c 42 52 3e 59 6f
ur current exper 75 72 20 63 75 72 72 65 6e 74 20 65 78 70 65 72
ience is .[4z<!E 69 65 6e 63 65 20 69 73 20 1b 5b 34 7a 3c 21 45
N xp 97047 publi 4e 20 78 70 20 39 37 30 34 37 20 70 75 62 6c 69
sh>97047 and you 73 68 3e 39 37 30 34 37 20 61 6e 64 20 79 6f 75
are level 246 i 20 61 72 65 20 6c 65 76 65 6c 20 32 34 36 20 69
n Mrs. Widgery's 6e 20 4d 72 73 2e 20 57 69 64 67 65 72 79 27 73
Lodgers; your o 20 4c 6f 64 67 65 72 73 3b 20 79 6f 75 72 20 6f
verall rating is 76 65 72 61 6c 6c 20 72 61 74 69 6e 67 20 69 73
95476..[4z<BR>Y 20 39 35 34 37 36 2e 1b 5b 34 7a 3c 42 52 3e 59
ou have died 34 6f 75 20 68 61 76 65 20 64 69 65 64 20 33 34 20
times and can di 74 69 6d 65 73 20 61 6e 64 20 63 61 6e 20 64 69
e 3 times before 65 20 33 20 74 69 6d 65 73 20 62 65 66 6f 72 65
you are complet 20 79 6f 75 20 61 72 65 20 63 6f 6d 70 6c 65 74
ely dead..[4z<BR 65 6c 79 20 64 65 61 64 2e 1b 5b 34 7a 3c 42 52
>Your wimpy is s 3e 59 6f 75 72 20 77 69 6d 70 79 20 69 73 20 73
et to 30%..[4z<B 65 74 20 74 6f 20 33 30 25 2e 1b 5b 34 7a 3c 42
R>You are unburd 52 3e 59 6f 75 20 61 72 65 20 75 6e 62 75 72 64
ened (21%) and q 65 6e 65 64 20 28 32 31 25 29 20 61 6e 64 20 71
uite comfortable 75 69 74 65 20 63 6f 6d 66 6f 72 74 61 62 6c 65
..[4z<BR>You are 2e 1b 5b 34 7a 3c 42 52 3e 59 6f 75 20 61 72 65
barely evil, wo 20 62 61 72 65 6c 79 20 65 76 69 6c 2c 20 77 6f
rshipping no god 72 73 68 69 70 70 69 6e 67 20 6e 6f 20 67 6f 64
..[4z<BR>You are 2e 1b 5b 34 7a 3c 42 52 3e 59 6f 75 20 61 72 65
a citizen of An 20 61 20 63 69 74 69 7a 65 6e 20 6f 66 20 41 6e
kh-Morpork and t 6b 68 2d 4d 6f 72 70 6f 72 6b 20 61 6e 64 20 74
he Agatean Empir 68 65 20 41 67 61 74 65 61 6e 20 45 6d 70 69 72
e..[4z<BR>You ar 65 2e 1b 5b 34 7a 3c 42 52 3e 59 6f 75 20 61 72
e 113 days, 18 h 65 20 31 31 33 20 64 61 79 73 2c 20 31 38 20 68
ours, 37 minutes 6f 75 72 73 2c 20 33 37 20 6d 69 6e 75 74 65 73
and 36 seconds 20 61 6e 64 20 33 36 20 73 65 63 6f 6e 64 73 20
old and have log 6f 6c 64 20 61 6e 64 20 68 61 76 65 20 6c 6f 67
ged in 1075 time 67 65 64 20 69 6e 20 31 30 37 35 20 74 69 6d 65
s..[4z<BR>.[4z<! 73 2e 1b 5b 34 7a 3c 42 52 3e 1b 5b 34 7a 3c 21
EN hp 1919 publi 45 4e 20 68 70 20 31 39 31 39 20 70 75 62 6c 69
sh>.[4z<!EN xp 9 73 68 3e 1b 5b 34 7a 3c 21 45 4e 20 78 70 20 39
7047 publish>.[4 37 30 34 37 20 70 75 62 6c 69 73 68 3e 1b 5b 34
z<!EN gp 349 pub 7a 3c 21 45 4e 20 67 70 20 33 34 39 20 70 75 62
lish>.[4z<!EN ma 6c 69 73 68 3e 1b 5b 34 7a 3c 21 45 4e 20 6d 61
xhp 1919 publish 78 68 70 20 31 39 31 39 20 70 75 62 6c 69 73 68
>.[4z<!EN maxgp 3e 1b 5b 34 7a 3c 21 45 4e 20 6d 61 78 67 70 20
349 publish>ÿù 33 34 39 20 70 75 62 6c 69 73 68 3e ff f9
| Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
60,035 views.
This is page 1, subject is 2 pages long: 1 2
Posting of new messages is disabled at present.
Refresh page
top