|
kyanos Newbie
Joined: 14 Jul 2002 Posts: 7 Location: Canada
|
Posted: Thu Sep 18, 2003 7:28 pm
Peculiarity with #PSUB |
First off, thanks for implementing this command. I requested something similar a while back, didn't really expect it to happen, but it's there and more flexible and powerful than I had in mind! (You don't really want to see my previous workarounds, though.) I managed to get it to add text to the end of a line within a few minutes of discovering its existence. It didn't change the colouring of the line or anything else, it worked perfectly. But I'm having a difficult time getting it to insert text at the *beginning* of a line, without otherwise affecting the line.
For example, I'm trying to make it more obvious when I do something related to casting. Such as:
Code: |
#TRIGGER {^You complete your spell.} {#PSUB "[MAGIC] " 0 0} |
This should put the text "[MAGIC] " on the beginning of the line without affecting anything else. I've played around with those two numbers, but this is the only way I've gotten it to work. (I thought perhaps putting -1 0, or -1 -1, might work, but then it starts inserting ANSI sequences -- sometimes elsewhere on the line -- and looks worse.) Even this doesn't work quite right, because it chops off the first character of the line:
[MAGIC] ou complete your spell.
I have to manually re-insert it like this:
Code: |
#PSUB %concat("[MAGIC] ", %ansi(%linecol), %copy(%line,1,1)) 0 0 |
Which does work fine in all the cases I've tried, but seems inelegant and not the way it's supposed to work. If anybody can suggest a method that does work better, or explain why it currently works the way it does, that'd be great. It'd be really nice if this command had two simple ways to say "insert this at the beginning of the line" and "insert this at the end of the line" without having to worry about offsets or fake ()'s in the trigger pattern to take advantage of the %x1 .. %x99.
One last thing on this topic -- I can't seem to enclose that text in []. I've tried using %concat("[", "MAGIC", "] "), using escape sequences, even creating special variables that just contain "[" and "]" but I just can't get #PSUB to display the square brackets. I have redefined "[" as the window special character (a holdover from way back when putting a smiley like ":)" at the end of a line would try to send something to the ")" window), as well as re-defining the quote char to "" (I'm used to unix), either one of which might be causing problems. I had a trigger with sequences of [%d] in the pattern, I couldn't get it to match the brackets even when escaped (either with or ~), I eventually had to use ? to match anything at that position.
Any suggestions or feedback would be appreciated! |
|
|
|
megamog75 Enchanter
Joined: 20 Nov 2002 Posts: 627 Location: USA
|
Posted: Thu Sep 18, 2003 8:55 pm |
first thing:
#TRIGGER {^You complete your spell.} {#PSUB "[MAGIC] " 0 0}
woulod work like this too
#TRIGGER {^(You complete your spell).} {#SUB "~[MAGIC~] %1"}
to enclose []or any other command symbol you need to have zmud ignor it with ~ in front of every symbol you want to be ignored (patter mattching)
that is ofcorse if you have your defaults set. |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Thu Sep 18, 2003 10:24 pm |
#PSUB obviously has problems displaying []. Use something else.
Since you aren't specifying a color, #PSUB takes on the initial line-color and since you know the phrase to be matched, your workaround can be simplified considerably.
#TRIGGER {^You complete your spell.} {#PSUB "{MAGIC} Y" 0 0} |
|
|
|
kyanos Newbie
Joined: 14 Jul 2002 Posts: 7 Location: Canada
|
Posted: Fri Sep 19, 2003 7:57 pm |
megamog75:
That's actually very much what my old versions looked like; match the entire line (although you need some kind of wildcard in there to capture it to %1), gag it, add my text and spit it back out. It removes all the ANSI colours on the line, though, which is why I wasn't pleased with the solution.
LightBulb:
Actually, I am changing colours, which is why the %concat is necessary. I didn't put that in the post because it makes the code much messier: the trigger actually looks like
Code: |
#PSUB %concat(%ansi(magenta,bold), "[MAGIC] ", %ansi(%linecol), %copy(%line, 1, 1)) 0 0
|
I guess I don't technically need to bother with the %copy, since I will know what the first letter is. That should speed it up a little.
Thanks! |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|