About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 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
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Thu May 22, 2008 5:17 pm   

[2.25] Text echoing and triggers
 
Are there any echo-like commands left that will not cause pattern-matching triggers to fire? I send informational messages to myself quite often and do not want to accidentally fire one of my triggers.

Code:
#TRIGGER {^(%w) command test$} {#SAY %concat("Trigger fired for: ", %1)};
#SAY "SAY command test";
#ECHO "ECHO command test";
#SHOW "SHOW command test"


Output:
=====
SAY command test
Trigger fired for: SAY
ECHO command test
Trigger fired for: ECHO
SHOW command test
Trigger fired for: SHOW

Well, I expected that only the last command will fire the trigger, but they all did... Confused
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu May 22, 2008 6:14 pm   
 
Not sure why you have triggers that match your information messages, but maybe try using #sayadd for them?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Thu May 22, 2008 6:20 pm   
 
Currently NO, if you show it on the screen. Then a trigger will fire off of it. The exception is commands that you have sent to the mud.
If you do not have an oninput trigger that matches it then you have bypassed all triggers.

I SUPPOSE that if you created an oninput trigger then set that to noinput you would in effect create what you want.

Another way around this is to set your trigger to NOT trigger on trigger.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu May 22, 2008 6:29 pm   
 
I guess it depends on what kind of information messages you are sending and how you are sending them. If you use sayadd from an anchored trigger, it isn't going to fire the trigger.

Example:

Code:
<trigger priority="10" id="1">
  <pattern>^This is a test.</pattern>
  <value>#sayadd { This is a test.}</value>
</trigger>
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Thu May 22, 2008 8:08 pm   
 
Thanks for you answers, guys.
I always thought that only text from the #SHOW command can fire off triggers, because it interpreted by CMUD as received from MUD, which is not the case for #SAY/#ECHO. So I didn't use #SHOW in my scripts.

I do not use messages to fire my triggers, only for information, just send them (messages) to a window when a job can't be done with #COLOR or buttons/statuses (various warnings and like, messages from aliases, etc.). That's why I don't like the idea when #SAY/#ECHO cause triggers firing - I have no easy way to put some text on the screen without put myself at risk to fool my own triggers. This just have no sense - there are #ONINPUT trigger and #SHOW command exists if someone want to fire triggers themself. Why add another two commands to this list? What then the difference between #SAY and #SHOW? Default text color? Confused
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri May 23, 2008 2:36 am   
 
As far as I can tell the difference between #SAY and #SHOW is that #SHOW is treated as an incoming packet. It is put through all the same processing that direct dat would be. #SAY only goes to the screen skipping many of the processing steps.

I would suggest that you do the same thing I do. Make a window named Debug, and then send your informational messages there with the #WINDOW command. I keep mine tabbed behind the main window so it uses the minimum continuous screen space. Since anything I display there indicates a major failure in my scripts it is likely I will be too busy to look at it immediately. The tab for the window will have a nice little icon until I look at it to figure out what went wrong.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Fri May 23, 2008 9:00 pm   
 
Thanks for your suggestion, Vijilante. I thought about this myself too, even have created a new Info window and then take a break for thinking. I already have Debug window for the very same purpose as you, but, unlike debug messages, informational messages can't wait until I review them later and, what is more important, they tied to text that comes from a MUD in the main window. About half of them will be meaningless in a separate window. Thats why sending text to the main screen was a simple solution.

Well, I understand that I have 2 possible ways: 1) continue #ECHOing and #SAYing messages to the screen and hope that carefully designed triggers will not be fooled, and 2) consider a serious script and layout redesign with additional window in mind.

Back to my original post, I was just surprised that CMUD, having so many tricky commands for text processing, does not have a simple command just for putting text to the screen... Eh...

Thanks to everyone once again for your input.
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri May 23, 2008 9:36 pm   
 
OK, I suppose I need to give an example of what I meant above.

First you make this trigger.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger type="Command Input" priority="10" trigontrig="false" regex="true" copy="yes">
    <pattern>^Tsay {(.*)}$</pattern>
    <value>#noinput
#say {%1}</value>
  </trigger>
</cmud>

Now to use this you would need to Unfortunately use the #send command within your script.
If you use the following trigger with the above in a blank session you can get an idea how it works using #Show.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger name="allt" priority="20" copy="yes">
    <pattern>(*)</pattern>
    <value>#send {tsay {%1}}</value>
  </trigger>
</cmud>

Anything that you #show on the screen will be echoed exactly once.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sat May 24, 2008 10:03 pm   
 
Sorry, Arminas, you system of 2 triggers will not work. You can suppress user (or #SEND) input echo with #NOINPUT, but you can't suppress #SHOW output, so you will get:
1) echo from #SHOW
2) echo from OnInput trigger

I thought about this possibility myself too and this solution have come first (only 1 trigger used):
Code:

<trigger type="Command Input" priority="10" trigontrig="false" stop="true" id="1">
  <pattern>^PRINT (*)$</pattern>
  <value>#NOINPUT;
         #SAY %1</value>
</trigger>


