[PHP][MAP] Need a bit of PHP help or Arma info...

For all the help you need with Armagetron!
Post Reply
7Priest7
On Lightcycle Grid
Posts: 14
Joined: Sat Dec 11, 2010 5:26 pm

[PHP][MAP] Need a bit of PHP help or Arma info...

Post by 7Priest7 »

I made a php script capable of Generating letters and select symbols as walls...

Code: Select all

<?php

function ArmaLetter($x,$y,$l) { 
   // Armagetron Letter Wall Generator
   // Needs the values of top left x y and the letter to be made...
   // Will return any walls needed to create the letter in a 10x10 spot
   
   // following 5 lines make code shorter
   $ws = "<wall>\n";
   $we = "</wall>\n";
   $ps = "<Point ";
   $pe = " />\n";
   $pm = $pe.$ps;
   
   // Following 22 lines assign relative cords + cord related code that makes rest the code a little easier/and ALOT shorter(character wise)(also not counting my comments)

   $x1="x=\"" . strval($x+1) ."\" ";
   $x2="x=\"" . strval($x+2) ."\" ";
   $x3="x=\"" . strval($x+3) ."\" ";
   $x4="x=\"" . strval($x+4) ."\" ";
   $x5="x=\"" . strval($x+5) ."\" ";
   $x6="x=\"" . strval($x+6) ."\" ";
   $x7="x=\"" . strval($x+7) ."\" ";
   $x8="x=\"" . strval($x+8) ."\" ";
   $x9="x=\"" . strval($x+9) ."\" ";
   $x10="x=\"" . strval($x+10) ."\" ";
   $y1="y=\"" . strval($y+1) ."\" ";
   $y2="y=\"" . strval($y+2) ."\" ";
   $y3="y=\"" . strval($y+3) ."\" ";
   $y4="y=\"" . strval($y+4) ."\" ";
   $y5="y=\"" . strval($y+5) ."\" ";
   $y6="y=\"" . strval($y+6) ."\" ";
   $y7="y=\"" . strval($y+7) ."\" ";
   $y8="y=\"" . strval($y+8) ."\" ";
   $y9="y=\"" . strval($y+9) ."\" ";
   $y10="y=\"" . strval($y+10) ."\" ";
   $x="x=\"$x\" ";
   $y="y=\"$y\" ";
   
   $l = strtoupper($l); // Make sure the letter is uppercase...
   
   // This If/Else If cluster returns the neccesary wall(s) for the letter given...
   if($l=="A") return "$ws$ps$x$y10$pm$x$y$pm$x10$y$pm$x10$y10$pe$we$ws$ps$x1$y3$pm$x9$y3$pe$we";
   else if($l=="B") return "$ws$ps$x$y$pm$x$y10$pm$x10$y10$pm$x10$y4$pm$x$y4$pm$x7$y4$pm$x7$y$pm$x$y$pe$we";
   else if($l=="C") return "$ws$ps$x10$y$pm$x$y$pm$x$y10$pm$x10$y10$pe$we";
   else if($l=="D") return "$ws$ps$x$y$pm$x$y10$pm$x7$y10$pm$x10$y7$pm$x10$y4$pm$x7$y$pm$x$y$pe$we";
   else if($l=="E") return "$ws$ps$x10$y$pm$x$y$pm$x$y10$pm$x10$y10$pe$we$ws$ps$x1$y4$pm$x7$y4$pe$we";
   else if($l=="F") return "$ws$ps$x10$y$pm$x$y$pm$x$y10$pe$we$ws$ps$x1$y4$pm$x7$y4$pe$we";
   else if($l=="G") return "$ws$ps$x10$y$pm$x$y$pm$x$y10$pm$x10$y10$pm$x10$y5$pm$x7$y5$pe$we";
   else if($l=="H") return "$ws$ps$x$y$pm$x$y10$pe$we$ws$ps$x10$y$pm$x10$y10$pe$we$ws$ps$x1$y4$pm$x9$y4$pe$we";
   else if($l=="I") return "$ws$ps$x4$y$pm$x7$y$pe$we$ws$ps$x4$y10$pm$x7$y10$pe$we$ws$ps$x5$y1$pm$x5$y9$pe$we";
   else if($l=="J") return "$ws$ps$x10$y$pm$x10$y10$pm$x3$y10$pm$x$y8$pe$we";
   else if($l=="K") return "$ws$ps$x$y$pe$we$ws$ps$x10$y$pm$x1$y5$pm$x10$y10$pe$we";
   else if($l=="L") return "$ws$ps$x$y$pm$x$y10$pm$x7$y10$pe$we";
   else if($l=="M") return "$ws$ps$x$y10$pm$x$y$pm$x5$y5$pm$x10$y$pm$x10$y10$pe$we";
   else if($l=="N") return "$ws$ps$x$y10$pm$x$y$pm$x10$y10$pm$x10$y$pe$we";
   else if($l=="O") return "$ws$ps$x$y$pm$x$y10$pm$x10$y10$pm$x10$y$pm$x$y$pe$we";
   else if($l=="P") return "$ws$ps$x$y10$pm$x$y$pm$x7$y2$pm$x$y4$pe$we";
   else if($l=="Q") return "$ws$ps$x9$y7$pm$x10$y6$pm$x10$y$pm$x$y$pm$x$y10$pm$x6$y10$pm$x7$y9$pe$we$ws$ps$x10$y10$pm$x6$y6$pe$we";
   else if($l=="R") return "$ws$ps$x$y10$pm$x$y$pm$x10$y4$pm$x$y4$pm$x10$y10$pe$we";
   else if($l=="S") return "$ws$ps$x10$y$pm$x$y$pm$x$y5$pm$x10$y5$pm$x10$y10$pm$x$y10$pe$we";
   else if($l=="T") return "$ws$ps$x$y$pm$x10$y$pe$we$ws$ps$x5$y1$pm$x5$y10$pe$we";
   else if($l=="U") return "$ws$ps$x$y$pm$x$y10$pm$x10$y10$pm$x10$y$pe$we";
   else if($l=="V") return "$ws$ps$x$y$pm$x5$y10$pm$x10$y$pe$we";
   else if($l=="W") return "$ws$ps$x$y$pm$x$y10$pm$x10$y10$pm$x10$y$pe$we$ws$ps$x5$y5$pm$x5$y10$pe$we";
   else if($l=="X") return "$ws$ps$x$y$pm$x4$y4$pe$we$ws$ps$x10$y$pm$x$y10$pe$we$ws$ps$x6$y6$pm$x10$y10$pe$we";
   else if($l=="Y") return "$ws$ps$x$y$pm$x4$y4$pm$x10$y$pe$we$ws$ps$x5$y6$pm$x5$y10$pe$we";
   else if($l=="Z") return "$ws$ps$x$y$pm$x10$y$pm$x$y10$pm$x10$y10$pe$we";
   else if($l==".") return "$ws$ps$x4$y9$pm$x4$y7$pm$x6$y7$pm$x6$y9$pm$x4$y9$pe$we";
   else if($l=="!") return "$ws$ps$x4$y$pm$x4$y5$pm$x6$y5$pm$x6$y$pm$x4$y$pe$we$ws$ps$x4$y9$pm$x4$y7$pm$x6$y7$pm$x6$y9$pm$x4$y9$pe$we";
   else if($l=="?") return "$ws$ps$x3$y1$pm$x7$y1$pm$x7$y4$pm$x5$y4$pm$x5$y6$pe$we$ws$ps$x5$y8$pm$x5$y9$pe$we";
   else if($l=="'") return "$ws$ps$x5$y1$pm$x5$y2$pm$x6$y1$pm$x5$y1$pe$we";
   else if($l=="") return "$ws$ps$x4$y1$pm$x4$y2$pe$we$ws$ps$x6$y1$pm$x6$y2$pe$we";
   else if($l==",") return "$ws$ps$x4$y9$pm$x4$y7$pm$x6$y7$pm$x4$y9$pe$we";
}


