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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Dark Court Jester
Newbie


Joined: 20 Jun 2002
Posts: 8
Location: USA

PostPosted: Thu Jun 20, 2002 9:09 am   

Random Color for says/emotes
 
At this time I use multiple aliases and one control alias for random colored says. basically I have a sa0 through sa21 alias with the context of "emote says, '%-1'" each one with their own scheme. the alias sa is set as: sa%random(sa0,21)

My question is, is there a way to make this 'truly' random? I mean as in making a say alias and it emoting: says, '%-1' with each separate character(including the text replaced by %-1) choosing a random color? The mud I'll be running this on uses easy color with the & codes. &r &g &y &b &m &c &w &R &G &Y &B &M &C &W &K and &n is the terminating character.

"For those with wings, fly to your dreams"
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jun 20, 2002 11:54 am   
 
You need to create a loop that will place a random color code, then a character from the message, and continue doing this until there are no more characters. The script should be something like this:
#VAR colors {r|g|y|b|m|c|w|R|G|Y|B|M|C|W|K}
#ALIAS say {#VAR message "";#LOOP %len("%-1") {#VAR message %concat(@message, "&", %item(@colors, %random(1, %numitems(@colors))), %copy("%-1", %i, 1))};#VAR message %concat(@message, "&n");emote says, '@message'}

Kjata
Reply with quote
Dark Court Jester
Newbie


Joined: 20 Jun 2002
Posts: 8
Location: USA

PostPosted: Thu Jun 20, 2002 7:11 pm   
 
Thank You Kjata, works like a charm. Now I can do away with scheme's if I want. Thanks again.

"For those with wings, fly to your dreams"
Reply with quote
Dark Court Jester
Newbie


Joined: 20 Jun 2002
Posts: 8
Location: USA

PostPosted: Thu Jun 20, 2002 10:17 pm   
 
I did find one problem after using it. lower case color's: &r &g &y &b &m &c &w are 'dull' ansi colors. They need to be terminated with &n before the actual color code in order to be displayed correctly(ie. &n&rDark Red&n). My question is how do I fix it?

"For those with wings, fly to your dreams"
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jun 20, 2002 10:36 pm   
 
A quick, cheap fix is to change the variable with the colors so that it will work like this. The variable should then be:
#VAR colors {n&r|n&g|n&y|n&b|n&m|n&c|n&w|R|G|Y|B|M|C|W|K}

Kjata
Reply with quote
Dark Court Jester
Newbie


Joined: 20 Jun 2002
Posts: 8
Location: USA

PostPosted: Fri Jun 21, 2002 12:42 am   
 
Thanks again Kjata, I was spacing out when I tried fixing it on my own earlier... I was trying: r&n|g&n|y&n|b&n|m&n|c&n|w&n so basically I had it backwards. Oops =P

"For those with wings, fly to your dreams"
Reply with quote
Kyra
Newbie


Joined: 21 Jun 2002
Posts: 3
Location: Singapore

PostPosted: Fri Jun 21, 2002 12:58 pm   
 
Does this alias/variable only work for later versions of zmud(after 4.62)? If so is there any way to correct it to make it work for v4.62?

^_~
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sat Jun 22, 2002 7:44 pm   
 
I haven't used 4.62 in a very long time, so I wouldn't know if it works in that version. However, it should work as long as all the command and functions used in the script are available in 4.62

You would need to check for support for the following commands:
#VARIABLE
#ALIAS
#LOOP

and the following functions:
%len
%concat
%item
%random
%numitems

Some of these I'm sure are supported, but I included them in the list just for completeness. Of course, the quickest way of testing for support would be to type it all into zMUD and see if the alias works.

Kjata
Reply with quote
Kyra
Newbie


Joined: 21 Jun 2002
Posts: 3
Location: Singapore

PostPosted: Sun Jun 23, 2002 2:37 am   
 
Hmm.. i haven't checked whether those functions and commands are supported, but when i typed in the alias and variable, an infinite loop occured. A few messages of infinite loops occuring happens, then i emote saying @message. So i guess its the version..

^_~
Reply with quote
Apollyon
Wanderer


Joined: 02 Oct 2001
Posts: 76
Location: USA

PostPosted: Sat Dec 14, 2002 12:43 am   
 
i play on a mud where i use #alias cha {chat #s%-1} to chat
the #s creates a random color
is there i way i can use this to make every other letter a random color, instead of just the whole thing, i tried using the above script, but i keep messing it up

any help would be appreciated
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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