Jump to content

An Idiot's Guide to Growing Custom Facial Hair


Recommended Posts

This mini-guide is intended to help those new to modding with adding a growing, shaveable custom beard to custom characters. As someone who is new to the modding system for DST, adding a custom beard was quite a headache for me!
NB: The method used here, unlike some other methods for creating changing characters, doesn't result in the invisible ghost glitch.
 
Acknowledgements: Thank you tremendously to Kzisor in this thread for giving pointers on how to achieve this. This guide aims to fill in the blanks for those of us who would struggle with the technical explanations.

Also thank you to Corrosive for helping me to iron out kinks in the code.

Thanks to ButteredBehind for testing and reporting bugs.

 
Before we begin
 
I'm assuming you've used the Extended Sample Character Template to create your custom character, following the tutorial. Therefore you should already have a .lua editor, such as Notepad++, and should also have Spriter as part of the DST modding tools.
 
You will also need to download ktools. I downloaded the Windows binary release (ktools-4.1.2-win32.zip) so that I didn't have to compile the source code. Make a note of where you've extracted/installed ktools to - you'll be using this later.
 
Within this guide I use bold to highlight specific files, italics to highlight specific folders, and red to indicate where "yourcharacter" should be changed to the name you've given your custom character.
 
Step 1: Getting the source files
 
Copy beard.zip from the \anim folder of your main game data
(e.g: C:\Program Files (x86)\Steam\SteamApps\common\Don't Starve Together Beta\data\anim )
to wherever you've extracted/installed ktools
(e.g: C:\Users\User\Downloads\ktools-4.1.2 ).
 
Extract the files from beard.zip into this ktools folder (NB: NOT into a \beard folder - just straight into this
\ktools-4.1.2 folder). There should be 3 files extracted from the .zip:

  • anim.bin
  • build.bin
  • atlas-0.tex

The \ktools-4.1.2 folder should now look like this:
 
1_zpszgswntyi.png
 
Run krane using command prompt. If you've never used a console application before, this video should help (if the program "just flashes up and then vanishes", you're doing it wrong and need to watch the video!). As the video shows, navigate to where you've installed ktools (the \ktools-4.1.2 folder) using "cd".
Once you've navigated to the correct folder, type in:

krane anim.bin build.bin yourcharacter_beard

replacing "yourcharacter" with the name you've been using.

 
3_zpseocrbjdm.png
 
This should create a new folder within the \ktools-4.1.2 folder called "yourcharacter_beard", containing 3 folders and a Spriter file:
2_zpsqk8omooi.png
 
Move this whole \yourcharacter_beard folder to the \exported folder in your mod folder, i.e copy the \yourcharacter_beard folder to:
C:\Program Files (x86)\Steam\SteamApps\common\Don't Starve Together Beta\mods\Your Character\exported\
 
Once you've moved the \yourcharacter_beard folder, rename beard.scml to yourcharacter_beard.scml to match the folder name.
 
Step 2: Getting the game to recognise these files
 
First off, you need to rename the build for this beard. To do this, open yourcharacter_beard.scml in Spriter and double-click on 'beards' in the animation pane. Change the name from 'beards' to 'yourcharacter_beard', using your character's name. Save the Spriter file.

4_zpssgzkck3i.png
 
Next, we need to edit your character's script so that they can grow the beard! As you did in the Extended Sample Character Template Tutorial, use a .lua editor (such as Notepad++) to open yourcharacter.lua, found in:
C:\Program Files (x86)\Steam\SteamApps\common\Don't StarveTogether Beta\mods\Your Character\scripts\prefabs
We'll go through the changes you need to make in order, inserting code based on Wilson's code.
NB: the insulation properties of the beard, and sanity bonus from shaving, are hard-coded, so we don't need to include anything for that.
 
First of all, we need to get the game to load the beard files.  Under the section 'local assets = {', delete the line 'Asset( "ANIM", "anim/beard.zip" ),' (found at the bottom of the first block of text).
Next, add this to the bottom of the second block of text:

Asset( "ANIM", "anim/yourcharacter_beard.zip" ),

obviously replacing "yourcharacter" with your character's name as we've done so far.
The 'local assets' part should now look like this: 

