Tuxemon Debug Console

From Tuxepedia
Jump to navigation Jump to search

Tuxemon comes with command line that you can use for debugging purposes. The Tuxemon command line console provides you with a *full* python shell and access to all in-game functions and variables. This page will give you some examples on how you can use the Tuxemon CLI to do things like give yourself monsters or start battles.

Enabling the CLI

To enable to Tuxemon command line, edit the tuxemon.cfg configuration file with a text editor and change cli_enabled to 1.

hvvblIn.png

After enabling the CLI, run Tuxemon from the command line:

python ./tuxemon.py

Using the CLI

Introduction

After launching Tuxemon from the command line, you should get a prompt that looks like this:

Tuxemon>>

To start a python shell, enter the following command:

Tuxemon>> python

You should now get a python shell prompt that looks like this:

>>>

From here, you can execute arbitrary Python code. To access the game's objects and variables, use self.app.

Examples

   python
   >>> print self.app
   <core.tools.Control object at 0x7f4365302e90>
   
   python
   >>> from pprint import pprint
   >>> pprint(self.app.__dict__)
   {'animations': {},
    'caption': 'Tuxemon',
    'cli': <core.components.cli.CommandLine instance at     0x7f436532bc68>,
    'clock': <Clock(fps=62.50)>,
    'config': <core.components.config.Config object at     0x7f4367617810>,
    'current_music': {'song': None, 'status': 'stopped'},
    'current_time': 383013,
    'done': False,
    'event_actions': {},
    'event_conditions': {},
    'event_data': {},
    'event_engine': <core.components.event.EventEngine object at 0x7f436530c0d0>,
    'event_persist': {},
   ...


   python
   >>> dir(self.app)
   ['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'animations', 'caption', 'cli', 'clock', 'config', 'controller_event_loop', 'current_music', 'current_time', 'done', 'event_actions', 'event_conditions', 'event_data', 'event_engine', 'event_loop', 'event_persist', 'events', 'exit', 'flip_state', 'fps', 'imports', 'joystick_event_loop', 'key_events', 'keyboard_events', 'keys', 'main', 'main_loop', 'network_event_loop', 'network_events', 'player1', 'rumble', 'rumble_manager', 'screen', 'server', 'setup_states', 'show_fps', 'state', 'state_dict', 'state_name', 'time_passed_seconds', 'toggle_show_fps', 'update']

Adding Monsters

You can add a monster to your party by typing the following into the Tuxemon python shell:

   python
   >>> from core.components.event.actions.player import Player
   >>> Player().add_monster(self.app, (None, 'Fruitera,20'))

In this example, we add the monster "Fruitera" at level 20 to the player's monsters.

Adding Items

You can add an item to your inventory by typing the following into the Tuxemon python shell:

   python
   >>> from core.components.event.actions.player import Player
   >>> Player().add_item(self.app, (None, 'Potion'))

In this example, we add the item "Potion" to the player's inventory.

Start NPC Battle

You can start combat by typing the following into the Tuxemon python shell:

   python
   >>> from core.components.event.actions.combat import Combat
   >>> Combat().start_battle(self.app, (None, '1'))

This example starts a battle with the NPC with ID "1".

Start Random Battle

You can start a random battle by typing the following into the Tuxemon python shell:

   python
   >>> from core.components.event.actions.combat import Combat
   >>> Combat().random_encounter(self.app, (None, '1'))

This example will possibly start a battle with monsters from encounter group "1". Executing this is the same as stepping into a random encounter area, which may or may not trigger a battle depending on the monster's encounter rate in the encounter group.