[PHP] Converting Armagetron Colors to HTML Colors

Everything todo with programming goes HERE.
User avatar
delinquent
Match Winner
Posts: 760
Joined: Sat Jul 07, 2012 3:07 am

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by delinquent »

Looking at that makes me confused again as to the operation of the counter... surely it should be looking for the zone first being conquered rather than the round starting? Or have I got this completely wrong?
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by LOVER$BOY »

um... delinquent, how the heck is ROUND_COMMENCING and zone comqueing related? :P
It's meant to change maps once the round is about to start.

Ok. Actually the original code wasn't commented. I usually don't leave comments. Only through title or description in my wiki is where I explain about the use of that script.
Last edited by LOVER$BOY on Fri Aug 31, 2012 6:23 am, edited 1 time in total.
Image
nux
Round Winner
Posts: 206
Joined: Mon Sep 12, 2011 11:20 pm

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by nux »

LOVER$BOY wrote:um... delinquent, who the heck is ROUND_COMMENCING and zone comqueing related? :P
It's meant to change maps once the round is about to start.

Ok. Actually the original code wasn't commented. I usually don't leave comments. Only through title or description in my wiki is where I explain about the use of that script.
Its not his fault he doesnt understand what this script does. That is the problem, you are commenting on the wrong things. There should be a link to the wiki on your script if you dont want to duplicate the usage comments or its too extended/detailed to be there.
There's a difference between knowing your shit, and knowing you're shit. Grammar does matter.
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by LOVER$BOY »

Ok I got it.
Instead of posting it here, I might as well post it at my wiki with the extended details :)

Thanks nux. That's a great idea.

Actually I made a mistake in the wording. Instead of writing "how", I wrote "who" :P My bad.
Image
User avatar
Light
Reverse Outside Corner Grinder
Posts: 1667
Joined: Thu Oct 20, 2011 2:11 pm

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by Light »

Don't know if it's helpful, but here's how I do it. I just throw the span's inside of each other.

Code: Select all

$servername = preg_replace('/(<|>|\\|\/)/e', 'htmlspecialchars("$1");', $servername);
while (strpos($servername, "0x") !== false)
{
	$servername = preg_replace('/0x(\w{6})(.*)?/', '<span style="color: #$1;">$2</span>', $servername);
}
XD|VIPer
Average Program
Posts: 76
Joined: Thu Feb 09, 2012 12:53 am

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by XD|VIPer »

About comments:
Mostly what comments I write is at the beginning that tells information about the script and who made it and that stuff. For example:

Code: Select all

// By Nelg; adventure time script.
or also this

Code: Select all

// Script by nelg. Created for the use of Advanced Stable version. Some commands in this script were copyed from 'Beta Trunk 0.4'.
// Some commands will Be different, lots will not be there. If you think theres something that should be here, please
// tell nelg. 
And I figure things like

Code: Select all

function [i]DEFAULT_MAP[/i]($value) {
if (($value == 1)) {
CMD("map_file Anonymous/polygon/regular/square-1.0.1.aamap.xml");
};
};
are a bit self explanitory
I write comments in these places. For example:

Code: Select all

 $NUM_AIS_3_PLAYER = 1;  // How many Ais to have with 3 players in MutiPlayer mode - No limit
Edit: I made a mistake on one of the comments on this post.





(I need to get out of the habit of using all those ;'s in places where they are not needed) :oops:
Last edited by XD|VIPer on Tue Apr 02, 2013 12:32 pm, edited 1 time in total.
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by LOVER$BOY »

Light wrote:Don't know if it's helpful, but here's how I do it. I just throw the span's inside of each other.

Code: Select all

$servername = preg_replace('/(<|>|\\|\/)/e', 'htmlspecialchars("$1");', $servername);
while (strpos($servername, "0x") !== false)
{
	$servername = preg_replace('/0x(\w{6})(.*)?/', '<span style="color: #$1;">$2</span>', $servername);
}
Ya that's the way to go! I was actually planning on re-programming this script since my first attempt was pretty rough and not simple. Thanks for the heads up :)
XD|VIPer wrote:About comments:
Mostly what comments I write is at the beginning that tells information about the script and who made it and that stuff. For example:

Code: Select all

// By Nelg; adventure time script.
or also this

Code: Select all

// Script by nelg. Created for the use of Advanced Stable 'Beta Trunk 0.4' version. Most commands were copyed from there.
// Some commands will Be different, lots will not be there. If you think theres something that should be here, please
// tell nelg. 
And I figure things like

Code: Select all

function [i]DEFAULT_MAP[/i]($value) {
if (($value == 1)) {
CMD("map_file Anonymous/polygon/regular/square-1.0.1.aamap.xml");
};
};
are a bit self explanitory
I write comments in these places. For example:

Code: Select all

 $NUM_AIS_3_PLAYER = 1;  // How many Ais to have with 3 players in MutiPlayer mode - No limit






(I need to get out of the habit of using all those ;'s in places where they are not needed) :oops:
Don't worry. I haven't changed much in the habit of commenting. Rather, I'm less commenting since I'm letting my lazy attitude take over when programming. Only in situations like complexity that I prefer to comment and explain a bit on it :)
Image
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by LOVER$BOY »

I've fixed up my script and assembled it to the launchpad now. It's simple, neat and very effective. On top of that, only took me 10 minutes which is better than the version 1.0 who took me hours :D

So Version 2.0 is now better and more effective. Also, it will not load the characters of non-color recognized. Just a place holder to stop loading in non-recognized letters.
Image
User avatar
LOVER$BOY
Match Winner
Posts: 731
Joined: Thu Jan 24, 2008 12:46 pm

Re: [PHP] Converting Armagetron Colors to HTML Colors

Post by LOVER$BOY »

Upgraded script to now check if the color codes are dark or not. If so, white background will appear with the text colored. I followed the steps taken in the game code which works great! ;)
Image
Post Reply