local assets = {         Asset( "ANIM", "anim/player_basic.zip" ),        Asset( "ANIM", "anim/player_idles_shiver.zip" ),        Asset( "ANIM", "anim/player_actions.zip" ),        Asset( "ANIM", "anim/player_actions_axe.zip" ),        Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),        Asset( "ANIM", "anim/player_actions_shovel.zip" ),        Asset( "ANIM", "anim/player_actions_blowdart.zip" ),        Asset( "ANIM", "anim/player_actions_eat.zip" ),        Asset( "ANIM", "anim/player_actions_item.zip" ),        Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),        Asset( "ANIM", "anim/player_actions_bugnet.zip" ),        Asset( "ANIM", "anim/player_actions_fishing.zip" ),        Asset( "ANIM", "anim/player_actions_boomerang.zip" ),        Asset( "ANIM", "anim/player_bush_hat.zip" ),        Asset( "ANIM", "anim/player_attacks.zip" ),        Asset( "ANIM", "anim/player_idles.zip" ),        Asset( "ANIM", "anim/player_rebirth.zip" ),        Asset( "ANIM", "anim/player_jump.zip" ),        Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),        Asset( "ANIM", "anim/player_teleport.zip" ),        Asset( "ANIM", "anim/wilson_fx.zip" ),        Asset( "ANIM", "anim/player_one_man_band.zip" ),        Asset( "ANIM", "anim/shadow_hands.zip" ),        Asset( "SOUND", "sound/sfx.fsb" ),        Asset( "SOUND", "sound/wilson.fsb" ),         Asset( "ANIM", "anim/yourcharacter.zip" ),        Asset( "ANIM", "anim/ghost_yourcharacter_build.zip" ),        Asset( "ANIM", "anim/yourcharacter_beard.zip" ),}


 
In the next section ('local prefabs = {}'), add the prefab "beardhair", so that the code looks like this:
local prefabs ={    "beardhair",}

 

 

Between the 'local common_postinit' and 'local master_postinit' sections, paste this code:

local function OnResetBeard(inst)    inst.AnimState:ClearOverrideSymbol("beard")end --tune the beard economy...local BEARD_DAYS = { 4, 8, 16 }local BEARD_BITS = { 1, 3,  9 } local function OnGrowShortBeard(inst)    inst.AnimState:OverrideSymbol("beard", "yourcharacter_beard", "beard_short")    inst.components.beard.bits = BEARD_BITS[1]end local function OnGrowMediumBeard(inst)    inst.AnimState:OverrideSymbol("beard", "yourcharacter_beard", "beard_medium")    inst.components.beard.bits = BEARD_BITS[2]end local function OnGrowLongBeard(inst)    inst.AnimState:OverrideSymbol("beard", "yourcharacter_beard", "beard_long")    inst.components.beard.bits = BEARD_BITS[3]end


