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.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Tips and tricks ➜ Alternating codes per letter in text

Alternating codes per letter in text

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


Posted by Meekah   USA  (16 posts)  Bio
Date Mon 24 May 2004 03:29 AM (UTC)
Message
I have tried to figure out how to do this but haven't succedded yet.

What I would like is an alias that would take the inputted text and output it with inserted color codes alternating per letter.

example:

alias input> say Hello, how are you?

alias output> say `OH`^e`Ol`^l`Oo`^, `Oh`^o`Ow `^a`Or`^e `Oy`^o`Ou`^?``

If anyone has any ideas on how to do this it would be much appreciated.

Thanks in advance

meekah
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #1 on Mon 31 May 2004 12:48 PM (UTC)

Amended on Mon 31 May 2004 01:04 PM (UTC) by Magnum

Message
Function PickColour (StrPosition)
	Dim StringPosition
	Dim PositionColour(2)
	PositionColour(1) = "'O"
	PositionColour(2) = "'^"
	StringPosition = StrPosition
	While StringPosition > UBound(PositionColour)
		StringPosition = StringPosition - UBound(PositionColour)
	Wend
	PickColour = PositionColour(StringPosition)
End Function

Function Colourize (SourceString)
	Dim TargetString
	Dim ColourCode
	Dim x
	TargetString = Empty
	For x = 1 to Len(SourceString)
		ColourCode = PickColour(x)
		TargetString = TargetString & ColourCode & Mid(SourceString, x, 1)
	Next
	Colourize = TargetString
End Function

Sub ColourSay (AliasName, AliasLine, ArrWildcards)
	World.LogSend "say " & Colourize(ArrWildcards(1))
End Sub

These sets of routines will do the job. Note: The routines will attempt to colour spaces as well. It would be too complicated to work around this.

You could colourize any string you want to send via other subroutines, simply by using the Colourize function. I wrote a simple alias if you only want to use this to "say" things. Here's the alias:
<aliases>
  <alias
   name="ColourSay"
   script="ColourSay"
   match="csay *"
   enabled="y"
   sequence="100"
  >
  </alias>
</aliases>
You could easily make these routines use more colours by editing the PickColour function. Simply increase the value of Dim PositionColour(2) to whatever number of colours you will be using, then add the appropriate PositionColour(#) = lines as needed.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Magnum   Canada  (580 posts)  Bio
Date Reply #2 on Mon 31 May 2004 01:08 PM (UTC)

Amended on Mon 31 May 2004 01:14 PM (UTC) by Magnum

Message
Ok, turns out testing for spaces wasn't so difficult afterall.

Here's a revised edition, with all of the relevant code quoted:
Function PickColour (StrPosition)
	Dim StringPosition
	Dim PositionColour(2)
	PositionColour(1) = "'O"
	PositionColour(2) = "'^"
	StringPosition = StrPosition
	While StringPosition > UBound(PositionColour)
		StringPosition = StringPosition - UBound(PositionColour)
	Wend
	PickColour = PositionColour(StringPosition)
End Function

Function Colourize (SourceString)
	Dim TargetString
	Dim ColourCode
	Dim CurrentChr
	Dim SpacesEncountered
	Dim x
	TargetString = Empty
	SpacesEncountered = 0
	For x = 1 to Len(SourceString)
		CurrentChr = Mid(SourceString, x, 1)
		If CurrentChr = Chr(32) Then                    ' Chr(32) is the space character.
			SpacesEncountered = SpacesEncountered + 1
			TargetString = TargetString & CurrentChr
		Else
			ColourCode = PickColour(x - SpacesEncountered)
			TargetString = TargetString & ColourCode & CurrentChr
		End If
	Next
	Colourize = TargetString
End Function

Sub ColourSay (AliasName, AliasLine, ArrWildcards)
	World.LogSend "say " & Colourize(ArrWildcards(1))
End Sub

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
Top

Posted by Meekah   USA  (16 posts)  Bio
Date Reply #3 on Tue 01 Jun 2004 06:18 PM (UTC)
Message
Works perfectly, thank you so much.
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.


16,251 views.

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.