Create an account


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to output (rainbow) colored text?

#1
Hello,
I wondered which category is better to post, general or here but I post here.

I sometimes see the players who type rainbow colored text(chat). So I asked him how to do that, and told me he uses perl(or PHP? I don't remember exactly) script to do that.

I searched about it on Google and found something which might be related:

http://www.krazydad.com/makecolors.php
http://hg.gewt.net/irssi-config/file/dc0...rainbow.pl

but still I can't solve...

Does anyone know how to output rainbow colored text(references or the way to do)?

Thanks.
Reply

#2
They be trollin. It's voodoo magic and custom engine builds.

Reply

#3
Instructions are here.

No no no. Nothing there to see... (I don't remember typing this) Big Grin
Reply

#4
Nexuiz used to have a client command that gave you either 'pirate' or rainbow text. I don't know if the same function still exists in Xonotic or if the function uses the same passphrase. Sadly I'm not at liberty to divulge the Nexuiz phrases.

The basic command was
PHP Code:
cl_cmd FOO say Hello world 
You could make a simple alias
PHP Code:
alias rainbow "cl_cmd FOO say $*"
alias pirate "cl_cmd BAR say $*" 
and then use
PHP Code:
rainbow Hello world
pirate Look at me 

You need to replace FOO and BAR with the correct codes.

Peace my Brothers
Reply

#5
I am using this:

Code:
alias spam "menu_cmd curl --exec --key 0 http://rm.sudo.rm-f.org/~xonotic/spam/spam.php cmd \"$1\" text \"${2- q}\""
alias spammessagemode2 "commandmode spam say_team"
alias spammessagemode "commandmode spam say"

However, without having the right player ID, you won't have a chance to get a reply from that script.

The rainbow coloring itself is:

Code:
function rainbow($s)
{
        $s = decolorize($s);
        $s2 = "";

        $n = mb_strlen($s);
        $j = ((6 * max(1, floor($n/$CONSTANT + rand() / getrandmax() * 2 - 1))) / $n) * (1 - 2 * (rand(0, 1)));
        $f = rand() / getrandmax() * 6;
        $p = 0;

        for($i = 0; $i < $n; ++$i)
        {
                $c = mb_substr($s, $i, 1);
                if($c == "^")
                {
                        $c = "^^";
                        if(mb_substr($s, $i+1, 1) == "^")
                                ++$i;
                }
                if($c != " ")
                {
                        list($r, $g, $b) = ......;
                        $c = rgb_to_hexcolor($r, $g, $b) . $c;
                }
                ++$p;
                $s2 .= $c;
        }

        return $s2;
}

The rest is for you to piece together on your own Wink or, better, write your own text transform for even more fun.
BRLOGENSHFEGLE (core dumped)

The Bot Orchestra is back! | Xoylent Easter Egg | 5bots1piano
My music on Google Play and SoundCloud
Reply

#6
Hehe, kudos on posting that div. Mine does not work anymore by the way, but maybe I should write my own script for it.
"Yes, there was a spambot some time ago on these forums." - aa
Reply

#7
>Lord Canistra
Haha, btw i like 猫耳, too XD
http://safebooru.org//samples/407/sample...jpg?407097

>rocknroll237
Oh, you got the wrong PICTURE. I wanna write rainbow colored TEXT lol

>Spaceman
Unfortunately, I couldn't find command for what I wanna do instead of FOO and BAR.
But I could learn more about commands and coud find some useful links by your help. Thank you Wink

>divVarent
Thank you again for giving useful example! I'll try it(and try to fix a little)!
I didn't know Xonotic(and Nexuiz) can load not only cfg file but PHP scripts.

And I want to ask you is there any website for reference of these commands(explain options like --exec, --key or other commands)?
I can see some of commands' explanation on OUNS website but not so many. I'd like to know more about these.

>PinkRobot
Tell me if you could write any useful code Big Grin
Reply

#8
Well, Xonotic can't load PHP scripts, but it can use web servers. And you can put anything you want on a web server...
BRLOGENSHFEGLE (core dumped)

The Bot Orchestra is back! | Xoylent Easter Egg | 5bots1piano
My music on Google Play and SoundCloud
Reply

#9
(12-16-2011, 06:50 AM)PinkRobot Wrote: Hehe, kudos on posting that div. Mine does not work anymore by the way, but maybe I should write my own script for it.

All I need is your player ID. If you use a current Xonotic build, just send me your key_0-public-fp.txt file that's in your xonotic configuration directory (one directory upwards from config.cfg). If you have an older build, just give me a qconsole.log, it contains it too.
BRLOGENSHFEGLE (core dumped)

The Bot Orchestra is back! | Xoylent Easter Egg | 5bots1piano
My music on Google Play and SoundCloud
Reply

#10
I couldn't find key_0-public-fp.txt or qconsole.log anywhere. But if I run above PHP code on my local server, it is okay, right?

However, I tried to run it and I got some troubles.(correct PHP scripts could run on my local machine)
  1. Do I need to add <?php at the top and ?>
    at the bottom in this situation, too? I added.
  2. I've never code in PHP and don't know which variables should be applied. But I modified as follows:
    Code:
    <?php //I added.
    //print("TEST");
    function rainbow($s)
    {
      $s = decolorize($s);
      $s2 = "";
      
      $n = mb_strlen($s); //n = count number of letters
      $j = ((6 * max(1, floor($n/$CONSTANT + rand() / getrandmax() * 2 - 1))) / $n) * (1 - 2 * (rand(0, 1)));
      $f = rand() / getrandmax() * 6;
      $p = 0;
      
      for($i = 0; $i < $n; ++$i) //loop n times
        {
          $c = mb_substr($s, $i, 1); //get a letter from index i
          if($c == "^")
        {
          $c = "^^";
          if(mb_substr($s, $i+1, 1) == "^")
            ++$i;
        }
          if($c != " ")
        {
          list($r, $g, $b) = array($j, $j, $j); //I added but idk this's correct.
          $c = rgb_to_hexcolor($r, $g, $b) . $c;
        }
          ++$p;
          $s2 .= $c;
        }

      return $s2;
    }
    ?>

  3. I modified one of three aliases as follows:
    Code:
    alias spam "menu_cmd curl --exec --key 0 http://localserverIP/spam.php cmd \"$1\" text \"${2- q}\""
    and input as a cfg file.
  4. type spammessagecommand in console and RET,
    and then,
    Code:
    ]spam say
    prompto is displayed

    then I type "TEST" as a test and hit RET.
    And I got
    Code:
    Unknown variable function -q

This PHP script seems to work from my eyes. I guess arguments are not passed or received well in alias command.
hmm, but I tried http://rm.sudo.rm-f.org/~xonotic/spam/spam.php without my ID, of course I couldn't get colored text but error message output as "say" command.
Currently my environment doesn't output even as "say" command(I mean, displayed error message only in console)...
I have no idea now...

If possible, I could do this thing on my local server or local machine.
Could you tell me a little more advices?

Regards
Reply

#11
That code was just a PHP function - you still need to call it.

The code is supposed to print the console commands to run.

It gets input from $_POST['cmd'] and $_POST['text'].
BRLOGENSHFEGLE (core dumped)

The Bot Orchestra is back! | Xoylent Easter Egg | 5bots1piano
My music on Google Play and SoundCloud
Reply

#12
Thank you for you advice again.

I've not understood it completely, but I searched and learned about PHP, and I made it somehow...

I will modify my coloring code then XD

Thank you for helping!
Reply

#13
You are lucky to do that so easy, Lento.

I knew a few guys in Nexuiz who rewrote the whole engine to be able to do this Tongue
Reply

#14
(12-18-2011, 09:04 AM)Mepper Wrote: You are lucky to do that so easy, Lento.

I knew a few guys in Nexuiz who rewrote the whole engine to be able to do this Tongue

wow really? yeah I'm so lucky Big Grin This method might be able to apply for other things!
Reply

#15
OH YEAH!!


Attached Files
.png   無題.png (Size: 131.98 KB / Downloads: 319)
Reply

#16
I first was like: "OMFG I WANT THAT TOO!" But now it seams you have to code a lot of shit I have the slight feeling I'm never gonna talk in rainbow colors Tongue
Reply

#17
If I wanted this, I'd prefer doing an engine mod. It's contained, doesn't depend on some external webserver and doesn't send your potentially private conversations to some remote location. Confused

But that's just paranoid ol' me. (then there's always the irc spybot anyway)
And I don't need it. Or maybe I should do it, just for fun? hmm Big Grin
Reply

#18
(12-19-2011, 12:58 AM)nilyt Wrote: If I wanted this, I'd prefer doing an engine mod. It's contained, doesn't depend on some external webserver and doesn't send your potentially private conversations to some remote location. Confused

But that's just paranoid ol' me. (then there's always the irc spybot anyway)
And I don't need it. Or maybe I should do it, just for fun? hmm Big Grin

Chatting is by definition sending your potentially private conversations to some remote location, AFAIK Tongue
Reply

#19
Well done Lento Smile
"Yes, there was a spambot some time ago on these forums." - aa
Reply

#20
@nilyt: you can set up a httpd and PHP on localhost if you don't want to use external servers.
(08-10-2012, 02:37 AM)Mr. Bougo Wrote: Cloud is the new Web 2.0. It makes no damn sense to me.
Reply

#21
(12-21-2011, 03:40 AM)PinkRobot Wrote: Well done Lento Smile

Thanks!

and I also could do like this:

.jpg   xonotic20111222132034-00.jpg (Size: 46.71 KB / Downloads: 288)
僕と契約してXonoticプレイヤーになってよ!
(send specified command and get value from the server.)
Currently Xonotic doesn't support typing in Japanese but it can display Big Grin
Reply

#22
hello,

I do not understand quite how to put one sentence into one parameter, for example, this line

alias spam "menu_cmd curl --exec --key 0 http://internet.org/test.php?myvarible=$1"

does work, but it sends only one word out to the php file so by typing

spam hello world

in xonotic I get

say hello

what do I missing? D:
[Image: signature.php] [Image: DVlpo.png]
Reply

#23
menu_cmd curl --exec --key 0 http://example.org/meh.cgi foo "abc def" bar "ghi jkl"

That's the same as querying meh.cgi?foo=abc%20def&bar=ghi%20jkl.
So you want alias spam "menu_cmd curl --exec --key 0 http://example.org/test.php myvariable \"$1\""
Reply

#24
How should the php look like? I try to catch this var with $_POST["foo"] or $_GET["foo"]. Oh my I guess I just dont get it how this is gonna work
[Image: signature.php] [Image: DVlpo.png]
Reply

#25
Hehe, I'd really love to see Lento helping you on this now. Now that would be awesome.

I personally don't have a clue about PHP, but from reading this thread I see that div's function needs to be called by your code and it should access $_POST["myvariable"]. Actually maybe the syntax that I showed you above sends $1 as $_POST["myvariable"] data rather than GET, and div's posts suggest that it indeed works that way.

Anyway, it should output a string that consists of "say " followed by whatever you want to say, I'm guessing. The menu_cmd executes as console command whatever the output of the web request is.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-