Table of Contents
API
  Python example
  PHP example

API

Python example

Below are a few examples of calling methods from the empyreal.engine.core on the server through a python blocking client. The client used here can be downloaded from the download page.

>>> b  = BlockingGameClient()
>>> b.connect()
>>> b.game('core.get_tick')
15318
>>> b.game('core.get_year')
510
>>> b.game('core.get_character')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/marten/workspace/empyreal/empyreal/lib/blockingclient.py", line 91, in game
    return self.processResponse()
  File "/Users/marten/workspace/empyreal/empyreal/lib/blockingclient.py", line 138, in processResponse
    raise e
empyreal.lib.exceptions.UserNotIncarnatedException: User is not incarnated (None)
>>>

Now lets see that last one while being logged in and incarnated.

>>> b = BlockGameClient()
>>> b.connect('lithium_1', '96af1c214c2644c29ef0a6f61b06fc8f')
>>> character = b.game('core.get_character')
>>> print character
<empyreal.lib.models.Resident instance at 0x1007b28c0>
>>> print character.name
ringmaster
>>> religion = b.game('core.get_religion')
>>> print religion.name
the dark carnival
>>> b.game('core.is_busy')
False
>>>

PHP example

The client used in the example below can be downloaded from the download page.

<?php

$client = new BlockingClient();
$client->connect('lithium_1', '96af1c214c2644c29ef0a6f61b06fc8f');

print_r($client->uptime());

print_r($client->get_user());

$character = $client->get_character();
print_r($character->name);

?>

Output:

Array
(
    [0] => 0
    [1] => 0
    [2] => 19
    [3] => 40
)
EmpyrealUser Object
(
    [username] => 
    [objname] => EmpyrealModel
    [_fields] => Array
        (
            [username] => lithium_1
            [is_active] => 1
            [is_superuser] => 1
            [last_login] => 2013-12-15T12:59:38
            [id] => 12
            [date_joined] => 2013-12-10T20:02:48
        )

)
ringmaster