GoldenEye: Source v4.2 introduced the use of Eclipse and PyDev to offer customized code completion and in-game debugging of your Python scripts. The following is a tutorial on how to setup Eclipse with PyDev and start your first debugging session.
First things first, you will need a copy of Python 2.6 and Eclipse.
Please follow this tutorial for help installing and using Eclipse: Eclipse Tutorial
After you have Eclipse fully installed and running you need to download a separate plugin for Eclipse called PyDev. This is free and open source, and thankfully Eclipse includes an update manager to download and install this for you.
Click the PyDev checkbox so that your update manager matches the picture to the right and press Next and follow the prompts to complete install.
Make sure you restart Eclipse when prompted.
For setup instructions and general navigation please refer to this tutorial. Usually, PyDev will find your interpreter automagically on first load.
An additional step must be completed in order to setup the GE:S predefines so that you can get code completion. Open the preferences diaglog and go to PyDev → Interpreter - Python and click the predefined tab (see image to right). Press New… and navigate to C:\<PATH_TO_STEAMAPPS>\gesource\scripts\python\lib and click the GESource directory, press OK.
We will not be setting up a new Python project, GE:S v4.2 ships with a project already setup for you. To load it into Eclipse, make sure you are on the PyDev perspective and right click inside the left pane (PyDev Project Explorer) and click Import…. Select Existing Projects Into Workspace… and hit next. Then click Browse… and select the C:\<PATH_TO_STEAMAPPS>\gesource\scripts\ directory, press OK. Once selected you should see python in the middle box, make sure the checkbox is selected then press Finish.
Congratulations if you made it this far! Your Eclipse layout should look something like the below image:
Some things to note:
Now that you are setup, let's do a sample debugging session. The first thing we need to do is start the debugging server in PyDev. To do this, click on the green bug icon next to the green stop icon that is below the menu bar. You should see “Debug Server at port: 5678” in the console.
Now load up GoldenEye: Source and create a game with a map of your choice. Once loaded, make sure we are playing Deathmatch which is what we will be debugging. Issue the command ge_gameplay deathmatch from the console.
Once complete, we need to connect the game to the debugger. To do this, issue the command ge_py_connectdebugger in the console. The screen will freeze briefly as the game communicates to the debugger, but should begin playing again shortly.
Now go back into Eclipse and set a breakpoint in the OnThink function by clicking the far left side of the editor at the line you want to break at (see image below). Once set, the game should immediately break at that point (since OnThink is called every 1/10 of a second). To see the debug information, click on the debug perspective in the upper right corner and view the information available. When you want to go back into the game press the Play button in the top left corner. You will have to remove the breakpoint in OnThink before resuming the game since it will break at that point every 1/10 second.
For more indepth information please consult the official PyDev readme: http://pydev.org/manual_101_root.html