Jump to content

[Tutorial] Creating an optional, alternate costume/patch-mod


Recommended Posts

As a companion to my challenge, I give you a tutorial for something which is actually very simple, but can be a little confusing, if you get the specifics wrong.

 

Bear in mind that this method will work for replacing or patching any part of a mod - you could alter item graphics, stats, strings, or basically anything else.

In fact, by altering strings through this method, you could create a translation patch for your mod!

This effectively allows us to have customisable options for our mods... though each "option" must be presented as its own add-on mod.

 

So, here's the breakdown:

 

 

We will need only two files as basic necessity.
The modmain, and the modinfo.

 

MODINFO:
This is much the same as usual - fill it in as you would any other mod. However, there is an important extra step:
Make sure you add a load priority! This is what makes the patch work.

name = "NAME"description = "DESCRIPTION"author = "AUTHOR"version = "X"priority = -1

Here is an example - for most patches, priority of -1 will work, since default priority is set at 0, and load order is determined by highest number first. (Priority 100 will load before Priority 1. I use negative numbers, because default is zero, and is seldom changed.)
If you have set a lower priority for the mod you are patching, you must use a lower number for the priority.

 

MODMAIN:

When the mod loads afterwards in priority, it overwrites anything that was set in both mods. This is how we patch it.

For example, the base mod defines the following string:

STRINGS.NAMES.OCARINA = "Hero's Ocarina"

We can alter that with our patch, by adding to the patch's modmain:

STRINGS.NAMES.OCARINA = "Ocarina of Time"

Since the string is defined by both the base mod and the patch, the load order is important. By making the patch load afterwards, it overwrites that setting.

 

Since this patch mod loads afterwards, we can also alter any prefab, or other bit of code, defined in the main mod through post-inits in the modmain:

function PATCHPostInit( inst )inst.components.hunger:SetMax(300)  end   AddPrefabPostInit("mymod", PATCHPostInit)

In this example, the "mymod" character prefab is having its max hunger set to 300 - overwriting whatever it was previously.

 

 

ALTERING IMAGES/ANIMS:

The part you all came here for!

This works on the same principle that anything that occupies the same space, and is loaded afterwards, will fill that space.

 

First, you need to add your anim/image where it goes in the other mod. For example, you would like to patch the anim for "froggy" - your original "froggy" art was green, but you've decided to make a patch for people who would prefer froggy to be brown.
So you've altered the art for froggy, and converted it to tex.

 

The first thing you have to make sure is that you use the same file and build names.

It was "anim/froggy.zip" in the original mod, and it will be "anim/froggy.zip" in the patch.

 

We can then load the asset into the game, and overwrite what was loaded in the original mod. This only replaces the file used for the asset - the original mod still dictates when and how it is used.

We simply need the following code in our modmain:

Assets = {         Asset( "ANIM", "anim/froggy.zip" )    }

So that's it!

Very simple, and very versatile. Can be used for stat tweaks, translations, and most importantly... adding alternate costumes to your mod characters! ^^

Have fun, everyone!

Link to comment
Share on other sites

As a companion to my challenge, I give you a tutorial for something which is actually very simple, but can be a little confusing, if you get the specifics wrong.

 

Bear in mind that this method will work for replacing or patching any part of a mod - you could alter item graphics, stats, strings, or basically anything else.

In fact, by altering strings through this method, you could create a translation patch for your mod!

This effectively allows us to have customisable options for our mods... though each "option" must be presented as its own add-on mod.

 

So, here's the breakdown:

 

 

We will need only two files as basic necessity.

The modmain, and the modinfo.

 

MODINFO:

This is much the same as usual - fill it in as you would any other mod. However, there is an important extra step:

Make sure you add a load priority! This is what makes the patch work.

name = "NAME"description = "DESCRIPTION"author = "AUTHOR"version = "X"priority = -1

Here is an example - for most patches, priority of -1 will work, since default priority is set at 0, and load order is determined by highest number first. (Priority 100 will load before Priority 1. I use negative numbers, because default is zero, and is seldom changed.)

If you have set a lower priority for the mod you are patching, you must use a lower number for the priority.

 

MODMAIN:

When the mod loads afterwards in priority, it overwrites anything that was set in both mods. This is how we patch it.

For example, the base mod defines the following string:

STRINGS.NAMES.OCARINA = "Hero's Ocarina"

We can alter that with our patch, by adding to the patch's modmain:

STRINGS.NAMES.OCARINA = "Ocarina of Time"

Since the string is defined by both the base mod and the patch, the load order is important. By making the patch load afterwards, it overwrites that setting.

 

Since this patch mod loads afterwards, we can also alter any prefab, or other bit of code, defined in the main mod through post-inits in the modmain:

function PATCHPostInit( inst )inst.components.hunger:SetMax(300)  end   AddPrefabPostInit("mymod", PATCHPostInit)

In this example, the "mymod" character prefab is having its max hunger set to 300 - overwriting whatever it was previously.

 

 

ALTERING IMAGES/ANIMS:

The part you all came here for!

This works on the same principle that anything that occupies the same space, and is loaded afterwards, will fill that space.

 

First, you need to add your anim/image where it goes in the other mod. For example, you would like to patch the anim for "froggy" - your original "froggy" art was green, but you've decided to make a patch for people who would prefer froggy to be brown.

So you've altered the art for froggy, and converted it to tex.

 

The first thing you have to make sure is that you use the same file and build names.

It was "anim/froggy.zip" in the original mod, and it will be "anim/froggy.zip" in the patch.

 

We can then load the asset into the game, and overwrite what was loaded in the original mod. This only replaces the file used for the asset - the original mod still dictates when and how it is used.

We simply need the following code in our modmain:

Assets = {         Asset( "ANIM", "anim/froggy.zip" )    }

So that's it!

Very simple, and very versatile. Can be used for stat tweaks, translations, and most importantly... adding alternate costumes to your mod characters! ^^

Have fun, everyone!

Dear Dana, i really appreciate your efford to teach and inspire people, but I fought with getting my custom creature into the game for over one week and its just over my head at the moment ( could follow and make ur custom character tut work fine without using my own animation ). So I wanted to ask if you are interested in cooperation. I could send you some artwork of mine ( not a lot of it in klei style cause I "just" stumbled upon dont starve and loved it immediantly ), I have some ideas for creature mods in mind but I just have to give up to make them by myself. I'm really dedicated to make some new cool content for this particular game and I see you all over the forums trying to help wherever possible, so I thought it would be okay to ask you directly and for further advice :)

 

Link to comment
Share on other sites

Dear Dana, i really appreciate your efford to teach and inspire people, but I fought with getting my custom creature into the game for over one week and its just over my head at the moment ( could follow and make ur custom character tut work fine without using my own animation ). So I wanted to ask if you are interested in cooperation. I could send you some artwork of mine ( not a lot of it in klei style cause I "just" stumbled upon dont starve and loved it immediantly ), I have some ideas for creature mods in mind but I just have to give up to make them by myself. I'm really dedicated to make some new cool content for this particular game and I see you all over the forums trying to help wherever possible, so I thought it would be okay to ask you directly and for further advice :-)

 

 

I've not yet imported a custom creature into the game myself - I'm afraid I don't really know how it's done.

The animation is all I've done with regards to a custom creature.

I believe the tutorial by Cheerio is out of date somehow, so the best suggestion I have is to examine a mod that has added custom-animated creatures, like (I think) Hero in the Dark, or the unfinished Night Terrors mod.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...