📚 | Overview
PythonToSW is a Python package that allows you to create addons in Stormworks: Build and Rescue with Python through HTTP using FastAPI under the hood.
Documentation: https://pythontosw.cuhhub.com/
Working Example
from PythonToSW import (
Addon,
CallEnum,
)
addon = Addon(
"Testing",
path = ".",
port = 2000
)
def on_start():
"""
Called when the addon starts (connects with in-game addon).
"""
# If you was to code a Lua addon with the same behaviour, it'd look like: server.announce("Server", "Hello world!")
addon.call(CallEnum.ANNOUNCE, "Server", "Hello world!")
def on_stop():
"""
Called when the addon stops (disconnects with in-game addon).
"""
print("Whups, we lost connection!")
def on_tick():
"""
Called every addon tick.
"""
pass
# Call `on_tick` every addon tick
# Note that this doesn't connect to the in-game `onTick` callback as HTTP would not be able to keep up
# Instead, this is a simulated version that is called at a manageable rate (32 TPS, theoretical max)
addon.on_tick += on_tick
# Start the addon
# `on_start` is called when the in-game addon connects
# `on_stop` is called when the in-game addon disconnects (game exited, etc.)
addon.start(on_start, on_stop)
More examples can be found in the examples directory.
📚 | Documentation
Click here for the documentation.
⚙️ | Installing this package
- Use
pip install PythonToSW --upgrade - Import the package with
import PythonToSW as PTSin your code
✅ | Advantages
- Since the addon is running outside of the game, you get much more control with your addon and aren't limited by the limitations of Stormworks Lua.
- You can send HTTP requests to places other than localhost, and using methods other than
GET. - You can write to/read from files.
- ... and so on.
- You can send HTTP requests to places other than localhost, and using methods other than
- Classes (since we're using Python here)
- The source code of your addon can't be accessed via malicious actors.
- Yup. If someone with malicious intent is in a server with an addon, they can get the addon's raw code (although difficult to do).
- Because PythonToSW uses HTTP and doesn't compile code to Lua, the Python source code is completely hidden and the only code malicious actors can get is the Lua code that connects to the PythonToSW server (which is already open-source).
❌ | Disadvantages
- Noticeable delays. This project works through HTTP instead of converting Python code to Lua code, and HTTP is unfortunately slow (limited to one request every two ticks, aka 32 requests/sec).
- For your addon to function, the host of the server must run the Python script behind your addon. Closing the Python script will essentially stop the addon.
- Uploading your addon to the workshop is pointless as the Python code is what makes your addon work. Distributing your addon therefore becomes harder and less convenient for users to download and use.
✨ | Credit
- Cuh4 (GitHub)
Metadata
Release files for PythonToSW 2.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pythontosw-2.1.1.tar.gz | 97.4 kB | Without provenance | Details for pythontosw-2.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pythontosw-2.1.1-py3-none-any.whl | Python 3 | none | any | Details for pythontosw-2.1.1-py3-none-any.whl |
Total release size: 201.0 kB
Release files / pythontosw-2.1.1.tar.gz
| Download URL | pythontosw-2.1.1.tar.gz |
|---|---|
| Size | 97.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21c83ae0d5164eb19c09cc4607edca94b5fb2d82446ad7fbd3365ea261e36e30
|
|
BLAKE2b-256 checksum How to use checksums |
6b37fef0249af361853e60a82a6c41c981e852792e4c58e674f12aae402d6385
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / pythontosw-2.1.1-py3-none-any.whl
| Download URL | pythontosw-2.1.1-py3-none-any.whl |
|---|---|
| Size | 103.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
224210c8adcd22a1b7d7eeb0e1e4c067346a600e269de25efaea1a8ba7955251
|
|
BLAKE2b-256 checksum How to use checksums |
aaf2cf30441aa807f1732101f44a69cf89360fbccc1f77a81c5cd37173d2542d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for PythonToSW 2.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.