Skip to content

Tuxemon Debug Console

meirw770 edited this page Jan 18, 2023 · 6 revisions

Tuxemon Debug Console

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/tuxemon.cfg configuration file with a text editor and change cli_enabled to 1.

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
   <tuxemon.core.client.Client object at 0x03B09F90>
python
  >>> from pprint import pprint  
  >>> pprint(self.app.__dict__)
  {'_remove_queue': [],
  '_state_dict':
    {'BackgroundState': <class 'tuxemon.core.states.start.BackgroundState'>,
    'ChoiceState': <class 'tuxemon.core.states.choice.ChoiceState'>,
    'CombatAnimations': <class 'tuxemon.core.states.combat.combat_animations.CombatAnimations'>,
    'CombatState': <class 'tuxemon.core.states.combat.combat.CombatState'>,
    ...
    'WorldMenuState': <class 'tuxemon.core.states.world.world_menus.WorldMenuState'>,
    'WorldState': <class 'tuxemon.core.states.world.worldstate.WorldState'>},
  '_state_queue': [],
  '_state_resume_set': {<tuxemon.core.states.start.BackgroundState object at 0x06A7A190>},
  '_state_stack': [<tuxemon.core.states.start.StartState object at 0x07465130>,
  <tuxemon.core.states.start.BackgroundState object at 0x06A7A190>],
 'caption': 'Tuxemon',
 'cli': <tuxemon.core.cli.CommandLine object at 0x04053C50>,

 ...
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 tuxemon.core.event.eventengine import EventEngine
   >>> EventEngine.execute_action(self.app.event_engine, 'add_monster', ['hydrone', 10])

In this example, we add the monster "Hydrone" at level 10 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 tuxemon.core.event.eventengine import EventEngine
   >>> EventEngine.execute_action(self.app.event_engine, 'add_item', ['potion'])

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

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

   python
   >>> from tuxemon.core.event.eventengine import EventEngine
   >>> EventEngine.execute_action(self.app.event_engine, 'random_encounter', ['routea'])

This example will possibly start a battle with monsters from encounter group "routea". 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.