Skip to content

A Python library that can read and modify most file formats used by the game Knights of the Old Republic and its sequel.

License

Notifications You must be signed in to change notification settings

th3w1zard1/PyKotor

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyKotor

A comprehensive Python library that can read and modify most file formats used by the game Knights of the Old Republic and its sequel.

Installation

  1. Clone the repository:

    git clone https://github.com/NickHugi/PyKotor
    cd PyKotor
    
  2. Install Poetry (if not already installed):

    pip install poetry
    
  3. Install the project and its dependencies:

    poetry install
    
  4. Activate the virtual environment:

    poetry shell
    

This will install PyKotor and all its subpackages in editable mode.

Requirements

PyKotor supports Python versions 3.8 and above. All dependencies are managed by Poetry. PyKotor is supported on most (if not all) operating systems, including Mac and other case-sensitive filesystems.

Running the tools

After installation and activating the virtual environment, you can run any of the provided tools, such as HoloPatcher, KotorDiff, or the Toolset, like this:

python Tools/HolocronToolset/src/toolset/__main__.py
python Tools/HoloPatcher/src/holopatcher/__main__.py
python Tools/KotorDiff/src/kotordiff/__main__.py

Development

To install development dependencies, use:

poetry install --with dev

This will install all the development tools like mypy, ruff, pylint, etc.

Running the tools

After installation, you can run any of the provided tools, such as HoloPatcher, KotorDiff, or the Toolset, like this:

python Tools/HoloPatcher/src/holopatcher/__main__.py
python Tools/HolocronToolset/src/toolset/__main__.py
python Tools/KotorDiff/src/kotordiff/__main__.py

See HoloPatcher's readme for more information

See HolocronToolset's readme for more information

Compiling/Building Available Tools:

After cloning the repo, open any of the powershell scripts in the compile folder such as compile_holopatcher.ps1 and compile_toolset.ps1 with PowerShell. Run the deps_holopatcher.ps1 or deps_toolset.ps1 first to get the dependencies setup. Doing so will start an automated process that results in a EXE being built/compiled to the PyKotor/dist folder. Specifically, those scripts will:

  • Find a compatible Python interpreter, otherwise will install Python 3.8
  • Setup the environment (the venv and PYTHONPATH)
  • Install the tool's dependencies. This is any pip packages they require from requirements.txt and recommended.txt
  • Install PyInstaller
  • Compile to executable binary, as one file, to the dist folder in the root level of this repository.

Working with Installation class in src:

Simple example of loading data from a game directory, searching for a specific texture, and exporting it to the TGA format.

from pykotor.resource.type import ResourceType
from pykotor.extract.installation import Installation
from pykotor.resource.formats.tpc import write_tpc

inst = Installation("C:/Program Files (x86)/Steam/steamapps/common/swkotor")
tex = inst.texture("C_Gammorean01")
write_tpc(tex, "./C_Gammorean01.tga", ResourceType.TGA)

As shown, this will save C_Gammorean01.tga to the current directory. More examples

Tests

These represent the currently passing/failing python versions/operating system combinations. Each badge is hyperlinked and permalinked to the full test report. Pick and choose any commit and see how far we have come.

Windows:

python-3.7-x86-Build_Failed python-3.7-x64-Build_Failed windows-2019-python-3.8-x86 windows-2019-python-3.8-x64 windows-2019-python-3.9-x86 windows-2019-python-3.9-x64 windows-2019-python-3.10-x86 windows-2019-python-3.10-x64 windows-2019-python-3.11-x86 windows-2019-python-3.11-x64 windows-2019-python-3.12-x86 windows-2019-python-3.12-x64

Linux:

python-3.7-x64-Build_Failed python-3.8-x64-Build_Failed python-3.9-x64-Build_Failed python-3.10-x64-Build_Failed python-3.11-x64-Build_Failed python-3.12-x64-Build_Failed

MacOS:

python-3.7-x64-Build_Failed macos-12-python-3.8-x64 macos-12-python-3.9-x64 macos-12-python-3.10-x64 macos-12-python-3.11-x64 macos-12-python-3.12-x64

License

This repository falls under the LGPL-3.0-or-later License.

About

A Python library that can read and modify most file formats used by the game Knights of the Old Republic and its sequel.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 72.0%
  • Python 27.2%
  • C++ 0.6%
  • PowerShell 0.2%
  • Shell 0.0%
  • Objective-C++ 0.0%