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
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Fri Apr 13, 2012 2:27 pm   

Random Colors in a Message
 
Hello,

I have something a little challenging. I'm not used to coding very much, and I don't know where to begin.

My mud has a color selection for different commands/functions. For example, when in combat you can set a specific color to what is offered from the list of colors my mud allows us to use.

We also can color each and every individual letter in our 'shout' command for everyone chatting on the shout line, or on the 'tell' line etc... But to color everyone of the individual letters manually makes it very long, and tedious typing.

My mud used to have the random colors command, but in time for some reason it was taken down.

Can I make it so that Zmud loads a random selection of colors offered by mud into the chat commands?

My mud uses these selection to 'color' the letter:

blue green red orange cyan magenta yellow and white

We also can use 'bold' to make the letters very bright.

They also use special symbols we must type for every individual 'color' and 'bold', the percentage (%) and the carot (^). They are used together like this as a pair %^ before and after each color.

If I wanted to color a message with individually different colors, I should type something like this:
shout %^RED%^H%^ORANGE%^E%^YELLOW%^L%^GREEN%^L%^BLUE%^O%^MAGENTA%^%^RESET%^. (RESET makes it so that it returns back to the normal color in the mud, and the rest of the title,command is naturally white, and not the last color of the string, which would have been magenta)

Ok, so you see that I had to type it individually, and it's a pre-set selected colors. That pattern will always be the same if i keep on hitting 'enter'. Is there a way to have Zmud load a different selection randomly every time I use a specific command?

If this is too complicated, plz say so ;)

THANK YOU!!!
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Tue Apr 17, 2012 6:31 am   
 
so there nothing of a random input function, or command that can be used to make random colors in a message?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Tue Apr 17, 2012 2:06 pm   
 
There is a way to do it, but it wont look pretty.
Take a look at #HELP %random
_________________
Discord: Shalimarwildcat
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Wed Apr 25, 2012 9:42 am   
 
Hi,

Thank you shalimar! ill have read it now,
im trying to figure out how the 5,8 fits into the picture.

Is there any who could tell me how the (5,8) works?


random

Syntax: %random(i,j)

return a random integer >= I and <= J. If J is omitted, then I specifies the maximum value, and 0 is used as the minimum value.
Examples:

#VAR dirList {n|e|s|w|ne|se|sw|nw|u|d}

#20 {%item(@dirList,%random(5,8))}

sends 20 randomized diagonal directions to the mud.
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Wed Apr 25, 2012 12:00 pm   
 
Ok, I think i got it. Could someone tell me if I am wrong? The (5,8) means ne and nw? Just my assumption. Laughing
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4672
Location: Pensacola, FL, USA

PostPosted: Wed Apr 25, 2012 2:50 pm   
 
It means it will randomly pick a number between 5-8.
And then retrieve the nth string from your string list.

that example will only ever pick from: ne|se|sw|nw


You want to make a list of @colors

%item(@colors, %random(1, %numitems(@colors)))

would be a random color from the entire list
_________________
Discord: Shalimarwildcat
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Wed Apr 25, 2012 9:54 pm   
 
Wow, a response, thanks!

So I would need to make variable list 1st which would look like this:

#VAR ColorList {%^BLUE%^|%^GREEN%^|%^RED%^|%^ORANGE%^|%^CYAN%^|%^MAGENTA%^|%^YELLOW%^|%^WHITE%^|%^BOLD%^%^BLUE%^|%^BOLD%^%^GREEN%^|%^BOLD%^%^RED%^|%^BOLD%^%^ORANGE%^|%^BOLD%^%^CYAN%^|%^BOLD%^%^MAGENTA%^|%^BOLD%^%^YELLOW%^|%^BOLD%^%^WHITE%^}

Then the random string:

%item(@ColorList, %random(1, %numitems(@colors)))

and the 1 means to select 1 only from the entire list, I'm assume Very Happy

And to use that within a 'tell' or a 'shout' command and for the letters in the sentence to be randomly colored would be this:

#AL ctell %item(@ColorList, %random(1, %numitems(@colors)))
#AL cshout %item(@ColorList, %random(1, %numitems(@colors)))

Am I right, or does something else need to be added? Anyone? Very Happy
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Thu Apr 26, 2012 7:46 am   
 
ok, i guess I'm sorta on the right track. Sorta.
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Thu Apr 26, 2012 1:15 pm   
 
I think I got it. What I need is a trigger from zmud to load as I type, so the random color is selected and placed BEFORE the individual letter as I type the message. Then when I hit enter, the color will load into the letter.

Does Zmud have a function/trigger for this?
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Thu Apr 26, 2012 1:19 pm   
 
I'll read the #HELP #TRIGGER section ;)
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Thu Apr 26, 2012 5:10 pm   
 
