cocolabs / pz-zdoc

ZomboidDoc is a Lua library compiler for Project Zomboid.
GNU General Public License v3.0
26 stars 10 forks source link
emmylua intellij lua modding-tools project-zomboid projectzomboid

ZomboidDoc

Java CD Maven Central codecov License chat

ZomboidDoc is an easy-to-use Java command-line application that compiles an annotated Lua library directly from modding API. Powered by IntelliJ IDEA it makes mod development an enjoyable experience by providing everything you need to write an amazing mod right from you IDE.

Introduction

Mods for Project Zomboid that change existing or add custom game logic are composed of scripts written in Lua language. Scripts accomplish this by interacting with Java classes exposed by the game engine (also known as modding API) which are documented online via Javadocs. Although useful, this documentation is often out of date and a bit of a hassle to read through, but does provide us with necessary information to start writing mods.

However we still lack a comfortable development environment required to stay motivated and creative. This is where ZomboidDoc comes in! It compiles a Lua library directly from exposed game classes using online modding API to get important information not stored in compiled code such as parameter names and comments.

Because ZomboidDoc reads directly from game code the compiled Lua library is guaranteed to always be up-to-date with your installed game version regardless of online API documentation - great when modding for beta game versions.

Features

Installation

Notes

Prerequisites

Gradle

The easiest way to install and use ZomboidDoc is with ZomboidMod, which has built-in support for all ZomboidDoc commands. Read project documentation to learn more about how to setup and use ZomboidMod.

It is also possible to setup ZomboidDoc with Gradle without using ZomboidMod:

repositories {
    mavenCentral()
}
dependencies {
    // https://search.maven.org/artifact/io.github.cocolabs/pz-zdoc
    implementation 'io.github.cocolabs:pz-zdoc:3.+'
}

Manual

How to use

Distribution

The release distribution archive contains two directories:

Launch Script

Follow these steps in order to launch ZomboidDoc:

  1. Open the terminal and navigate to ZomboidDoc bin directory.
    $ cd /D <absoulte_path_to_app_dir>/bin
  2. Set environment variable PZ_DIR_PATH to point to game installation directory.
    $ set PZ_DIR_PATH=<path_to_game_dir> - on Windows.
    $ export PZ_DIR_PATH=<path_to_game_dir> - on Unix.
  3. Launch ZomboidDoc with an appropriate launch script.
    $ start pz-zdoc.bat <command> <args> - on Windows.
    $ sh pz-zdoc <command> <args> - on Unix.

Read Commands and Examples section for more information.

Commands

Here is an overview list of available commands:

Notes to keep in mind when executing commands:

Examples

Launch ZomboidDoc on Windows:

@rem Navigate to application bin directory
@rem Application is installed in game root directory
cd /D E:\Games\Steam\steamapps\common\ProjectZomboid\pz-zdoc\bin

# Set environment variable to game installation directory
set PZ_DIR_PATH=%cd%\..\..\

# Annotate vanilla Lua files with EmmyLua
start pz-zdoc.bat annotate -i %PZ_DIR_PATH%\media\lua -o ..\media\lua

# Compile Lua library from modding API
start pz-zdoc.bat compile -i %PZ_DIR_PATH% -o ..\media\lua\shared\Library

# Check compile ouput directory
cd ..\media\lua && dir /B

Launch ZomboidDoc on Linux:

# Navigate to application bin directory
# Application is NOT installed in game root directory
cd /home/yooks/Documents/pz-zdoc/bin

# Set environment variable to game installation directory
export PZ_DIR_PATH=/home/yooks/.local/share/Steam/steamapps/common/ProjectZomboid/projectzomboid

# Annotate vanilla Lua files with EmmyLua
sh pz-zdoc annotate -i $PZ_DIR_PATH/media/lua -o ../media/lua

# Compile Lua library from modding API
sh pz-zdoc compile -i $PZ_DIR_PATH -o ../media/lua/shared/Library

# Check compile ouput directory
cd ../media/lua && ls

Lua library

Standalone

After compiling the library no additional steps are required and you can use it as-is with your favorite text editor.

Note that although the compiled Lua library can be used without any additional software integration it is intended to be used with IntelliJ IDEA to provide advanced features only available when using IDE.

IDE integration

Follow these steps to create a new mod project and enable IDE integration:

That's it, everything should be setup!

You can now continue modding with full confidence that everything you need to know to create an amazing mod is right at your fingertips. See list of features to remind yourself what to expect.

Discussion

Credits

License

This project is licensed under GNU General Public License v3.0.

FOSSA Status