|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Wed Aug 26, 2009 2:53 am
#SAY ADD/PROMPT idea |
Can this command be mage to take an additional paramater?
#SAY{add|prompt} {text} -1
So that i could have it appear in the prompt space of the current line? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Aug 26, 2009 4:01 pm |
I have no idea what you mean by "appear in the prompt space of the current line". Please give me a more detailed example of what you are trying to do.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Thu Aug 27, 2009 3:35 am |
In short, the start of the triggering line... instead of the following line or the end of the triggering line
Here is an example.
#TR {This is item one.} {#SAYp { 1. } -1}
Would turn:
This is item one.
into:
1. This is item one. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Thu Aug 27, 2009 4:29 pm |
You need to take a look at the #PSUB command. It will do what you want and allow you to manipulate the text line and place new text at the beginning. If you have trouble, I'm sure someone can post a specific example.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Fri Aug 28, 2009 7:08 am |
I just want to insert text to the front of the line, not replace anything....
I can't seem to get the results I want without enclosing the entire pattern in parenthesis
#TR {(This is item one.)} {#PSUB {1. %1} %x1}
But i dont see how using the #PSUB is any better than using:
#SUB {1. %1}
But then i try the following to see what happens.
#SAY bleet skeet neat fleet This is item one.
And its still not inserted to the point i want (the very start of the line) unless i remove %x1, and then the gibberish gets removed.
I could use %line, but then we are back to, why use #PSUB for this when #SUB handles it fine. heck, i could #gag and #say with %line
Maybe i just dont get how #PSUB works.
----
#TR {(^)*This is item one.} {#PSUB {1. } %x1}
I thought i might be sneaky this way... but it doesn't seem to even fire this way. Until you spam the #SAY. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Aug 28, 2009 4:50 pm |
Look at the #PSUB documentation and you will learn that the additional arguments of #PSUB allow you to specify the start and end X and Y position of the text replacement. The %x1 is just a shortcut for the matched position of the first subpattern. In any case, you can do what you want with the following regular expression trigger:
#REGEX {^(.)} {#PSUB {1. %1} %x1}}
This matches a single character at the beginning of a line and replaces it. Sort of like what you were trying to do with your (^) trick, but the ^ and $ characters in a regular expression don't actually match any subtext, they just anchor the pattern. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sat Aug 29, 2009 12:39 am |
I had to look up what . meant in regex, but once i did, i figured out how to apply it.
#tr {^(?)*This is item one.} {#PSUB {1. %1} %x1}
This works for my example, thanks for the help.
As for the documentation, i had read it, but I didn't understand the extra arguments.
Perhaps if there was an example there that used all five potential arguments it would have been more clear. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sat Aug 29, 2009 1:18 am |
On second thought that only works when there is preceeding text.
I tried again without it and failure...
A bit more finagaling and iI got it to work...
#TR {This is item one.} {}
#COND {^(?)} {#PSUB {1. %1} %x1} "reparse"
Which makes me wonder... there might me lots of things where i will want to insert something to the start of the line.
And remaking the same reparse state over and over feels like bad coding to me.
Can #PSUB be called from an alias or event?
I see no reason why it couldn't, but how would i pass it control of the line with the proper arguments?
I can see a way, but it would involve a new command:
#REPARSE {pattern} {commands} linenum
It would work exactly like a reparse trigger state, with the exception that the optional linenum argument could specify a line |x| places back from the current.
My example would then be something like:
#EVENT onLineInsert {#IF (%params!=%null) {
$insert=%params
#REPARSE {^(?)} {#PSUB {$insert %1} %x1}
}
}
#TR {This is line one.} {#RAISE onLineInsert "1."} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Sat Aug 29, 2009 3:48 pm |
I think your making this more complicated than this needs to be.
Code: |
#trigger {^(T)his is item one.$} {#psub {1. %1} {%x1}}
#trigger {^(T)his is item two.$} {#psub {2. %1} {%x1}} |
as for the documentation on the additional arguments to psub they're auuu, well i've never used them.
XStart would be for additional control over where the text goes on this line
Ystart Yend would be for replacing text on... previous line or next line. |
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sun Aug 30, 2009 12:32 pm |
If you can find a way for it to fire, weather or not the text is anchored to the front of the line, yet still have the inserted text at the starting the line, then i would agree, but I cant get my mind around another way to manage it.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Moo Apprentice
Joined: 10 Apr 2009 Posts: 145
|
Posted: Sun Aug 30, 2009 7:30 pm |
Code: |
#trigger {This is item one} {#gag;#print 1. %line}
|
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sun Aug 30, 2009 9:33 pm |
That would remove any custom colors sent by the MUD though.
Plus I mentioned that method up on my third post, only using #SAY instead of #PRINT |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Moo Apprentice
Joined: 10 Apr 2009 Posts: 145
|
Posted: Sun Aug 30, 2009 9:40 pm |
Ah oops, didn't see that..
|
|
|
|
Moo Apprentice
Joined: 10 Apr 2009 Posts: 145
|
Posted: Mon Aug 31, 2009 12:22 am |
How about this:
Code: |
#trigger {(^*This is item one)} {#sub {1. %1}}
or
#trigger {^*This is item two*$} {#sub {2. %line}}
|
|
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Mon Aug 31, 2009 12:54 pm |
Code: |
#regex {^(.).+?This is item one.$} {#psub {1. %1} {%x1} }
#regex {^(.).+?This is item two.$} {#psub {2. %1} {%x1} }
|
|
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
Moo Apprentice
Joined: 10 Apr 2009 Posts: 145
|
Posted: Mon Aug 31, 2009 1:13 pm Re Wrym |
Erm.. Isn't ".+?" the same as ".*" ?
Also, you'd need a .* or something before the $ at the end, or it would only match when the text was at the end of the line.. |
|
|
|
wrym Magician
Joined: 06 Jul 2007 Posts: 349 Location: The big palace, My own lil world
|
Posted: Mon Aug 31, 2009 2:04 pm |
No .+? is atleast 1 characters, as few as possible, .* is 0 or more characters as many as possible
If you just want to match "this is item one", "some text, this is item one" or "this is item one. and some more text" you'ld needa change to:
Code: |
#regex {^(.).+?is is item one.} {#psub {1. %1} {%x1} }
#regex {^(.).+?is is item two.} {#psub {2. %1} {%x1} }
|
Not really any reason to anchor the end just something extra to match and will end up slowing you down. same thing for the "greedy" wild card, .* as many as possible |
|
_________________ "To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle |
|
|
|
nexela Wizard
Joined: 15 Jan 2002 Posts: 1644 Location: USA
|
Posted: Tue Oct 06, 2009 4:17 am |
Normaly I wouldnt drag up an older topic but I figured why not.
#Trigger {^This is line one.} {#PSUB {1.%left(%line,1)} 0 0}
%left(%line,1) will return the first character of the line that triggered the script and 0 0 is the first space in the line for the psub. |
|
|
|
|
|