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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sat Aug 12, 2006 4:46 pm   

feature request, #sub and #psub taking out end of line.
 
Is there a way to substitute string, #sub or #psub, including end of line characters in cmud? So that next line recieved from mud would then be appeneded to that substituted string? Kind of like #echop, but for substitutes.


Last edited by hav on Sat Aug 12, 2006 8:00 pm; edited 1 time in total
Reply with quote
Zugg
MASTER


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

PostPosted: Sat Aug 12, 2006 5:12 pm   
 
Please change the title of your thread to something more related to the question you are asking. Otherwise you are less likely to get a useful response. I do not *want* to have *any* "Misc Questions" threads. It makes it impossible to track issues. Each separate question/bug should have it's own separate topic in the forums.

Also, your question might be better for the zMUD forum, since the scripting functions like #sub are the same between CMUD and zMUD and what you are asking is more of a "How do I do this?" question, rather than talking about CMUD Beta issues and bugs, which is what this forum is more intended for.

Now, back to your question...I'm afraid I have no idea what you are asking about. Perhaps you can give an example of what you are trying to do.
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sat Aug 12, 2006 7:53 pm   
 
My bad, I tried to be as clear as possible, sorry English just isnt my primary langage Embarassed
I _think_ its not in zmud and i'd like to add it as feature request, but not 100% sure, zmud is quite complex you just never know. Again, sorry, if wrong forum.
Now, for example, mud often sends you lines lets say ***SPAM1***, ***SPAM2*** and ***SPAM3***. Now i'd like to brief them but not completely remove with #gag. The difficult part is consolidating them on one line for easier readability.
***SPAM3***
***SPAM1***
some other text
***SPAM2***
***SPAM1***
***SPAM3***
would be nice to consolidate into lets say
spam3|spam1|
some other text
spam2|spam1|spam3|

this of course can be done in zmud, setting variables remembering what was recieved when and whatnot. I was thinking of a simple addition, sub command that also takes out end of line, so that next line from mud gets appended to substituted text, #SUBP or whatever you'd call it. Thus the above example could be achieved with something as simple as
#TR {***SPAM1***$} {#SUBP "spam1|"}
I am guessing it would only work like that if string matched is at the end of line, I guess it could work like regular #SUB if it matches somewhere in the beginning or middle of line.
Of course, this is very trivial example. #psub with end of line removal would also be appreciated for difficult patterns, #psubp or something.
Edit: hrm, seems this would actually produce
spam3|spam1|some other text
spam2|spam1|spam3|
ah well. close enough to desired result with minimum fuss, nothing's perfect.
Reply with quote
Zugg
MASTER


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

PostPosted: Sat Aug 12, 2006 9:57 pm   
 
Ahh, ok, now I understand what you are saying.

It's an interesting idea. I'll give it some thought for adding something like this in the future, but I probably won't use your syntax since I don't really want to create a bunch of new command names just to do this. If anyone else has suggestions on how they would like to tell #SUB to remove the CR/LF at the end of the line, let me know here.
Reply with quote
Vorax
Apprentice


Joined: 29 Jun 2001
Posts: 198
Location: USA

PostPosted: Sat Aug 12, 2006 10:26 pm   
 
Perhaps a new % variable to capture the CR/LF so that it can be substituted with a NULL or whatever else is desired. Or, allow the $ to be captured in the same manner as the % variables.

#TRIG {Text($)} {#Sub {%null}}
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sat Aug 12, 2006 10:48 pm   
 
Yes, I also thought about adding to existing commands, wasnt sure which is more preferable.
Obviously needs backwards compatibility, so needs extra optional parameter added. Maybe even make generic options in case deciding adding more options later, same as #TR syntax.
#SUB string [string] [options]
#PSUB text [XStart] [XEnd] [YStart] [YEnd] [options]
Now the tricky question how to call this option. Hmm, hmm, removecrlf anyone?
from above example, #TR {***SPAM1***$} {#SUB "spam1|" {removecrlf}}
Much thanks this gets considered, would considerably reduce my scripting headaches.
Vorax: probably not a good idea :)
Reply with quote
shalimar
GURU


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

PostPosted: Sat Aug 12, 2006 11:51 pm   
 
maybe a trigger to cattch the spam, then a reparse condition to strip away the $
_________________
Discord: Shalimarwildcat
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sun Aug 13, 2006 12:18 am   
 
Post triggers how its done for the above example in zmud 7.21 or cmud 1.03, whichever? I'd love to see a easy solution to situation like this. I run quite a few triggers dealing with similiar situations, and none of them are simple.
Reply with quote
shalimar
GURU


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

PostPosted: Sun Aug 13, 2006 12:53 am   
 
#tr {{@spamlist}${@spamlist}} {#noop {multispam found}}
#cond {$} {#sub {|}} "reparse"

something like that though it is untested
_________________
Discord: Shalimarwildcat
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sun Aug 13, 2006 1:24 am   
 
Tested. First part matches, though it wont work if theres more than 2 consecutive lines of spam. I'd love to it work with at least 2-10 consecutives.
More importantly, #cond totally bombs, doesnt do anything. Hence what this topic is all about. #sub and #psub could use addititional option for these kinds of situations.
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sun Aug 13, 2006 1:42 am   
 