Replace "yourcharacter" with your character's name. You can change the values underneath "--tune the beard economy...":
BEARD_DAYS = the number of in-game days it takes to grow the short, medium, and long beards respectively (for testing purposes it's handy to set this to "1, 2, 3").
BEARD_BITS = the number of beardhairs you receive when shaving off a short, medium, or long beard respectively.
 
In the next section, paste the following code immediately beneath the 'local master_postinit = function (inst)' part:
    inst:AddComponent("beard")    inst.components.beard.onreset = OnResetBeard    inst.components.beard.prize = "beardhair"    inst.components.beard:AddCallback(BEARD_DAYS[1], OnGrowShortBeard)    inst.components.beard:AddCallback(BEARD_DAYS[2], OnGrowMediumBeard)    inst.components.beard:AddCallback(BEARD_DAYS[3], OnGrowLongBeard)

 

This section of code should now look like:

local master_postinit = function(inst)    inst:AddComponent("beard")    inst.components.beard.onreset = OnResetBeard    inst.components.beard.prize = "beardhair"    inst.components.beard:AddCallback(BEARD_DAYS[1], OnGrowShortBeard)    inst.components.beard:AddCallback(BEARD_DAYS[2], OnGrowMediumBeard)    inst.components.beard:AddCallback(BEARD_DAYS[3], OnGrowLongBeard)    -- choose which sounds this character will play    inst.soundsname = "willow"    -- Stats     inst.components.health:SetMaxHealth(150)    inst.components.hunger:SetMax(150)    inst.components.sanity:SetMax(200)end

 

 
Save the yourcharacter.lua file.
 
Step 3: Putting it all together
 
Going back to this location:
C:\Program Files (x86)\Steam\SteamApps\common\Don't Starve Together Beta\mods\Your Character\exported\yourcharacter_beard
You can see the 3 folders (beard_long, beard_medium, and beard_short) as well as the Spriter file.

Each of these folders contains template .png files that can be modified in the same way as you've already done for your custom character's body. I'd highly recommend testing your beard in-game - because these template beards are designed to match up with Wilson's face, they may look quite different on your character and may well fit quite weirdly! 
 
As I said above, a handy tip for testing out beards in-game is to shorten the time taken to grow the beard (editing the values for BEARD_DAYS in yourcharacter.lua) so that it only takes 4 in-game days to test out all 3 different beards.
 
In order to export the animations and build for the beard, you should only need to run Don't Starve Together - as with the rest of the Extended Sample Character Template, the Autocompiler should run before the game opens, and sort everything out for you.
 
Remember that with a little effort and imagination, this guide could be adapted to help you add another type of growing part to your character, such as petals on a plant-hybrid character.
 
Step 4: Enjoy your new growing, shaveable, custom facial hair!
 
If there are any omissions or mistakes in this guide, please do let me know in the comments, and I'll update accordingly.

Edited by Ealish
  • Like 1
Link to comment
Share on other sites

Very good. But I can't see pictures in your guide.

Upd: Sorry. Actually I can, but they are very slow.

 

I tried to design the guide so that the pictures weren't essential, but rather help to illustrate my explanations. Do you think the slowness could be due to them being hosted on PhotoBucket?

Link to comment
Share on other sites

Hello, excellent guide, Ealish ! 

 

The only trouble I've run into is when shaving my character, the beard still shows up on my character until a new beard phase begins.

 

Edit: If I reload the world my characters beard behaves like normal (shows up at the stage is should).

Edited by ButteredBehind
Link to comment
Share on other sites

@ButteredBehind - thanks for letting me know! I've found that this can be fixed by changing this part of your_character.lua :

local function OnResetBeard(inst)inst.AnimState:ClearOverrideSymbol("yourcharacter_beard")end

Change "yourcharacter_beard" to just "beard" and it should fix your problem. I've updated the guide accordingly, thank you!

Edited by Ealish
Link to comment
Share on other sites

@YoBro Hey, sorry to hear you're having problems - which steps are you having issues with? I tried to write the guide to be as clear as possible, so it'd be useful to know which bits you've gotten stuck on! :-)

Yeah... Aha. Well. I'm trying to convert all the language from DST to just regular DS(RoG)

 

That might be the problem, but apart from that, It's trial and error.

Link to comment
Share on other sites

@YoBro I'm afraid that I don't own a copy of DS, just DST, so I don't know much about coding for that! I'm not sure how a video tutorial would help with that really (since it'd still be for my DST instructions!) - it sounds like you need to find someone who knows a lot about the differences between the two games :)

Link to comment
Share on other sites

@YoBro I'm afraid that I don't own a copy of DS, just DST, so I don't know much about coding for that! I'm not sure how a video tutorial would help with that really (since it'd still be for my DST instructions!) - it sounds like you need to find someone who knows a lot about the differences between the two games :-)

@Ealish Could you perhaps copy and paste what you put in for your .lua? If of course, you made a .lua file.

 

I'm a self teacher, so I just need to figure out what to do. Thanks for you help :grin:

Link to comment
Share on other sites

THANK YOU VERY MUCH FOR THIS!!!! Is exactly what I needed!! thank you!! I didn't tryed if it worked yet but I have now all the files and the sprited I needed to work! following this guide! I want to make a character with another type of growing part, in the head, I don't know yet if I will be able to fit all the art in the right place, but if I can see my character with beard, the rest it will be just try and error till I found the correct place for the parts!! I am so excited! My project seems to see the light finnally! thank you very much!!

If I have any other issues about this crazy project can I pm you? I think I will be okay but just in case ;P

Edited by YiinHikari
Link to comment
Share on other sites

Oh BTW, I am working for SW, I originally wanted to have the insulation and (less important) the sanity you gain when you shave the character. If that is possible I want to know how to add it to the moded character, if not... well it is not thaaaat important :)

thank you

Link to comment
Share on other sites

Hey sir! Thanks for all the help!

However I experience a problem.

My character's beard  appears very laggy when beaing watched from the back and doesn't move very smoothly with my character.

(Like when the 'stretching animation' plays, the beard falls behind on his body).

Is it just my medium-spec computer or am I doing something wrong?

 

Stil, many thanks!

Link to comment
Share on other sites

Very helpful, will follow this guide. Thanks!

Edit:

Where can I find this beard.zip? The extended sample char does not have it.

Edit:

Nm, as you said it's in the main game data\anim folder. Duh.

Edited by SenL
Link to comment
Share on other sites

@Ealish

I'm having an issue with krane. It doesn't seem to recognize the anim.bin or build.bin files I have extracted from the beard.zip file. I get the following error:

"Input path 'anim.bin' does not exist, skipping...

Input path 'build.bin' does not exist, skipping...

ERROR: No input files."

I've included screens of the folder and command prompt error. Anyone know what's up?

bearderror.png

Edited by SageOfLegend
Link to comment
Share on other sites

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
 Share

×
  • Create New...