|
sheetan Beginner
Joined: 07 May 2007 Posts: 19
|
Posted: Thu Jun 07, 2007 12:56 pm
Random Coloring |
Hey,
I am having a problem setting up a random color trigger for says or tells....the colorcodes of my MUD are
$RED$ - red $HIR$ - pink
$GRN$ - green $HIG$ - light green
$YEL$ - orange $HIY$ - yellow
$BLU$ - dark blue $HIB$ - blue
$MAG$ - purple $HIM$ - magenta
$CYN$ - cyan $HIC$ - light blue
$HIK$ - grey $HIW$ - white
Also:
$0$ - normal, resets color
$BOLD$ - bold, usually white
Any help will be appreciated
Thanks alot |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Thu Jun 07, 2007 2:23 pm |
Most likely you'll need to treat $ as a symbol in trigger otherwise trigger will think it isn't. Something like
Code: |
#trigger {John sent you a tell.} {#echo ~$RED~$You just got a tell from John!!}
|
Perhaps thats something you're after.
Prog |
|
_________________ The Proud new owner of CMud.
--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
-------------------------------- |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Jun 07, 2007 2:45 pm |
I've never quite understood what it's for, but zMUD has a section in the preferences for setting the MUD's colour syntax. You may find this useful for something.
What you're probably looking for is something like this:
#var colours {"$RED$"|"$GRN$"|...etc...|"$HIW$"}
#function RandCol {%item(@colours,%random(14)}
Now whenever you want a random colour in your script, you just insert @RandCol instead.
say @{Randcol}Isn't @{RandCol}this @{RandCol}say @{RandCol}colourful?$0$
Once you've got this facility to choose a random colour, I'm sure you can think of plenty of applications for it. |
|
|
|
sheetan Beginner
Joined: 07 May 2007 Posts: 19
|
Posted: Thu Jun 07, 2007 7:46 pm |
Ok...it is working in commands like #ECHO or #SAY, but not in normal mud commands...I've tried to figure out the reason, but I don't see why
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Thu Jun 07, 2007 8:16 pm |
Do you have variables set to expand from the command line in preferences?
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Thu Jun 07, 2007 11:58 pm |
This is pretty much exactly what it's for, Fang. When properly filled out and enabled, it's supposed to see the color code and treat it the same as if it were something like MXP or ANSI (that is, as a user you just see the color and not the color code). The $BOLD$ looks like it might be unsupported in that framework, though.
Also, I don't play on nor have I visited muds that used such color codes so I don't know if any of it actually works. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Sat Jun 09, 2007 12:25 am |
It does, I've used it on FoxMUD before.
|
|
_________________ Taz :) |
|
|
|
sheetan Beginner
Joined: 07 May 2007 Posts: 19
|
Posted: Thu Jun 14, 2007 6:34 am |
Thanks alot...it's all working perfectly well!..and the zMUD colorcodes are awesome also...one last question, can I make it in a way where i simply type "colorsay" for example and the output would be..You say : bla bla bla
where every single letter is automatically undergoing the @{RandCol} ?
Thanks alot in advance |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Jun 14, 2007 10:44 am |
Ugh, you really want to annoy people :P
This one's a bit more difficult. I'm not at home so I haven't tested it, but hopefully you get the idea:
#alias colorsay {TempString="";#loop %len(%-1) {TempString=%concat(@TempString,%insert(@RandCol,%SUBSTRING(%-1,%eval(%i-1)),%i))};say @TempString}
I couldn't remember the function to take a substring between two numbers (if there's not one, you could make one with left and right (back)). |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Jun 14, 2007 1:45 pm |
I'm not either so this is also untested, but the ideas the thing right?:
Code: |
#alias colorsay {#var TempString %subregex(%-1,"(\w)","@RandCol")} |
|
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Jun 14, 2007 2:40 pm |
Yes, that's a much better idea. You need a less specific pattern though, and you don't need to quote @RandCol since the function returns a string. I'm pretty sure you need to include the capture in the replace, too, giving you something like
#alias colorsay {say %subregex(%-1,"[^ ]",%concat(@RandCol,%1))}
You might need to use %pat instead of %1. |
|
|
|
Dharkael Enchanter
Joined: 05 Mar 2003 Posts: 593 Location: Canada
|
Posted: Thu Jun 14, 2007 6:40 pm |
Code: |
#alias colorsay {say %subregex(%-1,"(\S)","%concat(@RandCol,%1)")}
|
Thanks Fang I missed the fact that I'd have to put %1 back into the replacement expression.
I'm not sure about the quotes because according to %subregex help in order to have a function etc evaluated for each substitution it should be in quotes
else it gets eval'ed only once.
And yeah for the pattern I guess one might want to colour a non word char, how about \S to get any non whitespace char?
Also does %pat exist for zMUD? I think its just a CMUD thing.
p.s. loving this double bracket to point to helpfile thing, thanks nexela |
|
_________________ -Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style." |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Jun 17, 2007 12:20 pm |
Sorry, I forgot this was a zMUD thread. Again
|
|
|
|
Thorr686 Newbie
Joined: 10 Sep 2008 Posts: 2
|
Posted: Wed Sep 10, 2008 5:17 am |
I need some help with this script, i use the same mud and i was trying to get this script to work and i dont know why it wont? i am having trouble with the first two parts, the setting of the variables and the setting of the function, i use zmud not cmud so any way you can help would be awesome
|
|
|
|
charneus Wizard
Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Wed Sep 10, 2008 8:00 am |
Dharkael wrote: |
p.s. loving this double bracket to point to helpfile thing, thanks nexela |
I'm curious to what this double bracket thing you're talking about is... there have been times I've wanted to point to helpfile for a poster, but didn't or couldn't be bothered to look up the helpfile address itself... from what you said, it sounds like if you do a double bracket, it automatically encodes the word with the helpfile text? Or am I missing something entirely?
Charneus |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Wed Sep 10, 2008 8:58 am |
Code: |
#var colours {"$RED$"|"$GRN$"|"$YEL$"|"$BLU$"|"$MAG$"|"$CYN$"|"$HIK$"|"$HIR$"|"$HIG$"|"$HIY$"|"$HIB$"|"$HIM$"|"$HIC$"|"$HIW$"}
#function RandCol {%item(@colours,%random(14)} |
Just copy and paste the above into the command line and press return that will set up the colours and the function.
Charneus: A little off topic but open square bracket open square bracket command/function close square bracket close square bracket [ [ %random ] ] %random |
|
_________________ Taz :) |
|
|
|
Thorr686 Newbie
Joined: 10 Sep 2008 Posts: 2
|
Posted: Thu Sep 11, 2008 6:52 am |
i copy and pasted that and the first part is working, the variable part but the function part isnt is says syntax error?
|
|
|
|
Rappy Wanderer
Joined: 15 Jul 2005 Posts: 96
|
Posted: Tue Sep 16, 2008 9:40 pm |
Quote: |
I'm curious to what this double bracket thing you're talking about is...
|
%subregex
-Rappy |
|
_________________ Windows 11 Pro,
cMUD 3.34 |
|
|
|
|
|