all of these ideas come FROM the mud as it is received. I want Zmud to SEND it when I type a certain command, such as 'say' then have Zmud start loading a color variable list I've already made for the selection.

Anyone have any sugg's?
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Thu Apr 26, 2012 9:19 pm   
 
Thanks to Shalimar, I was able to get most of it. There was only a little change that needed to be done.

And to think it could not have been done Razz

Here is Shalimar's pure genius string:


%item(@colors, %random(1, %numitems(@colors)))


What I added was after the 1 was the number 16 with the comma(not sure what the comma's function is, BUT HEY IT WORKED! I tried different symbols, not having the experience and lack of study time to understand how things work since this is my first time to try coding. You can tell by the previous messages.)


say %item( @ColorList, (%random( 1, 16, %numitems@LttrList)))



So now it colors the entire sentence, how or WHAT do I add for it to do the letters individually? Shalimar, got any sugg's? Very Happy Or anyone else out there willing to take a shot at it? PLZ PLZ PLZ PRETTY PLZ Very Happy
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Thu Apr 26, 2012 9:25 pm   
 
I'll try the #NUMBER function since it was a part of the help file's example, you know that #20 next to those funny curvey brackets.(Which I studied, btw)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Apr 26, 2012 10:01 pm   
 
Code:
#LOOP 1,%len(%1) {
  ColoredSpeech = %concat(@Colorspeech,%item(@ColorList,%random(1,16)),%copy(%1,%i,1))
}


I don't remember if %copy() is a zmud-era function or not, so if it's not then you need to replace %copy(...) with the equivalent %right()/%left()/%rightback()/%leftback() combination.
_________________
EDIT: I didn't like my old signature
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Sat Apr 28, 2012 7:56 am   
 
Hello!

Thank you Mattlofton for that EXCELLENT SCRIPT! Very Happy

I tried many different variations tho, and many of them came up with this one result.

Here is what I changed from the above code:

#LOOP 1,%len( %1) {say = %concat( @say, %item( @ColorList, %random( 1, 16)), %copy( %1, %i, 1))}

MattLofton was able to understand very clearly what I said, because I do get random colors for EVERY letter that I typed for the say command.

Where it was sent, however, was into the @say variable, with no spaces after say in the @say variable.

So, here is one of the actual results after I tinkered around with it:

say%^BOLD%^%^YELLOW%^m%^BOLD%^%^RED%^u%^BLUE%^l%^WHITE%^t%^MAGENTA%^i%^BOLD%^%^MAGENTA%^c%^BOLD%^%^YELLOW%^o%^GREEN%^l%^BOLD%^%^GREEN%^o%^BOLD%^%^YELLOW%^r%^BOLD%^%^BLUE%^s

The intent was to 'say multicolors' with all of those letters being diff colors and then being sent to the mud. Instead it was sent to the @say variable where @say = say. the 'say' command on my mud needs a space in order for it to be understood as a say command.

Does anyone know or understand where I went wrong, because I did change the verbage around a little bit in order to fit how I THOUGHT it would work.
Could someone please help me where I went wrong? I've tried many times to use different ideas that i've had, but nothing worked.

THANK YOU!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Apr 28, 2012 6:50 pm   
 
1)make sure the say variable is empty
2)after the loop put "say @say". This will cause the alias to send the SAY command to the game, using the now already-colored contents of the @say variable (ZMud has no way to do what you were asking directly, because there's no form of temporary storage).
_________________
EDIT: I didn't like my old signature
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Sat Apr 28, 2012 8:12 pm   
 
How can I get the @say value to empty out? Here is what I have after your post:

#LOOP 1,%len( %1) {say = %concat( @say, %item( @ColorList, %random( 1, 16)), %copy( %1, %i, 1))}
say @say


I did try @say = 0, but that didn't work. I guess I could delete @say and then recreate it, making the value empty for another say.

Wow, thnx for the help, this is fun!
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Apr 28, 2012 8:23 pm   
 
say = ""
_________________
EDIT: I didn't like my old signature
Reply with quote
lionsroar777
Beginner


Joined: 31 Jan 2012
Posts: 17

PostPosted: Sun Apr 29, 2012 10:45 pm   
 
Hi,

I've often heard from my friends that they like repairing computers, or solving some problem with a code because the solution was most likely one that they have not done before. Which makes it interesting, well I think so anyhow. Cool

Ok, so now I have this brilliant string for showing random colors. And when I type a sentence only the 1st word is entered. I hit enter again and the 1st word is randomly colored and is now the last word of the sentence.

Ex:

rcsay Hello, how are you?

Result (which is sorta cool imo): You say, 'hhehelhellhello'

I think that it's the comma because without the comma i get this:

You say, 'hello'

I hit the enter once more and get:

You say, ' how are you?hello'

Also, I am learning code as I do this, which any help is fun and useful!

Thank you guys for your help so far!
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