# Handling Script Commands

## Handling Script Commands

By adding a custom command to your script, you can do something when it reaches it, with Python. It's easy to do and adds more functionality to scripts.

## Example

1. Add `do_something_here` your walk script
2. Add a `do_something_here(arguments)` function to your Python script

```
def do_something_here(arguments):
    log('%s' % arguments)
    return 0
```

* When the bot reaches `do_something_here` in your walk script, it will pass it over to your Python script. All script commands are passed to Python whether you have a function for it or not.
* The `return 0` is for how many milliseconds to sleep. This is necessary because the bot must lock the Python interpreter in order to keep everything thread safe. If you slept manually and another thread attempted to call one of your functions, it would block until you returned from the function and the global interpreter lock was released.

## Example Arguments

Arguments that get passed to your function must be comma separated in the walk script. They are then parsed into a `list` and sent to your Python script.

```
['walk', '6434', '1099', '-32']
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://plugins.phbot.org/handling-script-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
