Scripts guide

From PZwiki
ModdingScripts guide
UI Tick.png
This page has been revised for the current stable version (41.78.16).
Help by adding any missing content. [edit]

Items, recipes, transportation, and sounds are defined in .txt script files. The files are located in the 'media/scripts' folder. The contents of the files are divided into {blocks}. The parameters of the elements are described in the blocks.

Introduction

Each type of element is described by its own set of parameters. However, the syntax for describing blocks is generally similar.

Example:

/** This line is a comment. Anything inside these brackets is ignored **/
module MyModModuleName {
    imports {
        Base
    }
    /** Comments can be multiline like this
        and can appear anywhere in the file, even in the
        middle of a { block }
    **/
    item MyItem
    {
        Type = Normal,
        DisplayName = My First Item,
        Icon = MyIcon,
        Weight = 0.1,
    }
}

Module block

A script file starts with module MyModModuleName. The name of the module (in the example MyModModuleName) can be anything you want for your mod. All items within this module will use this prefix for their naming convention. This name will be used as a prefix for the full type of your item (example: MyModModuleName.MyItem).

Most vanilla items use the module Base. If you utilize the Base item block, you do not need to import it. Be careful with the naming when utilizing Base module, so it does not match name of a vanilla game item (as it will overwrite the vanilla item).

A common practice is to use the modID as the module name. You can then import the Base item block if you need to utilize it. When you define your module name you do not need to use module.itemname you would just use itemname.

Imports block

Often in recipes and item blocks, you need to reference vanilla items or items from other mod's script modules. By importing the Base module (or any other module), you give your scripts direct access to the elements from these modules, and you can use item IDs without adding the module prefix (for example, you can use Nails instead of Base.Nails).

Tips

  1. Attention: After each parameter line in block need write coma! Even on the last line. If you skip the comma, the line will not be read by the game.
  2. You don't have to set all values. Values you do not set will be set by default.

Item block structure

Each item in the game is set by a script, which determines the parameters of the item. Depending on the type of item, different parameters will be used.

Item script block guide

Fixing block structure

Fixing blocks are used to fix items in Project Zomboid. For example, repairing Wood Axe with different materials.

Fixing script block guide

Recipe block structure

Recipes are a description of the ingredients for crafting an item and a description of the item that will result from crafting.

Recipe script block guide

Evolved recipe block structure

This type of recipe is used to easily create food recipes that can be filled with many ingredients.

Evolved recipe script block guide

Sound block structure

The block sets the sound parameters, which can then be used in the game.

Sound script block guide

Model block structure

The block describes the parameters of the model that will be used.

Model script block guide

Vehicle block structure

The block describes the parameters of the vehicle.

Vehicle script block guide

Multistagebuild block structure

The block describes an option to improve/create a multi stage building.

Multistagebuild script block guide