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
vortis
Novice


Joined: 15 Jul 2010
Posts: 39
Location: USA

PostPosted: Thu Feb 03, 2011 4:23 pm   

[Resolved] [3.33a] Simple trigger to add wording to the end of a MUD's output -
 
Let's say I see:

<room description here>

a bobbing bobcat (0.681)
a dagger

<exits line>


and I want to add something to the end of the a bobbing bobcat (0.681) so that it looks like this:

a bobbing bobcat (0.681) (This mob has a tendancy to flee)
or
a bobbing bobcat (0.681) *runner*
or
a bobbing bobcat (0.681) Runs
or something simple like that.

Is there a way to do a trigger like:

Trigger pattern: a bobbing bobcat
Trigger: #SAY This mob runs

but have the output on the same line, rather than using a #SAY on a seperate line?


Last edited by vortis on Thu Feb 03, 2011 6:52 pm; edited 1 time in total
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Thu Feb 03, 2011 6:21 pm   
 
#SUB the original line with your appended text.
_________________
Unwritten Legends
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Feb 03, 2011 6:35 pm   
 
Don't need #SUB, just use #SAYADD if it goes at the end of the line
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Feb 03, 2011 6:37 pm   
 
Much better way is to use the #SAYADD command.

Then you could do:

Code:
#TRIGGER {a bobbing bobcat} {#SAYADD { (This mob has a tendency to flee)}}
Reply with quote
vortis
Novice


Joined: 15 Jul 2010
Posts: 39
Location: USA

PostPosted: Thu Feb 03, 2011 6:46 pm   
 
Thanks. That helps a lot. Is there a way to change the color of the added text used by #SAYADD?
Reply with quote
vortis
Novice


Joined: 15 Jul 2010
Posts: 39
Location: USA

PostPosted: Thu Feb 03, 2011 6:51 pm   
 
Got it

#SAYADD %ansi(cyan)" *Runs*"

Let me know if there is a more appropriate method or if this is good.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Feb 03, 2011 7:29 pm   
 
#SAYADD {%concat( %ansi(cyan), " *Runs*")}

would be the most appropriate way to format it.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Thu Feb 03, 2011 8:03 pm   
 
You don't even need the %concat... #SAYADD {%ansi(cyan) *Runs*} works just as well. Remember, things in {} are counted as strings except for functions.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Thu Feb 03, 2011 8:13 pm   
 
I thought Zugg recommended against implicit concatenation?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
vortis
Novice


Joined: 15 Jul 2010
Posts: 39
Location: USA

PostPosted: Thu Feb 03, 2011 8:57 pm   
 
What is "concatenation", and what is it that the %concat function is doing?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Feb 03, 2011 9:12 pm   
 
Concatenation is essentially adding strings together. Yes, that is what the %concat() function does. When you put "A", "B", and "C" together to make "ABC", that is concatenation. Implicit concatenation is simply putting the pieces of string next to each other and hoping that Cmud interprets it correctly and builds them into the longer string you want. Explicit concatenation means using a function or command specifically designed to concatenate. %concat() is the concatenation function for Cmud. Implicit concatenation works much of the time in Cmud, but in some situations it doesn't work, and occasionally it works in a specific situation in one version, but not in a later upgrade. In general, explicit concatenation is safer, and guaranteed to work (guaranteed in the sense that, if it doesn't, it is a bug and will get fixed). Implicit concatenation should work in all of the printing commands like #SHOW, #PRINT, #ECHO, #SAYADD, etc., especially if enclosed in curly braces as Charneus suggested. I suspect most people would consider it a bug if it stopped working for those commands, and Zugg would probably agree. But Chamenas is correct that the strictest coding would use %concat().
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Feb 04, 2011 1:23 am   
 
In the matter of small scripts it is likely less important, since, if something breaks it's often easy to isolate. I often write larger scripts and scripts for other people, in which case I want to make the scripts as version proof as I can. If it works it works, but it doesn't hurt to begin such considerations so that if you ever "graduate" into something more complex you will be able to keep the code manageable.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
vortis
Novice


Joined: 15 Jul 2010
Posts: 39
Location: USA

PostPosted: Fri Feb 04, 2011 1:32 am   
 
Thank you for the help. I definately plan on 'graduating' as i go along, I just don't exactly know where to start. all I do right now are simple triggers, coloring outputs, setting variables and doing basic %IF functions to make things happen.

I want to get into the database variables and such, but I don't really know where to begin...
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Fri Feb 04, 2011 2:23 am   
 
Well, don't force it. The simple stuff is a good way to learn, eventually you'll run into problems where the only solutions require slightly more elegant ways of thinking about things. You'll get there. And, of course, simply reading about them in the helpfiles is always a good place to begin. Smile
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Martaigne
Wanderer


Joined: 05 Jan 2002
Posts: 88
Location: Atlanta, GA

PostPosted: Fri Feb 04, 2011 8:22 pm   
 
Wow, I just learned something new. Despite the complexity of my scripts, I've never run across 'sayadd' before.
_________________
Unwritten Legends
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