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


Joined: 13 Jan 2008
Posts: 33
Location: Sweden

PostPosted: Sun Jan 13, 2008 1:32 am   

multi-line coloring trigger
 
Hello and welcome to my thread.

This is a problem that started out in zmud, I changed to cmud, and still couldn't find a way to solve it. I have tried a lot of things, wild experimenting, asking other people, and searching this forum. I have also been reading through a lot of guides, but nothing seems to work. Ok, so here is my problem.

I like things in order, which is why I have done a lot to hide things from my main window when mudding. Everything from channel/tells, to my own prompt and echoes. Now I want to color the attack messages that I do when attacking a ordinary monster. The message can look like this.

Fedaykin lets his guard down, and you instantly take advantage by chopping
mercilessly at Fedaykin's exposed weapon arm splattering gore and small
chunks of flesh!
(This is the linebreaks I get inside the mud)

Now, this is a fairly easy task to solve, coloring a multi-line message is doable in a lot of ways(I think), and I can even do it even though my knowledge in cmud is quite low. The problem arrives when the mobs name changes. When it does, the message may look like this.

Big frost giant lets his guard down, and you instantly take advantage by
chopping mercilessly at Fedaykin's exposed weapon arm splattering gore and
small chunks of flesh!

You see the difference right? Trying to trigger a static line is easy for me, but to trigger a line with changing words is a lot harder. I tried playing around with {chopping|mercilessly}, but came to a problem. What happens if there is a change that both of those word can appear on the same line, at the same time? I tried doing a double {chopping|mercilessly} which shouldn't work, and the test confirmed it. The need to trigger on something, and what happend when they cant?

So, at the last word on the first line can be chopping or chopping mercilessly. I am just stuck at the moment, not moving a single inch forward. So my question is if anyone have any experience with this. Either a multi-line coloring thing, or just a waste experience with commands like {chopping|mercilessly} and alike. Would appreciate it very much.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Jan 13, 2008 2:24 am   
 