But again, basically my first post was a question (actually 2 questions): why CMUD does not have a command like #PRINT {text-to-print-on-screen} and why someone need to use #SAY if #SHOW can do all the same thing plus a bit more? I have read help and Vijilante's post, but I'm sure that most of CMUD users, if not all, do not use #SAY 1000 times per second, so these extra processing steps that take part with #SHOW, they can be ignored. Really, if you have 1 powerful command and 1 with moderate power and you use them occasionally, why do you ever need to use less powerful command?
Reply with quote
Nezic
Apprentice


Joined: 10 Oct 2000
Posts: 119
Location: Colorado

PostPosted: Sun May 25, 2008 4:12 am   
 
Quote:
Back to my original post, I was just surprised that CMUD, having so many tricky commands for text processing, does not have a simple command just for putting text to the screen... Eh...

I agree.. If there isn't a way to display text so that it explicitly won't be processed against triggers, it would make a great feature request.


I wonder about #SAY, however. Should text printed with #SAY actually cause triggers to fire?
The documentation for #SHOW says:
Quote:
The difference between #SAY and #SHOW is that #SHOW processes the text just as if it was received from the MUD. This means text for #SHOW must be in Telnet format, which means %crlf should be used for newlines instead of just %cr.

If it is intended for the text printed by both #SHOW and #SAY to be matched against triggers, why would you ever use one vs. the other? Is there some reason that using %crlf with #SHOW or just %cr with #SAY would matter in practice?

If not, then maybe #SAY, #SAYPROMPT, and #SAYADD text should be made to not match against triggers.


Also consider these documentation details:

Quote:
SHOW example

#SH You have @gold coins
Prints You have nnnn coins to the screen where nnnn is the current value of the @gold variable. Any trigger set up for this type of pattern will get triggered.

Quote:
SAY example

#SA You have @gold coins
Prints You have nnnn coins to the screen where nnnn is the current value of the @gold variable.


The example for #SHOW specifically mentions that triggers will match the outputted text, but the example for #SAY doesn't.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun May 25, 2008 5:47 am   
 
Urm, how does my example not work?

I tested it. It did exactly what you wanted it to do when I tested it. Not fire other triggers.

That being it did not cause other triggers to fire when it was used for saying to the screen.

I gave two triggers only so that you could see how it needed to be used inside of another trigger.
If triggers DID fire off of the text then my example would have been an infinite loop.
If you look at the oninput trigger it is creating a SAY command that does not affect triggers.

The (*) trigger is to show that it is in fact NOT affecting triggers.

If you want to try using the command by itself from the command line type "tsay {This text will not fire a trigger.}" after having created the second trigger.

So please actually try out and think about my example again.

I understand what you are talking about. I thought about it myself a long time ago.
Back in the ZMUD days there was much more difference between SAY and SHOW than there is today, I actually made a few references to it in some posts.
I'm not trying to answer why a command doesn't exist to bypass triggers already I agree that it is a good idea.
Still, my example does do what you asked for...

Edit: Bah, I re-read your post a few times. What the heck to you mean it don't work then you make a command doing basically the same thing???
I'll leave the above for clarity of my thoughts on the matter if nothing else.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sun May 25, 2008 7:26 am   
 
This is a quick answer for Arminas about 2 triggers, I'll get back to this discussion a bit later.

Arminas wrote:
Anything that you #show on the screen will be echoed exactly once.

I did try it, Arminas. Do not think that I answered you without trying. It is not the triggers fire off the text but CMUD execute zScript commands, so there are no infinite loops.

Here what I see in the untitled session with your 2 triggers:

CmdLine: #SHOW test
test
test
CmdLine: #SHOW only once?
only once?
only once?

You see, when you type "#SHOW test", CMUD firstly executes #SHOW command and after that fires the trigger. Then your second trigger comes to work, which do #SEND #SAY..., resulting in second echo.
Code:
0.0007 | c  untitled |  [1] untitled Comline : start :
0.0014 | a  untitled |test
0.0002 | f  untitled |    Pattern: (*) : (%1="test")
0.0008 | c  untitled |    exec : Pattern "allt" : #send {tsay {%1}}
0.0003 | f  untitled |    Command Input: ^Tsay {(.*)}$ : (%1="test")
0.0009 | c  untitled |    exec : Command Input "^Tsay {(.*)}$" : #noinput#say {%1}
0.0003 | a  untitled |test
0.0006 | d  untitled |  [1] untitled Comline : stopped


And personally I don't like the "(*)"-only patterns...

Keeping things simple, I could use my own trigger shown in my post above, if I finally will decide to use trigger-safe text output. Plus I think that it can be adopted for multi-window use easily. But now my interest is rather academic. Wink

EDITED: spelling... Embarassed


Last edited by Arde on Sun May 25, 2008 8:43 am; edited 2 times in total
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun May 25, 2008 8:42 am   
 
OK, you STILL do not get the point...

YES if you type #SHOW test into the command line it will show up on the screen twice.... It is supposed to. This is the TEST case for the (*) trigger to prove that there is not an infinite loop.
The #SHOW is showing once, the (*) test trigger is using tsay to echo it once, so you see it TWICE on the screen. It is being echoed exactly once.

