What's new

PHP [7.6] Generowanie pliku creatures.xml

Status
Not open for further replies.

Thorge D

Advanced User
Joined
Jul 24, 2014
Messages
300
Reaction score
29
Autor: Baabuseek

Plik PHP, kt?ry generuje creatures Naszego silnika.

PHP:
<?php
$data_dir = "C:/OTS/data";
$content = '<?xml version="1.0"?>'. PHP_EOL .'<creatures>'.PHP_EOL;
foreach(glob($data_dir.'/monster/{*.xml}', GLOB_BRACE) as $file)
{
    $ex = explode("/", $file);
    if($ex[(count($ex)-1)] != "monsters.xml")
    {
        $monster = simplexml_load_file($file);
        if(($monster->look['type'] >= 128 && $monster->look['type'] <= 134) || ($monster->look['type'] >= 136 && $monster->look['type'] <= 142))
            $content .= '<creature looktype="'. $monster->look['type'] .'" head="'. $monster->look['head'] .'" body="'. $monster->look['body'] .'" legs="'. $monster->look['legs'] .'" feet="'. $monster->look['feet'] .'" name="'. $monster['name'] .'" type="monster"/>'.PHP_EOL;
        else
            $content .= '<creature looktype="'. $monster->look['type'] .'" name="'. $monster['name'] .'" type="monster"/>'.PHP_EOL;
    }
}
$content .= '</creatures>';
file_put_contents("creatures.xml", $content);
echo("The file 'creatures.xml' was created correctly.");
?>
 
Status
Not open for further replies.
Top