Difference between revisions of "User:Ath/WebAPI Examples"
< User:Ath
m (moved WebAPI/Examples to User:Ath/WebAPI Examples: An API document is not the place for this kind of example) |
m (Preliminary cleanup) |
||
Line 1: | Line 1: | ||
− | + | This page is intended as a quick reference for working with the [[WebAPI]]. As such, it is intended to provide basic examples of how to make use of certain fields, not act as a tutorial. | |
− | = [[ | + | ==[[WebAPI/GetPlayerItems|GetPlayerItems]]== |
− | == | + | ===inventory=== |
− | + | The inventory field contains a binary token encoded in denary form. The first 16 least significant bits denote an item's position within the backpack, the following 16 bits indicate which classes an item is currently equipped to. The first two most significant bits are unused. | |
− | === | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
function is_equipped($inventory_token) | function is_equipped($inventory_token) | ||
Line 43: | Line 10: | ||
return ($inventory_token & 0x0FFF0000) ? true : false; | return ($inventory_token & 0x0FFF0000) ? true : false; | ||
} | } | ||
− | |||
function is_equipped_for_class($class, $inventory_token) | function is_equipped_for_class($class, $inventory_token) | ||
{ | { | ||
return ($inventory_token & 0x80000000) && ($inventory_token & (0x00010000 << $class)); | return ($inventory_token & 0x80000000) && ($inventory_token & (0x00010000 << $class)); | ||
} | } | ||
− | |||
function extract_backpack_position($inventory_token) | function extract_backpack_position($inventory_token) | ||
{ | { | ||
Line 54: | Line 19: | ||
} | } | ||
− | + | ==[[WebAPI/GetSchema|GetSchema]]== | |
− | + | TODO | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
[[Category:WebAPI|Examples]] | [[Category:WebAPI|Examples]] |
Revision as of 17:49, 5 February 2011
This page is intended as a quick reference for working with the WebAPI. As such, it is intended to provide basic examples of how to make use of certain fields, not act as a tutorial.
GetPlayerItems
inventory
The inventory field contains a binary token encoded in denary form. The first 16 least significant bits denote an item's position within the backpack, the following 16 bits indicate which classes an item is currently equipped to. The first two most significant bits are unused.
function is_equipped($inventory_token) { return ($inventory_token & 0x0FFF0000) ? true : false; } function is_equipped_for_class($class, $inventory_token) { return ($inventory_token & 0x80000000) && ($inventory_token & (0x00010000 << $class)); } function extract_backpack_position($inventory_token) { return $inventory_token & 0x0000FFFF; }
GetSchema
TODO