Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » Finished MUD Scripts
ccogdill
Beginner


Joined: 16 Jul 2002
Posts: 27

PostPosted: Thu Jul 25, 2002 7:13 pm   

Colored Text Say Command
 
I wrote this script to print out your say command as alternating colors, it is very flexible. If you want to alternate red, white, blue just change the scheme to your muds charecters. Also if your mud uses a different escape charecter for the ansi colors the one i play uses the left curly bracket {.



#VAR out ""
#VAR Scheme "Wx" // Change this string for your different colors
#VAR ESC "{" // escape charecter the mud uses the ansii colors
#VAR Count 0
#WHILE ( %len( "%-1")>=@Count) {
#VAR out %concat( @out, @ESC)
#VAR out %concat( @out, %copy( @Scheme, %mod( @Count, %len( @Scheme))+1, 1))
#VAR out %concat( @out, %copy( "%-1", @Count+1, 1))
#ADD Count 1
}
#VAR out %concat( @out, @ESC, "x") // x in the mud i play uses {x as it's terminator
' @out// ' is an alias in the mud for the say command. could shorten it to sa also

Enjoy
Reply with quote
typhonjr
Beginner


Joined: 12 Jul 2002
Posts: 11

PostPosted: Sat Aug 10, 2002 10:46 pm   
 
i must say this is an awsome scirpt saves alot of time for me :-p but theres something ive been trying... the mud that i play uses a seperate inline character to change form normal to intense and vice versa everythhing that i've tried so far hasnt worked and i was wondering if someone could help me out. thanx, typ
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat Mar 22, 2003 7:30 am   
 
I just created a COM Dll for a friend on the mud I play that does the same thing.
It iterates through the colour codes for each character that is not a whitespace character.
If anyone is interested I'd be willing to send ya the Dll or rather for safety's sake
I could send the source code.

typhonjr
if you explained what it was you wanted to do
and the syntax your mud uses I could adapt it for your use.

Dharkael
Reply with quote
typhonjr
Beginner


Joined: 12 Jul 2002
Posts: 11

PostPosted: Tue Mar 02, 2004 11:52 am   
 
lol ok posts are far between but pretty much the color code on the mud works liek this..
Basic colors:
|n|r red |n|y yellow |n|g green
|n|b blue |n|c cyan |n|m purple
|n|x black (black) |n|w ivory

Intense colors:
|i|r red |i|y yellow |i|g green
|i|b blue |i|c cyan |i|m pink
|i|x grey |i|w white

im trying to get a if statement workin but for some reason it just doesnt want to.. heres what i have so far.

#VAR out "|n"
#VAR Scheme "ggGG" // Change this string for your different colors
#VAR ESC "|" // escape charecter the mud uses the ansii colors
#VAR Count 0
#WHILE ( %len( "%-1")>=@Count) {
#VAR out %concat( @out, @ESC)
#VAR t %copy( @Scheme, %mod( @Count, %len( @Scheme))+1, 1)
#IF ( @t = %upper( @t) ) {#VAR out %concat( @out, "i|")}{#VAR out %concat( @out, "n|")}
#VAR out %concat( @out, @t)
#VAR out %concat( @out, %copy( "%-1", @Count+1, 1))
#ADD Count 1
}
#VAR out %concat( @out, @ESC, "x") // x in the mud i play uses {x as it's terminator
' @out // ' is an alias in the mud for the say command. could shorten it to sa also