function ArmaSentence($x,$y,$s) {
   // Armagetron Sentence wall Creator
   // Companion to the Arma Letter function
   // Both Functions coded by Alexander Leonn Santiago
   // AKA 7Priest7@forums/Alexander In game
   
   // This function takes the start x and y and a sentence and returns a bunch of walls
   
   $sa = str_split($s);
   $o = "";
   foreach($sa as $l) {
      $o.=ArmaLetter($x,$y,$l);
      $x+=12; // Comment this for vertical text
      //$y+=12; //Uncomment this for vertical text
   }
   return $o;
}
/*explode("\r\n",file_get_contents("kjv.txt"));
$rn = rand(5,3801);*/
file_put_contents("cross-0.3.aamap.xml",'
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE Resource SYSTEM "map-0.2.8_beta3.dtd">
<Resource type="aamap" name="cross" version="0.3" author="7priest7" category="cross">
	<Map version="0.2.8">
		<!-- A Cross Shaped Map EDIT: BIGGER -->

		<World>
			<Field>
				<Axes number="4" />

				<Spawn	x="300"	y="100"	xdir="0" ydir="1"	/>
				<Spawn	x="100"	y="300"	xdir="1" ydir="0"	/>
				<Spawn	x="500"	y="300"	xdir="-1" ydir="-0"	/>
				<Spawn	x="300"	y="700"	xdir="-0" ydir="-1"	/>

				<Wall>
					<Point	x="200"	y="0"	/>
					<Point	x="400"	y="0"	/>
					<Point	x="400"	y="200" />
					<Point	x="600"	y="200" />
					<Point	x="600"	y="400" />
					<Point	x="400"	y="400" />
					<Point	x="400"	y="800" />
					<Point	x="200"	y="800" />
					<Point	x="200"	y="400" />
					<Point	x="0"		y="400" />
					<Point	x="0"		y="200" />
					<Point	x="200" 	y="200" />
					<Point	x="200" 	y="0" />
				</Wall>' .
				ArmaSentence(20,380,"Test.!?,\"'AbcDEFGHIJKLMNOPQRSTUVWXYZ") . '
			</Field>
		</World>
	</Map>
</Resource>');
?>
The above PHP Generated Something similar to this(I added a comment)...

Code: Select all


<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE Resource SYSTEM "map-0.2.8_beta3.dtd">
<Resource type="aamap" name="cross" version="0.3" author="7priest7" category="cross">
	<Map version="0.2.8">
		<!-- A Cross Shaped Map EDIT: BIGGER -->

		<World>
			<Field>
				<Axes number="4" />

				<Spawn	x="300"	y="100"	xdir="0" ydir="1"	/>
				<Spawn	x="100"	y="300"	xdir="1" ydir="0"	/>
				<Spawn	x="500"	y="300"	xdir="-1" ydir="-0"	/>
				<Spawn	x="300"	y="700"	xdir="-0" ydir="-1"	/>

				<Wall>
					<Point	x="200"	y="0"	/>
					<Point	x="400"	y="0"	/>
					<Point	x="400"	y="200" />
					<Point	x="600"	y="200" />
					<Point	x="600"	y="400" />
					<Point	x="400"	y="400" />
					<Point	x="400"	y="800" />
					<Point	x="200"	y="800" />
					<Point	x="200"	y="400" />
					<Point	x="0"		y="400" />
					<Point	x="0"		y="200" />
					<Point	x="200" 	y="200" />
					<Point	x="200" 	y="0" />
				</Wall>
<!-- All the walls after here were auto generated via PHP -->
<wall>
<Point x="20" y="380"  />
<Point x="30" y="380"  />
</wall>
<wall>
<Point x="25" y="381"  />
<Point x="25" y="390"  />
</wall>
<wall>
<Point x="42" y="380"  />
<Point x="32" y="380"  />
<Point x="32" y="390"  />
<Point x="42" y="390"  />
</wall>
<wall>
<Point x="33" y="384"  />
<Point x="39" y="384"  />
</wall>
<wall>
<Point x="54" y="380"  />
<Point x="44" y="380"  />
<Point x="44" y="385"  />
<Point x="54" y="385"  />
<Point x="54" y="390"  />
<Point x="44" y="390"  />
</wall>
<wall>
<Point x="56" y="380"  />
<Point x="66" y="380"  />
</wall>
<wall>
<Point x="61" y="381"  />
<Point x="61" y="390"  />
</wall>
<wall>
<Point x="72" y="389"  />
<Point x="72" y="387"  />
<Point x="74" y="387"  />
<Point x="74" y="389"  />
<Point x="72" y="389"  />
</wall>
<wall>
<Point x="84" y="380"  />
<Point x="84" y="385"  />
<Point x="86" y="385"  />
<Point x="86" y="380"  />
<Point x="84" y="380"  />
</wall>
<wall>
<Point x="84" y="389"  />
<Point x="84" y="387"  />
<Point x="86" y="387"  />
<Point x="86" y="389"  />
<Point x="84" y="389"  />
</wall>
<wall>
<Point x="95" y="381"  />
<Point x="99" y="381"  />
<Point x="99" y="384"  />
<Point x="97" y="384"  />
<Point x="97" y="386"  />
</wall>
<wall>
<Point x="97" y="388"  />
<Point x="97" y="389"  />
</wall>
<wall>
<Point x="108" y="389"  />
<Point x="108" y="387"  />
<Point x="110" y="387"  />
<Point x="108" y="389"  />
</wall>
<wall>
<Point x="133" y="381"  />
<Point x="133" y="382"  />
<Point x="134" y="381"  />
<Point x="133" y="381"  />
</wall>
<wall>
<Point x="140" y="390"  />
<Point x="140" y="380"  />
<Point x="150" y="380"  />
<Point x="150" y="390"  />
</wall>
<wall>
<Point x="141" y="383"  />
<Point x="149" y="383"  />
</wall>
<wall>
<Point x="152" y="380"  />
<Point x="152" y="390"  />
<Point x="162" y="390"  />
<Point x="162" y="384"  />
<Point x="152" y="384"  />
<Point x="159" y="384"  />
<Point x="159" y="380"  />
<Point x="152" y="380"  />
</wall>
<wall>
<Point x="174" y="380"  />
<Point x="164" y="380"  />
<Point x="164" y="390"  />
<Point x="174" y="390"  />
</wall>
<wall>
<Point x="176" y="380"  />
<Point x="176" y="390"  />
<Point x="183" y="390"  />
<Point x="186" y="387"  />
<Point x="186" y="384"  />
<Point x="183" y="380"  />
<Point x="176" y="380"  />
</wall>
<wall>
<Point x="198" y="380"  />
<Point x="188" y="380"  />
<Point x="188" y="390"  />
<Point x="198" y="390"  />
</wall>
<wall>
<Point x="189" y="384"  />
<Point x="195" y="384"  />
</wall>
<wall>
<Point x="210" y="380"  />
<Point x="200" y="380"  />
<Point x="200" y="390"  />
</wall>
<wall>
<Point x="201" y="384"  />
<Point x="207" y="384"  />
</wall>
<wall>
<Point x="222" y="380"  />
<Point x="212" y="380"  />
<Point x="212" y="390"  />
<Point x="222" y="390"  />
<Point x="222" y="385"  />
<Point x="219" y="385"  />
</wall>
<wall>
<Point x="224" y="380"  />
<Point x="224" y="390"  />
</wall>
<wall>
<Point x="234" y="380"  />
<Point x="234" y="390"  />
</wall>
<wall>
<Point x="225" y="384"  />
<Point x="233" y="384"  />
</wall>
<wall>
<Point x="240" y="380"  />
<Point x="243" y="380"  />
</wall>
<wall>
<Point x="240" y="390"  />
<Point x="243" y="390"  />
</wall>
<wall>
<Point x="241" y="381"  />
<Point x="241" y="389"  />
</wall>
<wall>
<Point x="258" y="380"  />
<Point x="258" y="390"  />
<Point x="251" y="390"  />
<Point x="248" y="388"  />
</wall>
<wall>
<Point x="260" y="380"  />
</wall>
<wall>
<Point x="270" y="380"  />
<Point x="261" y="385"  />
<Point x="270" y="390"  />
</wall>
<wall>
<Point x="272" y="380"  />
<Point x="272" y="390"  />
<Point x="279" y="390"  />
</wall>
<wall>
<Point x="284" y="390"  />
<Point x="284" y="380"  />
<Point x="289" y="385"  />
<Point x="294" y="380"  />
<Point x="294" y="390"  />
</wall>
<wall>
<Point x="296" y="390"  />
<Point x="296" y="380"  />
<Point x="306" y="390"  />
<Point x="306" y="380"  />
</wall>
<wall>
<Point x="308" y="380"  />
<Point x="308" y="390"  />
<Point x="318" y="390"  />
<Point x="318" y="380"  />
<Point x="308" y="380"  />
</wall>
<wall>
<Point x="320" y="390"  />
<Point x="320" y="380"  />
<Point x="327" y="382"  />
<Point x="320" y="384"  />
</wall>
<wall>
<Point x="341" y="387"  />
<Point x="342" y="386"  />
<Point x="342" y="380"  />
<Point x="332" y="380"  />
<Point x="332" y="390"  />
<Point x="338" y="390"  />
<Point x="339" y="389"  />
</wall>
<wall>
<Point x="342" y="390"  />
<Point x="338" y="386"  />
</wall>
<wall>
<Point x="344" y="390"  />
<Point x="344" y="380"  />
<Point x="354" y="384"  />
<Point x="344" y="384"  />
<Point x="354" y="390"  />
</wall>
<wall>
<Point x="366" y="380"  />
<Point x="356" y="380"  />
<Point x="356" y="385"  />
<Point x="366" y="385"  />
<Point x="366" y="390"  />
<Point x="356" y="390"  />
</wall>
<wall>
<Point x="368" y="380"  />
<Point x="378" y="380"  />
</wall>
<wall>
<Point x="373" y="381"  />
<Point x="373" y="390"  />
</wall>
<wall>
<Point x="380" y="380"  />
<Point x="380" y="390"  />
<Point x="390" y="390"  />
<Point x="390" y="380"  />
</wall>
<wall>
<Point x="392" y="380"  />
<Point x="397" y="390"  />
<Point x="402" y="380"  />
</wall>
<wall>
<Point x="404" y="380"  />
<Point x="404" y="390"  />
<Point x="414" y="390"  />
<Point x="414" y="380"  />
</wall>
<wall>
<Point x="409" y="385"  />
<Point x="409" y="390"  />
</wall>
<wall>
<Point x="416" y="380"  />
<Point x="420" y="384"  />
</wall>
<wall>
<Point x="426" y="380"  />
<Point x="416" y="390"  />
</wall>
<wall>
<Point x="422" y="386"  />
<Point x="426" y="390"  />
</wall>
<wall>
<Point x="428" y="380"  />
<Point x="432" y="384"  />
<Point x="438" y="380" />
</wall>
<wall>
<Point x="433" y="386"  />
<Point x="433" y="390"  />
</wall>
<wall>
<Point x="440" y="380"  />
<Point x="450" y="380"  />
<Point x="440" y="390"  />
<Point x="450" y="390"  />
</wall>

			</Field>
		</World>
	</Map>
</Resource>
I've tried to debug the problem...
However whatever I do(change the version mostly) it still gives me

Code: Select all

[0] Resource 7priest7/cross/cross-0.3.aamap.xml not found in cache. Downloading it, please be patient...
[0] Downloading http://www.blessed-armagetron.co.cc:81/7priest7/cross/cross-0.3.aamap.xml ...
[0] OK
[0] Failed to parse 
[0] Map load failure:
[0] The map 7priest7/cross/cross-0.3.aamap.xml could not be loaded or parsed; please check your configuration and the log.
I am for being so incredibly fail...
I would greatly appreciate Any attempt to aid me.

Alex

EDIT: Fixed error with Y Script still fails to parse
Last edited by 7Priest7 on Mon Jul 08, 2013 3:20 am, edited 3 times in total.
7Priest7
On Lightcycle Grid
Posts: 14
Joined: Sat Dec 11, 2010 5:26 pm

Re: [PHP][MAP] Need a bit of PHP help or Arma info...

Post by 7Priest7 »

Sorry for this the bbtag for php code failed and this post I re-posted php with same results.
User avatar
Z-Man
God & Project Admin
Posts: 11710
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Re: [PHP][MAP] Need a bit of PHP help or Arma info...

Post by Z-Man »

It's case sensitive. "Wall", not "wall". For future errors, please post the full errors the game gives you, that makes troubleshooting that much quicker.
7Priest7
On Lightcycle Grid
Posts: 14
Joined: Sat Dec 11, 2010 5:26 pm

Re: [PHP][MAP] Need a bit of PHP help or Arma info...

Post by 7Priest7 »

Z-Man wrote:It's case sensitive. "Wall", not "wall". For future errors, please post the full errors the game gives you, that makes troubleshooting that much quicker.
Thanks...
The walls were generated sadly way too tall to read...

Perhaps eventually grid coloring could be implemented?
Something like <GColor rgb="RRGGBB"><Point x="#" y="#" /><Point x="#2" y="#2" /></GColor>...

Ehh Well until GColor is implemented(if ever it will be) the PHP was a gigantic waste of time...

Ohh well...

EDIT: Forgot to put rgb="RRGGBB"
EDIT: The DTD lines would be as follows I believe
<!ELEMENT GColor (Point+) >
<!ATTLIST GColor rgb CDATA #REQUIRED>
<!ATTLIST GColor height CDATA #IMPLIED>
Last EDIT: I am pretty sure one of the source files that would need tweeking would be src\engine\eFloor.h ...
I would do the coding except it seems like almost every source file is 100+ lines and I have no desire to study such a intricate code...
User avatar
sinewav
Graphic Artist
Posts: 6477
Joined: Wed Jan 23, 2008 3:37 am
Contact:

Re: [PHP][MAP] Need a bit of PHP help or Arma info...

Post by sinewav »

Change the wall height with the height property. Try <Wall height="2">
Last edited by sinewav on Tue Dec 14, 2010 7:16 pm, edited 1 time in total.
7Priest7
On Lightcycle Grid
Posts: 14
Joined: Sat Dec 11, 2010 5:26 pm

Re: [PHP][MAP] Need a bit of PHP help or Arma info...

Post by 7Priest7 »

sinewav wrote:Change the wall height with the height property. Try <wall height="2">
Thanks =)
Post Reply