I'm going to assume that you're using a multistate trigger for this (if you're not, you should). The ideal solution to this problem would be to turn off server-side word-wrapping and if it's not possible on your MUD, pester your admins until they make it possible. If all else fails, change to a MUD that lets you change its wrap column - this is the single most annoying thing about many MUDs and it causes many problems like this. I have no idea why so many of them add code to do it.

From a scripting perspective, all you can really do is use triggers that only match the part that'll definitely be on the next line, something like this:

#trig {lets his guard down, and you instantly take advantage} {#color red}
#cond {exposed weapon arm splattering gore} {#color red} {within|param=1}
#cond {of flesh!$} {#color red} {within|param=1}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
N86eAL
Novice


Joined: 13 Jan 2008
Posts: 33
Location: Sweden

PostPosted: Sun Jan 13, 2008 3:28 am   
 
Wouldn't removing word-rapping destroy the whole text layout of the mud? I need the mud to look like it does right now, or else I can't read at all. The mud have the option to increase the width of the text, we talked about that, but it wasn't a solution for me. Anyway, I started to look around for math-related functions in cmud, and found something quite interesting. I found %len. A way for me to calculate the length of a variable. This gave me the choice to to a comparison, between a variable, i.e a mobs name, and a numerical value.

I ran around fighting mobs with 2, 3, 4.....10 char long names, and saw what happend. I could group them into 1-3, 4-6, 7 and 8-10. These all created a different message. I created 4 different multistate triggers, each labeled from attack1 to attack4. When I attack a mob(with F1 to F4), cmud compares a variable @mob1-@mob4, with a numerical value 1-10. Then depending on which numerical value it is, cmud disables and enables the attack triggers, only leaving 1 trigger open. The correct on.

Now, I hate to ask for help and then solve it. But this solution feels way more complicated than it should. But maybe it is the only way to do it?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Jan 13, 2008 3:41 am   
 
CMUD has its own word-wrapping which you can set up to mimic your MUD's output, but the important thing is that triggers are checked before CMUD does its wrapping, not afterwards as in server-side wrapping. So turn off server wrapping and turn on client wrapping and you should be good.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
N86eAL
Novice


Joined: 13 Jan 2008
Posts: 33
Location: Sweden

PostPosted: Wed Jan 16, 2008 1:18 pm   
 
Ok, I have now solved the problem I had, and the solution was quite easy, like the one you did further up. All I had to do was this

#TRIGGER {Your solid hit impacts *} {#cw x}
#COND {* quickly take advantage *} {#cw x}
#COND {* to the head.} {#cw x}

Which would color the message that looks like this;

Your solid hit impacts Fedaykin with such force that he is thrown to the
ground and you quickly take advantage of his prone situation with a
well-placed boot to the head.

NOW, happy as I was, I started to color more messages, when I suddenyl had to do a quick halt. The message I wanted to color was this one;

Fedaykin howls in pain as he sees his lifeblood spewing
forth from the wounds and laughing cruelly you kick him where it hurts the
most.

Now, this wouldn't be a problem if the message itself was looking like that in the mud. No, instead it looks like this;

Fedaykin lets his guard down, and you instantly take advantage by chopping
mercilessly at Fedaykin's exposed weapon arm splattering gore and small
chunks of flesh! Fedaykin howls in pain as he sees his lifeblood spewing
forth from the wounds and laughing cruelly you kick him where it hurts the
most.

As you all can see, the message starts directly after the "chunks of flesh!" message. The first message is a ordinary one, where the "howls in pain" is more or less like a crit. They do not share the same color, so this is where the problems begin. Since Fedaykin is a mob, that word needs to be wildcarded, typically with a *, but this automaticlly triggers the whole line, of course. So when I color it, "chunks of flesh!" will get the wrong color. I want to color one line, in two different colors. I have tried a lot of things, but non have really succeeded. This is also the only message that looks like this, and as a kind of perfectionist, I hate seeing that message over and over again.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Jan 16, 2008 1:50 pm   
 
The answer is not to use * when you don't mean to. You don't actually want to match every character (mob names won't contain punctuation) so use a range instead of *, perhaps [A-Za-z ].
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
N86eAL
Novice


Joined: 13 Jan 2008
Posts: 33
Location: Sweden

PostPosted: Wed Jan 16, 2008 2:08 pm   
 
Yeah, that is true, but it doesn't solve my problem. Just changing the trigger for mob to [A-Za-z ] is a better choice(never knew about that one), but how do I trigger a line "chunks of flesh! Fedaykin howls in pain as he sees his lifeblood spewing", and only color the part with the mobs name and after? When the crit doesn't start on a new line, I need to trigger the flesh message first. Using a mult-line trigger solves that;

#TRIGGER {* flesh!} {#cw x}
#COND {[A-Za-z] howls in pain *} {#cw x} <---Don't know how to use it, but you understand right? :)
#COND {* and laughing cruelly *} {#cw x}
#COND {*most.} {#cw x}

Now, it will trigger on the last line of that first message, then continue to trigger on the crit message. The only problem is that the first #COND will override the color of #TRIGGER, or does [A-Za-z ] remove that chance, since flesh! has a exclamation mark at the end? Anyway, going to test it later, and see what I can do.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Wed Jan 16, 2008 2:17 pm   
 
[A-Za-z ] won't match the exclamation mark, no. But if you're using it the way you have there (I'd've thought the crit message would have its own trigger), the first state needs to be a reparse state so that the "flesh!" line will be searched for the "howls in pain" string.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
N86eAL
Novice


Joined: 13 Jan 2008
Posts: 33
Location: Sweden

PostPosted: Wed Jan 16, 2008 3:15 pm   
 
Ehm, it worked. I changed my trigger so it looked like this,

#TRIGGER {[A-Za-z] howls in pain *} {#cw x}
#COND {* and laughing cruelly *} {#cw x}
#COND {*most.} {#cw x}

And it worked. On a mob with a 8 character long name, and on a mob with a 4 character long name. No reparse, and it still works. Anyone care to describe why? :)
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