readme edit: replace launch.png with text, CRLF->LF
This commit is contained in:
parent
884920ab91
commit
f1384fc289
2 changed files with 156 additions and 124 deletions
|
|
@ -1,125 +1,157 @@
|
||||||
# In-game debugpy command
|
# In-game debugpy command
|
||||||
|
|
||||||
This registers an in-game command `debugpy` which starts the debugpy debugger and listens on port 5678.
|
This registers an in-game command `debugpy` which starts the debugpy debugger and listens on port 5678.
|
||||||
For now this is only available for Visual Studio Code (VS Code).
|
For now this is only available for Visual Studio Code (VS Code).
|
||||||
|
|
||||||
If you are a JetBrains PyCharm user and would like to use this, make some noise at:
|
If you are a JetBrains PyCharm user and would like to use this, make some noise at:
|
||||||
https://youtrack.jetbrains.com/issue/PY-63403/Support-debugpy
|
https://youtrack.jetbrains.com/issue/PY-63403/Support-debugpy
|
||||||
|
|
||||||
|
|
||||||
Credit for this goes to Moony on the Evennia Discord getting-help channel, thx Moony!
|
Credit for this goes to Moony on the Evennia Discord getting-help channel, thx Moony!
|
||||||
|
|
||||||
0xDEADFED5 simply tied a pretty bow around it and stuck it here for everybody else.
|
0xDEADFED5 simply tied a pretty bow around it and stuck it here for everybody else.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
This requires VS Code and debugpy, so make sure you're using VS Code.
|
This requires VS Code and debugpy, so make sure you're using VS Code.
|
||||||
|
|
||||||
From the venv where you installed Evennia run:
|
From the venv where you installed Evennia run:
|
||||||
|
|
||||||
`pip install debugpy`
|
`pip install debugpy`
|
||||||
|
|
||||||
## Enable the command in Evennia
|
## Enable the command in Evennia
|
||||||
|
|
||||||
In your Evennia mygame folder, open up `\commands\default_cmdsets.py`
|
In your Evennia mygame folder, open up `/commands/default_cmdsets.py`
|
||||||
|
|
||||||
add `from evennia.contrib.utils.debugpy.cmd import CmdDebugPy` somewhere near the top.
|
add `from evennia.contrib.utils.debugpy.cmd import CmdDebugPy` somewhere near the top.
|
||||||
|
|
||||||
in CharacterCmdSet.at_cmdset_creation add this under `super().at_cmdset_creation()`:
|
in CharacterCmdSet.at_cmdset_creation add this under `super().at_cmdset_creation()`:
|
||||||
|
|
||||||
`self.add(CmdDebugPy)`
|
`self.add(CmdDebugPy)`
|
||||||
|
|
||||||
For a newly initialized game, the result would look like this at the top of the file:
|
For a newly initialized game, the result would look like this at the top of the file:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
"""
|
"""
|
||||||
Command sets
|
Command sets
|
||||||
|
|
||||||
All commands in the game must be grouped in a cmdset. A given command
|
All commands in the game must be grouped in a cmdset. A given command
|
||||||
can be part of any number of cmdsets and cmdsets can be added/removed
|
can be part of any number of cmdsets and cmdsets can be added/removed
|
||||||
and merged onto entities at runtime.
|
and merged onto entities at runtime.
|
||||||
|
|
||||||
To create new commands to populate the cmdset, see
|
To create new commands to populate the cmdset, see
|
||||||
`commands/command.py`.
|
`commands/command.py`.
|
||||||
|
|
||||||
This module wraps the default command sets of Evennia; overloads them
|
This module wraps the default command sets of Evennia; overloads them
|
||||||
to add/remove commands from the default lineup. You can create your
|
to add/remove commands from the default lineup. You can create your
|
||||||
own cmdsets by inheriting from them or directly from `evennia.CmdSet`.
|
own cmdsets by inheriting from them or directly from `evennia.CmdSet`.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from evennia import default_cmds
|
from evennia import default_cmds
|
||||||
from evennia.contrib.utils.debugpy.cmd import CmdDebugPy
|
from evennia.contrib.utils.debugpy.cmd import CmdDebugPy
|
||||||
|
|
||||||
class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
||||||
"""
|
"""
|
||||||
The `CharacterCmdSet` contains general in-game commands like `look`,
|
The `CharacterCmdSet` contains general in-game commands like `look`,
|
||||||
`get`, etc available on in-game Character objects. It is merged with
|
`get`, etc available on in-game Character objects. It is merged with
|
||||||
the `AccountCmdSet` when an Account puppets a Character.
|
the `AccountCmdSet` when an Account puppets a Character.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
key = "DefaultCharacter"
|
key = "DefaultCharacter"
|
||||||
|
|
||||||
def at_cmdset_creation(self):
|
def at_cmdset_creation(self):
|
||||||
"""
|
"""
|
||||||
Populates the cmdset
|
Populates the cmdset
|
||||||
"""
|
"""
|
||||||
super().at_cmdset_creation()
|
super().at_cmdset_creation()
|
||||||
#
|
#
|
||||||
# any commands you add below will overload the default ones.
|
# any commands you add below will overload the default ones.
|
||||||
#
|
#
|
||||||
self.add(CmdDebugPy)
|
self.add(CmdDebugPy)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Add "remote attach" option to VS Code debugger
|
## Add "remote attach" option to VS Code debugger
|
||||||
|
|
||||||
Start VS Code and open your launch.json like this:
|
Start VS Code and open your launch.json like this:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Add this to your configuration:
|
Add this to your configuration:
|
||||||
|
|
||||||
```
|
```json
|
||||||
{
|
{
|
||||||
"name": "Python Debugger: Remote Attach",
|
"name": "Python Debugger: Remote Attach",
|
||||||
"justMyCode": false,
|
"justMyCode": false,
|
||||||
"type": "debugpy",
|
"type": "debugpy",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"connect": {
|
"connect": {
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 5678
|
"port": 5678
|
||||||
},
|
},
|
||||||
"pathMappings": [
|
"pathMappings": [
|
||||||
{
|
{
|
||||||
"localRoot": "${workspaceFolder}",
|
"localRoot": "${workspaceFolder}",
|
||||||
"remoteRoot": "${workspaceFolder}"
|
"remoteRoot": "${workspaceFolder}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `localhost` for the host if you are running Evennia from the same machine you'll be debugging from. Otherwise, if you want to debug a remote server, change host as necessary.
|
Use `localhost` for the host if you are running Evennia from the same machine you'll be debugging from. Otherwise, if you want to debug a remote server, change host (and possibly remoteRoot mapping) as necessary.
|
||||||
|
|
||||||
Afterwards it should look something like this:
|
Afterwards it should look something like this:
|
||||||
|
|
||||||

|
```json
|
||||||
|
{
|
||||||
(notice the comma between the curly braces)
|
// Use IntelliSense to learn about possible attributes.
|
||||||
|
// Hover to view descriptions of existing attributes.
|
||||||
## Use it
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
Set a breakpoint in VS Code where you want the debugger to stop at.
|
"configurations": [
|
||||||
|
{
|
||||||
In Evennia run `debugpy` command.
|
"name": "Python Debugger: Current File",
|
||||||
|
"type": "debugpy",
|
||||||
You should see "Waiting for debugger attach..."
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
Back in VS Code attach the debugger:
|
"console": "integratedTerminal",
|
||||||
|
},
|
||||||

|
{
|
||||||
|
"name": "Python Debugger: Remote Attach",
|
||||||
Back in Evennia you should see "Debugger attached."
|
"justMyCode": false,
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "attach",
|
||||||
|
"connect": {
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5678
|
||||||
|
},
|
||||||
|
"pathMappings": [
|
||||||
|
{
|
||||||
|
"localRoot": "${workspaceFolder}",
|
||||||
|
"remoteRoot": "${workspaceFolder}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
(notice the comma between the curly braces)
|
||||||
|
|
||||||
|
## Use it
|
||||||
|
|
||||||
|
Set a breakpoint in VS Code where you want the debugger to stop at.
|
||||||
|
|
||||||
|
In Evennia run `debugpy` command.
|
||||||
|
|
||||||
|
You should see "Waiting for debugger attach..."
|
||||||
|
|
||||||
|
Back in VS Code attach the debugger:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Back in Evennia you should see "Debugger attached."
|
||||||
|
|
||||||
Now trigger the breakpoint you set and you'll be using a nice graphical debugger.
|
Now trigger the breakpoint you set and you'll be using a nice graphical debugger.
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 57 KiB |
Loading…
Add table
Add a link
Reference in a new issue