Skip to content

Commit

Permalink
Merge pull request #153 from gamingrobot/more-docs
Browse files Browse the repository at this point in the history
Updated docs and example
  • Loading branch information
Gjum committed Sep 23, 2015
2 parents 2901ef3 + 03eb7d0 commit 7839189
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 18 deletions.
2 changes: 2 additions & 0 deletions docs/authors.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _authors:

*******
Authors
*******
Expand Down
2 changes: 2 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _contributing:

************
Contributing
************
Expand Down
5 changes: 5 additions & 0 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.. _getting-started:

***************
Getting Started
***************

See the `Basic Example Bot <https://github.com/SpockBotMC/SpockBot/tree/master/examples/basic>`__ for basic usage of SpockBot.

Also see the `Extra Repository <https://github.com/SpockBotMC/SpockBot-Extra>`__ for some more plugin examples.
2 changes: 0 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ SpockBot
Welcome to SpockBot's documentation!
====================================

Contents:

.. toctree::
:caption: Usage
:maxdepth: 1
Expand Down
15 changes: 15 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
.. _installation:

************
Installation
************

If you are looking to contribute to SpockBot please follow the instructions :ref:`here <contributing>`.

#. Install cryptography first, instructions for that are `here <https://cryptography.io/en/latest/installation/>`__

#. Clone the repository locally::

git clone https://github.com/SpockBotMC/SpockBot.git

#. Install SpockBot::

cd SpockBot
python3 setup.py install

2 changes: 2 additions & 0 deletions docs/license.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _license:

*******
License
*******
Expand Down
7 changes: 7 additions & 0 deletions docs/modules/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spock
=====

.. toctree::
:maxdepth: 4

spock
8 changes: 8 additions & 0 deletions docs/modules/spock.plugins.core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ spock.plugins.core.settings module
:undoc-members:
:show-inheritance:

spock.plugins.core.taskmanager module
-------------------------------------

.. automodule:: spock.plugins.core.taskmanager
:members:
:undoc-members:
:show-inheritance:

spock.plugins.core.ticker module
--------------------------------

Expand Down
14 changes: 11 additions & 3 deletions docs/modules/spock.plugins.helpers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ spock.plugins.helpers package
Submodules
----------

spock.plugins.helpers.chat module
---------------------------------

.. automodule:: spock.plugins.helpers.chat
:members:
:undoc-members:
:show-inheritance:

spock.plugins.helpers.clientinfo module
---------------------------------------

Expand Down Expand Up @@ -52,10 +60,10 @@ spock.plugins.helpers.keepalive module
:undoc-members:
:show-inheritance:

spock.plugins.helpers.move module
---------------------------------
spock.plugins.helpers.movement module
-------------------------------------

.. automodule:: spock.plugins.helpers.move
.. automodule:: spock.plugins.helpers.movement
:members:
:undoc-members:
:show-inheritance:
Expand Down
16 changes: 16 additions & 0 deletions docs/modules/spock.plugins.tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ spock.plugins.tools package
Submodules
----------

spock.plugins.tools.collision module
------------------------------------

.. automodule:: spock.plugins.tools.collision
:members:
:undoc-members:
:show-inheritance:

spock.plugins.tools.inventory_async module
------------------------------------------

Expand All @@ -12,6 +20,14 @@ spock.plugins.tools.inventory_async module
:undoc-members:
:show-inheritance:

spock.plugins.tools.task module
-------------------------------

.. automodule:: spock.plugins.tools.task
:members:
:undoc-members:
:show-inheritance:


Module contents
---------------
Expand Down
8 changes: 0 additions & 8 deletions docs/modules/spock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ Subpackages
Submodules
----------

spock.task module
-----------------

.. automodule:: spock.task
:members:
:undoc-members:
:show-inheritance:

spock.utils module
------------------

Expand Down
3 changes: 2 additions & 1 deletion examples/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
- Creating a plugin
- Receiving chat messages
- Sending chat commands
- Using inventory
- Moving to location
- Triggering a periodic event using a timer
- Registering for an event upon startup
- Changing bot position and orientation
- Placing blocks
- Reading blocks

Expand Down
15 changes: 11 additions & 4 deletions examples/basic/example_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ class ExamplePlugin(PluginBase):
requires = ('Movement', 'Timers', 'World', 'ClientInfo', 'Inventory',
'Interact', 'Chat')
# Example of registering an event handler
# Event types are enumerated here:
# Packet event types are enumerated here:
# https://github.com/SpockBotMC/SpockBot/blob/master/spock/mcp
# /mcdata.py#L213
# There are other events that can be used that are emitted by other plugins
events = {
# This event will be triggered when a chat message is received
# from the server
'PLAY<Chat Message': 'chat_event_handler',
# This event will be triggered after authentication when the bot
# joins the game
'client_join_game': 'perform_initial_actions',
# This event is triggered once the inventory plugin has the
# full inventory
'inventory_synced': 'hold_block',
}

def __init__(self, ploader, settings):
Expand All @@ -72,9 +76,7 @@ def chat_event_handler(self, name, data):
"""Called when a chat message occurs in the game"""
logger.info('Chat message received: {0}'.format(data))

def periodic_event_handler(self):
"""Triggered every 5 seconds by a timer"""

def hold_block(self, name, data):
# Search the hotbar for cobblestone
slot = self.inventory.find_slot(4, self.inventory.window.hotbar_slots)
logger.info(slot)
Expand All @@ -84,6 +86,11 @@ def periodic_event_handler(self):
# Switch to first slot because there is no cobblestone in hotbar
else:
self.inventory.select_active_slot(0)
# Return True to unregister the event handler
return True

def periodic_event_handler(self):
"""Triggered every 5 seconds by a timer"""

logger.info('My position: {0} pitch: {1} yaw: {2}'.format(
self.clientinfo.position,
Expand Down

0 comments on commit 7839189

Please sign in to comment.