Jump to content

How to use the modloader


RobertJohnson

Recommended Posts

Howdy,

 

Here's a description of how to add your mod in PZ.

 

First, the folder tree :

zomboidFolder    |-- mods        |-- MyMod/            |-- poster.png            |-- mod.info            |-- media/                |-- lua/                    |-- lua1.lua                    |-- UI/                        |-- myUI.lua                |-- sounds/                    |-- myCustomSound.ogg                |-- textures/                    |-- Item_customItem.png                    |-- Prof_customProfession.png                |-- ui/                    |-- Traits/                        |-- trait_customtrait.png                |-- scripts/                    |-- myCustomItems.txt

Let's explain now :)

 

      1. The very important mighty mod.info

 

The mod.info file will contains a full description of your mod, along with other great stuf, here's an example :

name=My custom mod v1.7id=RJCustomModposter=poster.pngdescription=Here's a description of my awesome custom mod.require=Utility, CustomMod2url=http://theindiestone.com/forums/index.php

name = the name displayed in the mod selector.

id = an unique ID you need to find, it'll be used for the require stuff for example.

poster = the .png image which be displayed when someone click on your mod in the mod selector.

description = a full description of your mod.

require = you can add a list (separated by ",") of id of  mods which are required for your mod to works, for example if you want to add an Utility mod you use, or if you just want to make change on another mod, etc.

url = the url of your mod (indiestone forum, xeno-mods or pz-mods only), it'll be displayed as a button under the poster, click on it will open your default browser to this url.

 

The only essential tag is "name". All the others are optional and can be left out.

 

Here come my über paint skillz to show you how it look like in game :

 

2zjl7gl.png

 

Please don't be shy, you can compliment me on my paint skillz, I know I pwn everything.

 

      1.1 A bit more stuff about the require.

 

The require work recursively, for example if you have 3 mods, mod A require mod B, mod B require mod C. If you don't have the mod C, you couldn't activate the mod A, a red cross will be displayed if you miss some of the mods required :

1z6sgwk.png

Here, my test1 mod need the test2, I have it, but the test2 require exampleMod, which I don't have, so I can't use the test1 mod.

 

If now I have all my mod (A,B and C), and I double click on the mod A, the mod B and C will also be activated.

And then if I disable the mod B, the mod A will also be disabled, because it require the mod B to work.

 

Then, the require mod is also used to load your mod in a certain order, for example if mod A require mod B, then mod B will be loaded in the game before mod A.

 

Remember, you have to use the ID of the mod, not the name or the folder's name.

 

        2. The lua files.

 

The lua files are loaded after the vanilla lua files, which mean you can override the existing lua file (example, I make a new UI/ISLabel.lua file).

All the .lua extension file will be loaded, even if they're inside folders.

 

        3. Customize your items.txt !

 

You can add custom items for your mods, you just have to place them inside /scripts/ folder.

You can override existing items or make new one.

Here's an example :

 

module custom {        item myNewItem	{		HungerChange	=	-10,		Weight	=	0.1,		Type	=	Food,		DangerousUncooked	=	TRUE,		DaysTotallyRotten	=	21,		DisplayName	=	Egg,		Icon	=	customEgg,		DaysFresh	=	14,	}}

 

Here I created a new item (please note I used the module custom, but I could use the module Base if I wanted to).

 

Now I want to override existing item, if you make a file named items.txt, it'll override the existing items.txt, it mean we gonna load YOUR items.txt and not the vanilla one, so be carefull to do it, use this only if you want to replace EVERY ITEM or a bunch of them.

If you want to modify only some items, here's the solution :

You make a file named as you want (except items.txt), like customItems.txt, and inside it, do that :

 

module Base{item Egg    {        HungerChange    =    -50,        Weight    =    5,        Type    =    Food,        DangerousUncooked    =    TRUE,        DaysTotallyRotten    =    21,        DisplayName    =    Egg,        Icon    =    customEgg,        DaysFresh    =    14,    }}

 

Here I overrided the Egg, by setting the module Base (which is the one in items.txt).

Now the egg will weight 5 and give 50 hunger reduction.

 

        3. The custom textures

 

