Jump to content
RobertJohnson

How to use the modloader

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.

Share this post


Link to post
Share on other sites

Sweet!  Thanks RJ, the modloader is looking awesome.  I can pick up testing Xmod and SICmod with the next Steam build.  The require and new profession stuff is looking great.

Share this post


Link to post
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.

Share this post


Link to post
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 ;)

Share this post


Link to post
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.

Share this post


Link to post
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 ;)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

You should add that creating a file simply called "items.txt" in the "scripts" folder will make the mod fail (main menu will not load). This just took me a full hour to figure out :v

Share this post


Link to post
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 :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Am I putting the zipped folder into the mod file or something else? I followed the example mod folder thing but all that keeps showing up in the mod gui in the game launch is the example mod. Help? 

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...