the if statement just down work and i cant figure out why :(
thanks
-typ
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Mar 04, 2004 8:34 pm   
 
This forum is for posting finished scripts. Please use the zMUD General Discussion forum for your questions.
Reply with quote
Danlo
Magician


Joined: 28 Nov 2003
Posts: 309
Location: Australia

PostPosted: Sat Mar 20, 2004 6:46 pm   
 
Also, if you do a search on Coloring text aliases, you'll find that there are many many other such aliases already created and posted.

Don't reinvent the wheel, steal it from someone else.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat Apr 03, 2004 12:31 am   
 
Another member requested it so:
Well Here's another Wheel Implemented as JScript Windows Script Component.
Its Properties are
Colours: String with the colour characters desired no seperator eg. "ROYGBIV"

ByWord: Boolean value if true uses new colour with each Word,if false
does it for every word character

Random: Boolean value if true it randomly chooses a new colour every time it switches colours if false it iterates through the available colours then begins at the first colour again

Prefix: Character/String that indicates a colour sequence follows

ClearColour Character/String that used to reset colours to prevent bleeding.

ColourText: function that takes the text pased to it and returns the coloured String based on the config of the various properties.


Make sure you have Microsoft Windows Script Installed.
copy the source save it with .WSC extentsion eg. "Colourer.WSC"
right click on it and register it et voila!


Heres the source :

<?xml version="1.0" ?>
<package>

<component id="Colourer">
<?component error="true" debug="true" ?>
<registration progid="Colourer.WSC" classid="{BDF9F20A-A873-4725-9D06-685C0D2D2E34}" description="Colourer" version="1.0">
<script language="VBScript">
<![CDATA[
Function Register()
Dim TypeLib
Set TypeLib = CreateObject("Scriptlet.TypeLib")
TypeLib.AddURL "Colourer.WSC"
TypeLib.Path = "ColourerWSC.tlb"
TypeLib.Doc = "Colourer"
TypeLib.Name = "ColourerWSC.tlb"
TypeLib.MajorVersion = 1
TypeLib.MinorVersion = 0
TypeLib.Write
End Function

Function Unregister()

End Function

]]>
</script>
</registration>
<public>
<property name="Colours">
<get/>
<put/>
</property>
<property name="ByWord">
<get/>
<put/>
</property>
<property name="Random">
<get/>
<put/>
</property>
<property name="Prefix">
<get/>
<put/>
</property>
<property name="ClearColour">
<get/>
<put/>
</property>
<method name="ColourText">
<parameter name="txt"/>
</method>
</public>
<script id="Colourer" language="JScript">
<![CDATA[

/*var description = new Colourer;

function Colourer()
{
this.get_ClearColour = get_ClearColour;
this.put_ClearColour = put_ClearColour;
this.ColourText = ColourText;
this.get_Prefix = get_Prefix;
this.put_Prefix = put_Prefix;
this.get_Random = get_Random;
this.put_Random = put_Random;
this.get_ByWord = get_ByWord;
this.put_ByWord = put_ByWord;
this.get_Colours = get_Colours;
this.put_Colours = put_Colours;

}*/



var Colours = "cgnwyBCGMRWY".split("");//Default colours

function get_Colours()
{
return Colours.join("");
}

function put_Colours(newValue)
{
Colours = newValue.split("");
}

var ByWord = true;

function get_ByWord()
{
return ByWord;
}

function put_ByWord(newValue)
{
ByWord = newValue;
}

var Random = true;

function get_Random()
{
return Random;
}

function put_Random(newValue)
{
Random = newValue;
}

var Prefix = "&";

function get_Prefix()
{
return Prefix;
}

function put_Prefix(newValue)
{
Prefix = newValue;
}
var ClearColour = "n";

function get_ClearColour()
{
return ClearColour;
}

function put_ClearColour(newValue)
{
ClearColour = newValue;
}


function ColourText(txt)
{ txt = new String(txt);
var newTxt ="";
var c="";
var ls = new Boolean(true);
var prov = new CProvider(Colours,Random);
for(x=0;x<txt.length;x++)
{
c = txt.charAt(x);
w = isWhiteSpace(c);
if(w)
newTxt +=c;
else{
if(ByWord)
{
if(ls)
{
newTxt += Prefix+ prov.Next()+c;
}else{
newTxt += c;
}//ls
}else{//ByChar

newTxt += Prefix + prov.Next()+c;
}//ByWord
}//w
ls = w;
}//for
newTxt += Prefix + ClearColour;
return newTxt;
}




/* Nothing Below here is Visible to COM and are just helper objects/functions */

function CProvider(clrs,brnd)
{
this.Colours = clrs;
this.Random = brnd;
this.pos =0;
this.Next = function(){
var c ="";
if(this.Random)
{

var n= Math.round(Math.random()*(this.Colours.length-1));
c = this.Colours[n];

}else
{
c = this.Colours[this.pos];
this.pos++;
if(this.pos>=this.Colours.length)
this.pos=0;

}

return c;

}//Next

}//CProvider


function isWhiteSpace(c){
switch(c){

case 'n':
case 'r':
case ' ':
return (true);
break;
default:
return (false);
}
} //isWhiteSpace;
]]>
</script>
</component>
</package>






/* Sample Zmud usage
#ALIAS atconnect {InitMyColours}
#ALIAS myserial {#SS "JScript" var val =CurrentSession.GetVar("altcolour","");;CurrentSession.EchoStr(val.OlEVal.ColourText("%-1"),1);}
#ALIAS myrandom {#SS "JScript" var val =CurrentSession.GetVar("rndcolour","");;CurrentSession.EchoStr(val.OlEVal.ColourText("%-1"),1);}
#ALIAS InitMyColours {#VAR altcolour %comcreate( "Colourer.WSC");#VAR altcolour.Colours "cgnwyBCGMRWY";#VAR altcolour.Random 0;#VAR altcolour.ByWord 1;#VAR rndcolour %comcreate( "Colourer.WSC");#VAR rndcolour.Colours "cgnwyBCGMRWY";#VAR rndcolour.Random 1;#VAR rndcolour.ByWord 1}
#VAR altcolour {<OLE object: Colourer.WSC>}
#VAR myecho {}
#VAR rndcolour {<OLE object: Colourer.WSC>}
*/
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » Finished MUD Scripts 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