The (*) trigger should NOT be used in your real session...

If you want to place stuff onto the screen without it being shown twice or echoed by triggers then you type

tsay {Stuff I want on the screen only once here. triggers will not affect this text.}

So in your triggers or aliases or whatever you would use.
#send {tsay {Stuff I want on the screen only once here. triggers will not affect this text.}}

This is another reason I gave you the test trigger. To show you the syntax needed.

Again, the trigger that you made is virtually identical to the one that I made. So I know you do understand the concept.
Yes I knew that the debugger would show that it had executed a trigger. But your OTHER triggers are all safe from the text.

Yes, I'm going to stop beating the dead mule now.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sun May 25, 2008 8:53 am   
 
Sorry, I misunderstood you, Arminas. I thought you want me to use #SHOW with triggers... Embarassed Using solo OnInput trigger is trivial thing, so I thought about it myself as you did, before even I started this thread. And your reply
Quote:
Back in the ZMUD days there was much more difference between SAY and SHOW than there is today,
tell me more than all triggers examples: I'd miss this change and was not aware.
Thank you again! Smile

Btw, what was the reason to change #SAY behavior in the past?
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun May 25, 2008 9:08 am   
 
It is nearly 4 AM here now. So I'm not gonna bother looking up my old posts.

Some stuff though.

#show was placed at the end of the incoming text buffer. This meant that if you echoed on a line of incoming text, your #show was placed at the end of the buffer. Example follows.

#trigger {There are %w killer-bee nests here.} {#show {%ansi(blink)Run away bees will kill you.%ansi(reset)}}

You enter the room and receive a hug buffer of text.

blah blah blah blah
blah blah blah blah
blah blah blah blah
blah blah blah blah
There are two killer-bee nests here.
blah blah blah blah
blah blah blah blah
blah blah blah blah
Pretend this is several pages worth of stuff.

With show it would end up at the end of the pages of text.
With say it would be directly under the line that triggered it.

I'll throw in echo here too. Echo did and still does go to whichever window last had activity. But it otherwise is the same as Say.

This is the most striking difference and the one that comes to mind. Besides the text color and the fact that it is not being treated as if it is coming from the mud.
I don't recall am not sure and Ain't gonna test it tonight but, I'm pretty sure I have been able to send myself MXP with Show, never tried it with Say that I can recall but I don't think it will work.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Mon May 26, 2008 4:33 pm   
 
Ok, I'm back for discussion... but apparently there is nothing more to discuss. Wink

Arminas wrote:
#show was placed at the end of the incoming text buffer. This meant that if you echoed on a line of incoming text, your #show was placed at the end of the buffer.

...skipped...

With show it would end up at the end of the pages of text.
With say it would be directly under the line that triggered it.

It is definitely one of the reasons to have 2 different commands with _almost_ similar functions at the first glance. Hmm... Never thought about this.
May be it is not a bad idea indeed to make request for a new command (#PRINT? What other words are not used yet?) which will only evaluates its parameters and send them to the screen the same way as #SAY does?
Reply with quote
Zugg
MASTER


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

PostPosted: Wed May 28, 2008 8:01 pm   
 
I think the suggestion to have a command that displays text without firing triggers is a good one. I think zMUD might have had an option for this, but it was global and not very useful. In the original CMUD rewrite, I had #SAY and #ECHO *not* firing triggers, but that caused too much compatibility problems, so I changed it back to how it was in zMUD.

In general, try to avoid using #SHOW in your scripts. This stuffs the text into the network buffer and treats it as text received from the MUD and can cause potential interference with the real MUD text (such as if there is a packet boundary in an ATCP message from the MUD, or something like that). I use #SHOW a lot for internal testing, but user scripts should really use #SAY/#ECHO instead.

Anyway, I think #PRINT is a useful idea and I'll add that to the wish-list for a future version.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Aug 09, 2008 10:56 am   
 
I just noticed today you had added #PRINT.

I wondered what the speed differences were between echoing text to screen.

The results to loop through, read, and display 3,371 full lines of text line by line.

Method Time
---------------------------------------------

Round 1

#echo 11875 ms
#sayp 11936 ms
#show 11973 ms
#echop 12353 ms
#print 12598 ms
#say 13285 ms
#sayadd 14976 ms

Round 2

#echop 11785 ms
#echo 11868 ms
#say 11883 ms
#sayp 11926 ms
#show 11945 ms
#print 11951 ms
#sayadd 15231 ms

Round 3

#print 11788 ms
#sayp 11890 ms
#show 12292 ms
#echop 12392 ms
#echo 12455 ms
#say 12609 ms
#sayadd 15761 ms

Round 4

#echop 11778 ms
#print 11788 ms
#echo 11842 ms
#say 11879 ms
#sayp 11888 ms
#show 11933 ms
#sayadd 15001 ms

Round 5

#echop 11772 ms
#print 11809 ms
#show 11938 ms
#echo 12200 ms
#say 12623 ms
#sayp 12674 ms
#sayadd 15009 ms


Shouldn't one of these ALWAYS come out on top? I thought using #print would be much faster? Obviously #sayadd always comes out on bottom.
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