In case anyone is curious how I'm working around briefing currently, here's actual triggers for briefing mob hits. Large load on CPU, also output glitches sometimes, gags the wrong thing. Best I could come up with, was forced to use two ^*$ triggers because I think there's some weird glitch in 7.x versions with trigger and trigger option, though i havent checked specifically with 7.21, maybe its gone there. Wrote it on 7.05.
Code:

#CLASS {mobhits}
#ALIAS mobhitsalias {#PRI {#T- mobhitsID};#ADDITEM liste5 {%0};#SUB @liste4" ("@liste5")";#IF (@war=1) {#CO 13};#IF (@mobhits=1) {#GAG -1} {#VAR mobhits 1}}
#VAR liste4 {}
#VAR liste5 {}
#VAR mobhits {0}
#REGEX "mobhitsID2" {^.*$} {#PRI {#T+ mobhitsID}}
#REGEX {^(?:@liste2) tickled (.*) in the stomach\.$} {#VAR liste4 %additem( 0, @liste4);mobhitsalias {%1}} "" {notrig}
#REGEX {^(?:@liste2) grazed (.*)\.$} {#VAR liste4 %additem( graze, @liste4);mobhitsalias {%1}} "" {notrig}
#REGEX {^(?:@liste2) hit (.*) very hard\.$} {#VAR liste4 %additem( vhard, @liste4);mobhitsalias {%1}} "" {notrig}
#REGEX {^(?:@liste2) hit (.*) hard\.$} {#VAR liste4 %additem( hard, @liste4);mobhitsalias {%1}} "" {notrig}
#REGEX {^(?:@liste2) hit (.*)\.$} {#VAR liste4 %additem( hit, @liste4);mobhitsalias {%1}} "" {notrig}
#REGEX {^(?:@liste2) struck (.*) a mighty blow\.$} {#VAR liste4 %additem( mblow, @liste4);mobhitsalias {%1}} "" {notrig}
#TRIGGER {^Bits of (*)'s skin flakes off and fall to the ground.$} {#VAR liste4 %additem( curse, @liste4);mobhitsalias {%1}} "" {notrig}
#REGEX "mobhitsID" {^.*$} {#VAR mobhits 0;#VAR liste4 "";#VAR liste5 ""}
#CLASS 0

output looks something like hard|smash|0 (Mob)
yeah i know, ugh, messy. As you can imagine, addition i am vouching for would simplify things immensely.
Reply with quote
shalimar
GURU


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

PostPosted: Sun Aug 13, 2006 2:08 am   
 
#tr {({@spamlist})$({@spamlist})} {#SUB {%1 - %2}}

again untested might need to add some *'s in there if you dont have the whole line in the stringlists or as an alternative...

#TR {^*{@spamlist}*$} {#GAG;#VAR spams {%additem(%line, @spams)};#ALARM "spamshower" +2 {#SAY {%expandlist(@spams, " - ")};#VAR spams {}}}
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


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

PostPosted: Sun Aug 13, 2006 2:22 am   
 
i just realized that second option would likely trigger on its own output for a recursive loop instead of #say try:

#WIN Spam %expandlist(@spams, " - ")
_________________
Discord: Shalimarwildcat

Last edited by shalimar on Sun Aug 13, 2006 2:26 am; edited 1 time in total
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sun Aug 13, 2006 2:24 am   
 
Tested. Opened blank 7.21 session.
#tr {(moo)$(moo)} {#SUB {%1 - %2}}
entered '#ECHO moo' a few times.
Actual output, I kid you not
moo
moo - moooomoo
moomoo moo - moooo
moo
moo - moooomoo
moomoo moo - moooo
moo
moo - moooomoo
moo moo - moo

Out of curiousity, loaded same trigger in 1.03, same output. Appreciate the effort, needs more work.

Second part seems working. Now how about same window and immediate output?
Edit: tried adding *s.
Blank session, 7.21
#tr {^*(moo)$(moo)*$} {#SUB {%1 - %2}}
Entered '#ECHO moo' twice.
Output:
moo
moo - moo
After that any #ECHO whatsoever misteriously vanishes. Laughing
Disabling trigger makes #ECHO work again.
Same trigger, 1.03
About same result, except disabling trigger didnt cut it, had to delete it.
Reply with quote
shalimar
GURU


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

PostPosted: Sun Aug 13, 2006 8:23 am   
 
Well.. If you can set up a trigger that fires when %line does NOT have any of @spamlist on it... have that trigger the #WIN command

#TR {[^{@spamlist}]}

i doubt that works... but thats the best i can think of at this hour
you can also adjust the speel of the alarm... i wanted to give it long enough for additional output to show and be added to the list before firing
_________________
Discord: Shalimarwildcat
Reply with quote
hav
Wanderer


Joined: 05 Oct 2004
Posts: 61
Location: Riga, Latvia

PostPosted: Sun Aug 13, 2006 2:28 pm   
 
Hey, no sweet. Likely there is no easy solution for my briefing needs with zmuds 7.x capabilities, I've been struggling with it for months. Looking forward to rewrite the trigger mess more efficiently using cmuds new features.
The alarm approach just wont do, sorry. Even though the text needs to be briefed, that doesnt mean it isnt important info. Text needs to appear here and now, not 1 second later, not 0.5 seconds later, not other window. Like the innovative approach though. Didnt think of it myself.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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