In the /textures/ folder, you can add your custom textures.

You can add textures for items, trait and profession.

 

        3.1 The custom item icon

 

To add a custom item icon, you just need to add the image in the textures/ folder, named like that :

Item_iconname.png

Here's an example of my item :

 

item myNewItem    {        HungerChange    =    -10,        Weight    =    0.1,        Type    =    Food,        DangerousUncooked    =    TRUE,        DaysTotallyRotten    =    21,        DisplayName    =    Egg,        Icon  =   customEgg,        DaysFresh    =    14,    }

 

So my item icon will be textures/Item_customEgg.png.

 

You also can override items icon, for example just place a textures/Item_Axe.png file, and this one will be taken instead of the vanilla one.

 

        3.2 The custom trait icon

 

To add a custom trait icon, you have to add your image in the ui/Traits/ folder like this :

ui/Traits/trait_yourtraitid.png

The trait ID is the first parameter when you add a trait, it need to be in lower case, example :

TraitFactory.addTrait("Athletic", getText("UI_trait_athletic"), 6, getText("UI_trait_athleticdesc"), false);

To add an icon for this trait, I need to add a ui/Traits//trait_athletic.png  image, the name is Athletic, but as I said, the name of the image have to be in lower case.

You can also override the existing one, for example just put in your mod folder an new ui/Traits/trait_brave.png, and there you go, the brave trait will now take your image instead of the vanilla one.

 

        3.3 The custom profession icon

 

It's almost the same as the trait, in your textures/ folder, you image have to start by "Prof_", example :

Prof_professionIcon.png

The icon of the profession is the last parameter (no need to be lower case on this one) :

ProfessionFactory.addProfession("fireofficer", getText("UI_prof_fireoff"), "Prof_FireFighter");

In this case,my .png file will be : textures/Prof_FireFighter.png.

 

You can add new one and override existing one.

 

 

 

And here you go for now :)

 

Please, don't hesitate to suggest new stuff for the mod.info or the mod loader, and tell me if there's any bugs :)

 

Oh also, everything will be in for the next steam version only.

Link to comment
Share on other sites

Wouldn't it be more user friendly if in "require" field it displays the "name=" of the mod , instead of "id="? It'd still look for "id=" in the general game folder, but it'll do that off-screen, so it doesn't scare away those who aren't really into mods yet.

 

That would look atleast a bit more customer-friendly, instead of modder-friendly. The game is, after all, made for customers :P

1z6sgwk.png

 

The way it will look like :

"requires : Test 2 by RobertJohnson v1.5"

instead of

"requires : test2"

 

UNLESS it already works like that And I'm just a noobinator that needs some sleep and coffee.

Link to comment
Share on other sites

The id is not the same as the name field quiet often. The reasoning behind it is pretty simple. When you first release your mod you choose a name AND a (unique) id. The name can be changed on any release whereas the id should stay the same for all eternity. Why? Because other modders can "require" your mod and be sure that it always will be true even if you update your mod.

Release:

name=My Awesome Mod (2.0.0)id=rm_MyAwesomeMod
Update:

name=Even Awesomer Mod (2.9.3)id=rm_MyAwesomeMod
Of course this still relies on the human factor called modder, but I'm sure that if people don't follow the rule no one will require their mods for long ;):P

BESIDES:

The only essential tag is "name". All the others are optional and can be left out.

It is optional ;)

Link to comment
Share on other sites

The id is not the same as the name field quiet often. The reasoning behind it is pretty simple. When you first release your mod you choose a name AND a (unique) id. The name can be changed on any release whereas the id should stay the same for all eternity. Why? Because other modders can "require" your mod and be sure that it always will be true even if you update your mod.

Release:

name=My Awesome Mod (2.0.0)id=rm_MyAwesomeMod
Update:

name=Even Awesomer Mod (2.9.3)id=rm_MyAwesomeMod
Of course this still relies on the human factor called modder, but I'm sure that if people don't follow the rule no one will require their mods for long ;):P

BESIDES:

The only essential tag is "name". All the others are optional and can be left out.

