コード例 #1
0
ファイル: items.php プロジェクト: Tobbebror/POT
<?php

// to not repeat all that stuff
include 'quickstart.php';
// loads item typing information
// dont use POT::getInstance() anymore
POT::loadItems('/path/to/your/ots/data/items');
// creates new player object
$player = new OTS_Player();
$player->find('Wrzasq');
/*
    Items loading example.
*/
// loading item from ammunition slot
$item = $player->getSlot(POT::SLOT_AMMO);
echo $player->getName(), ' has item with id ', $item->getId(), ' in his/her ammo slot.', "\n";
// checks if item is a container
if ($item instanceof OTS_Container) {
    // list backpack content
    foreach ($item as $inside) {
        echo 'Container contains item with id ', $inside->getId(), '.', "\n";
    }
}
/*
    Items tree composing example.
*/
// creates container - here it would be a depot locker (we pass ID of item to create)
$container = new OTS_Container(2590);
// now let's create depot chest
$chest = new OTS_Container(2594);
// let's put chest inside locker