Author Topic: Understanding Rainbow Player  (Read 810 times)

So while trying to re-invent my player's look I started to experiment around with my rainbow player mod. Can someone break this down into any semblance of a recognizable syntax?

Code: [Select]
{
        if($RainbowPlayerCount > 63) $RainbowPlayerCount=0;
        //Grejer
        $R=0+0*mSin($RainbowPlayerCount*3.14/16.0);
        $G=0.75+0.25*mSin($RainbowPlayerCount*3.14/16.0+21.0);
        $B=0.75+0.25*mSin($RainbowPlayerCount*3.14/16.0+42.0);
        $pref::Avatar::PackColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::PackColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::HatColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::LHandColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::RHandColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::HeadskinColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::TorsoColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::LArmColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::HipColor=$R SPC $G SPC $B SPC "1";
      $pref::Avatar::RArmColor=$R SPC $G SPC $B SPC "1";
        clientcmdupdateprefs();
        $RainbowPlayerCount++;
        $RainbowPlayer=schedule(1000,0,RainbowPlayerLoop);
}

The lines that start with $R, $G, and $B are what's really important here. They take a variable, $RainpowPlayerCount, which is a value from 0-63 (as per the second line) and figures out from that number what color it should be. mSin returns a value -1 through 1 based on the input. So as $RainbowPlayerCount increases, it goes from 0 to 1 to 0 to -1 back to 0 (start).

Then all the $pref::avatar::whatever lines are setting the color of your body parts to the value set to each of those variables (red, green, and blue). Then clientCmdUpdatePrefs() tells your server to change your body color. Then it increases the value of $RainbowPlayerCount (for the next time the function is run) and then runs the function again in 1 second (1000 ms)

It looks like you copy-pasted the code, but forgot the first line. Curly Brackets represent whats inside of something. Usually it's like
function servercmdHW()
{
      echo("Hello World!");
}

In your code, you don't even have a function name or anything.

The lines that start with $R, $G, and $B are what's really important here. They take a variable, $RainpowPlayerCount, which is a value from 0-63 (as per the second line) and figures out from that number what color it should be. mSin returns a value -1 through 1 based on the input. So as $RainbowPlayerCount increases, it goes from 0 to 1 to 0 to -1 back to 0 (start).

Then all the $pref::avatar::whatever lines are setting the color of your body parts to the value set to each of those variables (red, green, and blue). Then clientCmdUpdatePrefs() tells your server to change your body color. Then it increases the value of $RainbowPlayerCount (for the next time the function is run) and then runs the function again in 1 second (1000 ms)
Very helpful! Thank you very much!