Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $xml = simplexml_load_file('furnidata.xml');
- foreach ($xml->xpath('//roomitemtypes') AS $v) {
- foreach ($v->furnitype AS $v) {
- $name = (string) $v->attributes()->classname;
- $line = (string) $v->furniline;
- $item[$line][$name] = [
- (string) $v->name,
- 's',
- (INT) $v->xdim,
- (INT) $v->ydim,
- (INT) $v->canstandon,
- (INT) $v->cansiton,
- (INT) $v->canlayon === 1 ? 'bed' : 'default',
- ];
- }
- }
- foreach ($xml->xpath('//wallitemtypes') AS $v) {
- foreach ($v->furnitype AS $v) {
- $name = (string) $v->attributes()->classname;
- $line = (string) $v->furniline;
- $item[$line][$name] = [
- (string) $v->name,
- 'i',
- (INT) $v->xdim,
- (INT) $v->ydim,
- (INT) $v->canstandon,
- (INT) $v->cansiton,
- (INT) $v->canlayon === 1 ? 'bed' : 'default',
- ];
- }
- }
- ksort($item, SORT_FLAG_CASE | SORT_NATURAL);
- foreach ($item AS $k => $v) {
- ksort($item[$k], SORT_FLAG_CASE | SORT_NATURAL);
- }
- // print_r($item); exit;
- $i = 1;
- foreach ($item AS $k => $v) {
- foreach ($v AS $x => $y) {
- echo "INSERT INTO catalog_items (id, page_id, item_id, catalog_name) VALUES ({$i}, 0, {$i}, \"{$x}\");\n";
- echo "INSERT INTO items_base (id, sprite_id, public_name, item_name, type, width, length, is_walkable, can_sit, interaction_type) VALUES ({$i}, {$i}, \"{$y[0]}\", \"{$x}\", \"{$y[1]}\", {$y[2]}, {$y[3]}, {$y[4]}, {$y[5]}, \"{$y[6]}\");\n";
- $i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement