What is this?
d2txt.py is a Python 3 module for editing Diablo 2 *.TXT files. It provides the D2TXT class, which can be used to read, modify, and save a TXT file. If you're into systematically balancing your mod, or want to write your own mod-making script, check it out!
I wrote several sample scripts for my own use, but they may be useful for other modders. Check them out to see how D2TXT can be used.
d2ini.py is a command-line Python script that "decompiles" a TXT file to an INI file, or "compiles" an INI file to a TXT file. INI files have several advantages over TXT files:
- Easy to read in code editors
- Easy to post on the forums
- Play nice with version control (Git, Subversion, etc.)
- Provide pretty diff logs
Code: Select all
firewallmaker 68 6 6 4 no light freq 12 12 7 2 8 255 178 64 0 0 1 groundFireBig 1024 2 16 1 1 2 8 1 1 1 1 1 8 32 1 firewall firewall firesmall firemedium 0
Code: Select all
[69]
Missile=firewallmaker
Id=68
pCltDoFunc=6
pSrvDoFunc=6
CltParam1=4
*client param1 desc=no light freq
Vel=12
MaxVel=12
Range=7
LevRange=2
Light=8
Red=255
Green=178
Blue=64
InitSteps=0
Activate=0
LoopAnim=1
CelFile=groundFireBig
animrate=1024
AnimLen=2
AnimSpeed=16
SubLoop=1
SubStart=1
SubStop=2
CollideType=8
LastCollide=1
ClientCol=1
ClientSend=1
Size=1
Trans=1
HitShift=8
HitClass=32
NumDirections=1
SubMissile1=firewall
CltSubMissile1=firewall
CltSubMissile2=firesmall
CltSubMissile3=firemedium
EOL=0
How do I use it?
To use d2txt.py or d2ini.py, you must install Python 3.6 or higher. If you want support for older versions, let me know.
To use d2txt.py, simply copy the d2txt directory into your script directory (You can add it to PYTHONPATH instead if you wish). Then add the following statement at the top of your python script:
Code: Select all
from d2txt.d2txt import D2TXT
Code: Select all
./d2ini.py decompile <txt_to_compile> <ini_to_save_to>
./d2ini.py compile <ini_to_compile> <txt_to_save_to>
For more information, check out the project page.