Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: 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.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: 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.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: 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.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: 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
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Moo
Apprentice


Joined: 10 Apr 2009
Posts: 145

PostPosted: Sun Aug 30, 2009 7:30 pm   
 
Code:
#trigger {This is item one} {#gag;#print 1. %line}
Very Happy
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: 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
Reply with quote
Moo
Apprentice


Joined: 10 Apr 2009
Posts: 145

PostPosted: Sun Aug 30, 2009 9:40 pm   
 
Ah oops, didn't see that..
Reply with quote
Moo
Apprentice


Joined: 10 Apr 2009
Posts: 145

PostPosted: 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}}
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: 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
Reply with quote
Moo
Apprentice


Joined: 10 Apr 2009
Posts: 145

PostPosted: 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..
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: 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
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: 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.
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net