It is optional ;)

 

 

I'm sure you didn't fully get what I mean right there :P

 

What I wanted to say was, the "unique" ID can still be mandatory to load one of the mods, but for the sake of simplicity, wouldn't it be better if instead of redirecting to "You need this ID with weird name with no spaces" it would redirect you to "You need this awesome mod version 1.5 that has this unique ID", kind of VISUALLY showing you that you need the "Name" of the mod, but in the end actually requiring the "ID" of it?

 

So, in your example, it would look like :

 

require :My Awesome Mod (2.0.0)

 

(which is)

id=rm_MyAwesomeMod

 

It'll still require that specific ID, but you'll know what that actually means, so instead of browsing through countless forums finding what that "ID" actually is, you can simply look for the name of the mod.

Link to comment
Share on other sites

Yeah but that's what I meant.

If you do

require: My Awesome Mod (2.0.0.)
and the mod has already been updated to

name=My Awesome Mod (2.0.1.)
it won't be able to find that mod.

Unless I'm really not getting what you mean :P Besides searching for the id of the mod is as easy as checking that mod's "id" in the mod.info ;)

Link to comment
Share on other sites

Yeah but that's what I meant.

If you do

require: My Awesome Mod (2.0.0.)
and the mod has already been updated to

name=My Awesome Mod (2.0.1.)
it won't be able to find that mod.

Unless I'm really not getting what you mean :P Besides searching for the id of the mod is as easy as checking that mod's "id" in the mod.info ;)

 

 

It will still require the specific ID (Which you don't really change after update), but visually it will tell you that it requires "My Awesome Mod" :P

 

It's easy to search for "specific" id once you have the MOD installed on your PC, but what if you download some mod, and it will require some ID, that looks like this : "id=rm_am1". Then you'd have to search the forums for hours to find out which of the mods have that specific "rm_am1" ID. Instead, it will display the NAME that you need, but in fact, it will STILL require that specific ID. It is just to simplify things, I am not asking the "require" to change from specific ID to specific mod name, as those do tend to change.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

From OP : Now I want to override existing item, if you make a file named items.txt, it'll override the existing items.txt.

 

So it's on purpose, if you want to override many items... Tho you'll need the base items, or you also have to modify the whole loot distribution to avoid any bug :)

Link to comment
Share on other sites

From OP : Now I want to override existing item, if you make a file named items.txt, it'll override the existing items.txt.

 

So it's on purpose, if you want to override many items... Tho you'll need the base items, or you also have to modify the whole loot distribution to avoid any bug :)

ohohoh, I didn't read everything! :c

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
The trait ID is the first parameter when you add a trait, it need to be in lower case, example :
TraitFactory.addTrait("Athletic", getText("UI_trait_athletic"), 6, getText("UI_trait_athleticdesc"), false);

The icon of the profession is the last parameter (no need to be lower case on this one) :

ProfessionFactory.addProfession("fireofficer", getText("UI_prof_fireoff"), "Prof_FireFighter");

Hey RobertJohnson, great Tutorial. However, I have reposted the quoted the two aspect from your post that are a little contradicting. First, you mention it needs to be lower case but in the example you use capital "Athletic". Second you say no need to be lower case but you then you use lower case. 

Link to comment
Share on other sites

Hey RobertJohnson, great Tutorial. However, I have reposted the quoted the two aspect from your post that are a little contradicting. First, you mention it needs to be lower case but in the example you use capital "Athletic". Second you say no need to be lower case but you then you use lower case.

IIRC that was during a time when the modloader differentiated between lower and uppercase for the icon loading. Not sure if it still works like that. The profession in my lockpicking mod works fine so far - I can post the code later if I don't forget.

Link to comment
Share on other sites

  • 1 month later...

Can someone help me? I don't seem to be able to install mods for this game ( i'm on a mac ) , I tried Users/User/Zomboid/Mods <- put mod file there but still I can't see the mod when I go into the game in mods section. I really need help I'm literally breaking my head trying to think of a solution. ( i'm on steam ) Also sorry for my bad english.

Link to comment
Share on other sites

  • nasKo unpinned this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...