Simple monkey-patching library to make for amazing ANSI experiences in MUDs
Project description
Volund's MudString library for Python
CONTACT INFO
Name: Volund
Email: volundmush@gmail.com
PayPal: volundmush@gmail.com
Discord: Volund#1206
Discord Channel: https://discord.gg/Sxuz3QNU8U
Patreon: https://www.patreon.com/volund
Home Repository: https://github.com/volundmush/mudstring-python
TERMS AND CONDITIONS
MIT license. In short: go nuts, but give credit where credit is due.
Please see the included LICENSE.txt for the legalese.
INTRO
MUD (Multi-User Dungeon) games and their brethren like MUSH, MUX, MUCK, and MOO (look 'em up!) use various ANSI features to provide colors to clients. Sadly there aren't many libraries out there which allow advanced manipulation of such text which preserve the formatting already applied to it. This attempts to address this problem.
mudstring is built upon the existing library, rich, using monkey-patching to hack in support for MXP (Mud eXtension Protocol). So, in order to use this library effectively, one must familiarize themselves with Rich. Rich is awesome, so be sure and do that soon.
FEATURES
- Everything Rich can do. Seriously, check it out...
- MXP Support.
- Encodings library, containing fully-working examples for how to implement various ANSI systems used by existing games.
OKAY, BUT HOW DO I USE IT?
Glad you asked.
Early on in your program, you should...
import mudstring
mudstring.install()
This will monkey-patch Rich for this process, replacing a few classes with ones from MudString in a way that will still allow Rich to do everything it normally does. From here on out, though, importing from Rich will net you the patched versions of classes like Style, Text, and Console.
Afterwards, instantiating a MudConsole and directing some output to an output buffer is this easy.
# this will get the MudCOnsole and MudText if install() has been run!
from rich import Console
from rich.text import Text
from mudstring.util import OutBuffer
buffer = bytearray()
out = OutBuffer(buffer)
con = Console(color_system="256", mxp=True, soft_wrap=True, file=out)
con.print(Text("Have some red text!", style="red"))
Afterwards, buffer
will contain the formatted red text.
Note that MudString's Text class for Rich implements a great deal more of the Python String API than Rich's original version, allowing for advanced text formatting - though, unfortunately, no f-strings or str.format() - it won't preserve the styling...
FAQ
Q: This is cool! How can I help?
A: Patreon support is always welcome. If you can code and have cool ideas or bug fixes, feel free to fork, edit, and pull request! Join our discord to really get cranking away though.
Q: I found a bug! What do I do?
A: Post it on this GitHub's Issues tracker. I'll see what I can do when I have time. ... or you can try to fix it yourself and submit a Pull Request. That's cool too.
Q: But... I want a MUD! Where do I start making a MUD?
A: check out pymush and athanor
Special Thanks
- The absolutely awesome lunatics who wrote PennMUSH's ANSI library.
- The Evennia Project.
- All of my Patrons on Patreon.
- Anyone who contributes to this project or my other ones.
- The Rich devs. That library is a godsend.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mudstring-0.5.0.tar.gz
.
File metadata
- Download URL: mudstring-0.5.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2a7aba6287fa2cfed359ccc0c0a5113972a8f80c776c59fdc2fc15daafe8671 |
|
MD5 | b202189a767ee89751c36712c3514996 |
|
BLAKE2b-256 | da98dec8a0a269694256f966d7d469805bbbb24e08a8d1289d42f0f429ec1486 |
File details
Details for the file mudstring-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: mudstring-0.5.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 310a044b063b124593fe69aa436a994d902ae990fa2d64172b4816c3effaa781 |
|
MD5 | b34f62c8716c2bb0eea2170b342529d8 |
|
BLAKE2b-256 | 86f5c1666059a10acde2ec56c914acea176d5d355dc7f521b0ef2dfb61fce08a |