Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ General ➜ Sending Alternate text colours per word to the mud...

Sending Alternate text colours per word to the mud...

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by David Berthiaume   (202 posts)  Bio
Date Wed 20 Apr 2005 06:07 AM (UTC)
Message
All right, What I'd like to do is send every other word in says, IC, and yells varying colours.

So, the ansi codes are:

^o - Light Black, A.K.A Dark Gray
^W - Bright White
^^ - Normal Text: Light Grey

I'd like to change each word a different colour.

First word, Bright White, then Light Grey, Then Dark Grey, then repeated per word.

I don't even know if this is possible, or what one would have to do to accomplish this.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Wed 20 Apr 2005 06:23 AM (UTC)
Message
<aliases>
<alias
match="^(say|ic|yell)( \w.*\w)+.*$"
enabled="y"
echo_alias="y"
regexp="y"
ignore_case="y"
keep_evaluating="y"
sequence="100"
>
<send>%1 [the words, colorized]</send>
</alias>
</aliases>

That will capture it, what script language are we using? Since I'd hate to code it and then have it be the wrong one.
That regexp can be tweaked to suit needs (like getting rid of the leading space, but then it'd be every second wildcard, etc) but that too depends on the script routine. So, what are we coding it in?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #2 on Wed 20 Apr 2005 06:25 AM (UTC)
Message
Coding in VBscript right now. I learned on it, and I know it more than I know Lua... Hard to switch over when you've had a couple of computer crashes to contend with and lose a lot of stuff.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #3 on Wed 20 Apr 2005 06:35 AM (UTC)
Message
The saddest part about all of this. When I see the code, I'm gonna be like. DAMN: I shoulda known that!
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #4 on Wed 20 Apr 2005 06:52 AM (UTC)

Amended on Wed 20 Apr 2005 06:55 AM (UTC) by Flannel

Message
Actually, that regexp was wrong, since, the \ws should have been \bs, and the space infront is now going to be \s+
Im worried about hyphenated words, but I think that setup should work.
New regexp becomes:
^(say|ic|yell)([ \t]+\b.*\b)+.*$

And we're going to be using a script file (because cycling through an array is much easier than trying to figure out how many wildcards we have inside the trigger).

And this could still all change (the regexp will probably change at least once more, just for fun).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #5 on Wed 20 Apr 2005 06:55 AM (UTC)

Amended on Wed 20 Apr 2005 07:03 AM (UTC) by David Berthiaume

Message
Something however seems to be missing...

Type: say Blah blah

Output: You say '[the words, colorized]'

Unless you haven't put up the code that is the words and colorized... Did I miss something?


EDIT: Oh yeah, additionally... There is also sayto <name> <string>

That'll probably have to be a seperate alias, which is fine, and should be easy enough to make once I have the script itself. It's just adding in another wildcard, no biggie
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #6 on Wed 20 Apr 2005 07:32 AM (UTC)
Message
Yeah, that trigger was script-less, it was just the trigger. I figured I might as well post that, since I needed to ask you what language anyway.

This is what I have thus far for the script (obviously it doesn't work).
The problem (as far as I can tell) is the trigger. Since it's not returning one word per wildcard. The commented lines (at the beginning) should (once everything works correctly) have one word per line.
I'm going to reread some of the basics of MC and scripts, since obviously I'm forgetting something (there are always 10 array pieces passed, regardless of how many wildcards there actually are?).
If that's true, then it looks like doing it via send to script may end up being more convenient (and feasible) anyway.


Option Explicit

Sub colorize (sName, sLine, aryWild)
  dim size
  dim Colored
  dim codes
'DEBUG TRIGGER
'  for i = LBound(aryWild) to UBound(aryWild)
'    note i & ": " & aryWild(i)
'  next
  
  codes = Array("^o","^W","^^") 'color codes
  size = UBound(aryWild) '1+3X+1?
  'except its length-1, so we dont need to 
  'subtract the 1 for the say/ic/yell
  Colored = aryWild(1)
  dim i
  For i = 2 to size Step 3
    'aryWild(i) whole thing
    'aryWild(i+1) whitespace
    'aryWild(i+2) word
    Colored = Colored & aryWild(i+1)
    Colored = Colored & codes(((i-1) mod 9)/(UBound(codes)+1))
    'append the color code (i-1) mod 9 is 0,3,6
    'divided by codes length (Ubound + 1) gives a corresponding
    'array element (0,1,2), this way you can simply change the
    'codes aray and not have to change anything else
    Colored = Colored & aryWild(i+2) 'append word
  Next
  Colored = Colored & aryWild(size) 'last bit
  
  Send Colored 'can't forget this
End Sub

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #7 on Fri 22 Apr 2005 12:47 AM (UTC)

Amended on Fri 22 Apr 2005 01:33 AM (UTC) by David Berthiaume

Message
Something similar, I think what we're missing in this particular case is the split command...
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
     for i=lbound (AutoCombo ) to ubound (AutoCombo )
      Select Case AutoCombo (i)
       case "rp" attack = "punch right"
       case "lp" attack = "punch left"
       case "s" attack = "sweep"
       case "r" attack = "roundhouse"
       case else attack = "" ' unknown attack type
      End Select
  if i = ubound (AutoCombo ) then
  world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #8 on Fri 22 Apr 2005 12:55 AM (UTC)

Amended on Fri 22 Apr 2005 01:20 AM (UTC) by David Berthiaume

Message
Did a little experimenting on my own with this. I don't know if it'll help. But here's what I got.

Sub colorize (sName, sLine, aryWild)
dim string, i
string = split (aryWild(1))
  for i = LBound(string) to UBound(string)
    note i & ": " & string(i)
  next

End Sub
Hope this helps a little bit atleast.


I searched the forums for one of my OLD postings with Autocombo. I knew that Lbound and Ubound were going to come into play with this, it was the rest I wasn't sure about. When you didn't put a split in there, it got me to thinking about the autocombo script Nick helped me write. I started fiddling with it. and I got it to note properly, I just do not know how to incorperate the split into the rest of your code you put up there. I think once that is done it will work very well.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #9 on Fri 22 Apr 2005 03:32 AM (UTC)
Message
Ok, more playing around with
Sub colorize3 (sName, sLine, aryWild)
  dim size
  dim Colored
  dim codes
  dim string
string = split(aryWild(2))
  for i = LBound(string) to UBound(string)
  next
  
  codes = Array("^o","^W","^^")
  size = UBound(string) '1+3X+1?
  Colored = aryWild(1)
  dim i
  For i = 2 to size Step 3
    Colored = Colored & aryWild(i+1)
    Colored = Colored & codes(((i-1) mod 9)/(UBound(codes)+1))
    Colored = Colored & aryWild(i+2) 'append word
next
  Colored = Colored & arywild(2) 'last bit
  
  Note Colored 
End Sub


Still not working right. But getting closer.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #10 on Fri 22 Apr 2005 05:06 AM (UTC)

Amended on Fri 22 Apr 2005 05:08 AM (UTC) by David Berthiaume

Message
All righty... Got it working... Sorta...
Sub colorize3 (sName, sLine, aryWild)
dim size, Colored, codes, string
string = split(aryWild(2))
  for i = LBound(string) to UBound(string)
  next  
  codes = Array("^o","^W","^^") 'color codes
for i = LBound(codes) to UBound(codes)
next
  size = UBound(string) '1+3X+1?
  'except its length-1, so we dont need to 
  'subtract the 1 for the say/ic/yell
  Colored = aryWild(1)

  dim i
  For i = 1 to size Step 1
    Colored = Colored & " " & codes(((i-2) mod 7)/(UBound(codes)+1)) & string(i)
  Next
 Send Colored
  
End Sub
The problem as you'll see when you use it. It won't change every other word. Perhaps you can figure out where the error in the step is. I dunno. It's doing something funky, I don't understand that whole mod thing. That's probably where my error is. But I got it semi-working. More than it was before.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #11 on Fri 22 Apr 2005 10:19 AM (UTC)
Message
Been working on this a LONG LONG time... Much more difficult this is, then I realized. I'll give an update later.

From what I've found out, Mod doesn't work as well as we hoped it would.
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #12 on Fri 22 Apr 2005 02:46 PM (UTC)
Message
Final Working Code. Thanks to my friend Nomad who helped me out
Sub colorize3 (sName, sLine, aryWild)
dim size, Colored, codes, String, i, x
Colored = aryWild(1)
string = split(aryWild(2))
  for x = LBound(string) to UBound(string)
  	next  
Size = UBound(string)
codes = Array("^W","^^","^o")
		for i = LBound(codes) to UBound(codes)
			Next
  For i = 1 to size Step 1
    Colored = Colored & " " & codes((i-1) mod (UBound(codes)+1)) & string(i)
  Next
	Colored = Colored & "^^"
send Colored 
End Sub
Top

Posted by David Berthiaume   (202 posts)  Bio
Date Reply #13 on Mon 25 Apr 2005 08:14 PM (UTC)
Message
Not sure on how to make this next alias work.

I got the say, ic, yell alias fine.

I need an alias that does:
sayto (characters name) (string)
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #14 on Mon 25 Apr 2005 08:31 PM (UTC)

Amended on Mon 25 Apr 2005 08:33 PM (UTC) by Flannel

Message
All you're doing is making the beginning thing different. You could reuse the script and just join the first and second thing (instead of ic the first thing is "sayto bob") in the script and then sent to the colorize routine.

Why do you have empty fors? You have two:
for x = LBound(string) to UBound(string)
next
and another with i, that do absolutely nothing.

You could change your colorize code to be a subroutine that doesn't send, and that doesn't worry about anything except coloring, then you could handle the specific i/o (including the prefix) outside of the colorize sub.
I guess a function would be easiest, since then you could return the string.
Actually, if you're going to do that, having the function itself figure out the splitting stuff might be best (pass it a string, it tokenizes it, adds color codes, and returns the new string).
Then you could use it whenever you wanted, in whatever context you wanted.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


68,782 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.