Jump to content

Learning to mod.

Recommended Posts

Can anyone tell me what i need to get started? I am literally trying to learn and modify a few items and create very simple items. The items already exist in the game i just need to port them over from shipwrecked to DST. I just need cactus armor.

Link to comment
Share on other sites

Of course, starting with a LUA crash course is a good thing to do. Notice that there are elaborating guides on the left side of the site. Good sources for learning are the API wiki and the API examples. The Guides thread and the Getting Started With Modding thread are also full of good information.

Get yourself Notepad++. It's a great text editor, with many nice functions. For example, CTRL+SHIFT+F lets you search for text in all files within a folder, which is SUPER useful for finding out where things are used in the game files. It also has syntax highlighting for LUA files, which makes them infinitely easier to read. If it doesn't detect the language as LUA automatically, you can just go to the "Language" menu at the top and choose it.

Really, the best way to learn, is to look at how simple mods are made. You can take a look at my Metabolizer mod. It's insanely simple, and the first one I did. It just changes a tuning-variable. These are variables set in the tuning.lua file, and are used all over the game code. It's damages for weapons, health for creatures, sanity cost of things etc. That mod will let you see very clearly how to set up the modinfo.lua file, how to add a simple setting to the mod, and how to read it in the modmain.lua file.

If you want to look at the game files, go to your game folder, and find the "databundles" folder in the "data" folder (steamapps\common\Don't Starve Together\data\databundles). Find and extract the "scripts.zip" file somewhere on your harddrive. This contains the code for all the prefabs (monsters, items, players etc.), and all the components used for these prefabs (health, sanity, hunger, combat, edible, lootdropper etc.), brains (AI) and stategraphs (behavior and actions) and everything else.

All things in the game are simple entities, with components on them which are updated or called by the game, to update their status or let them react in some way. These components include the movement, loot-drops, being able to freeze or catch fire, and even BEING a fire, or having an inventory, being edible, emitting light, having a set number of uses etc. Much is done using events called in these components when things happen, like the "death" event which is called by anything with the health-component when it dies. You can listen for these events, and if you've registered to listen for an event, you can have the game run a custom piece of code when it happens.

Anyway, you're looking to make an item mod, so after you've learned the basics of what makes up a mod, e.g. from the Metabolizer mod, find an item mod that adds just one simple item, like this one. Look how that's done. Then you can start to take a look at that big mod you want to copy the Cactus Armor from, and see if you can Frankenstein your own mod with just the Cactus Armor in it, using the code and files from it.

Good luck!

Edited by Ultroman
Link to comment
Share on other sites



I seriously cant find the location. I subscribed mods on steam. I cant locate them to pull code to transfer. I found an armor mod to modify but cant find coding for the cactus armor itself because i dont have access to any mod with the cactus armor. I am i just dumb am i missing something? do these mods actually not download? cannot i not access them?

Link to comment
Share on other sites

1 hour ago, Litlej86 said:

i pulled the script from shipwrecked to make it easy but i know there is an issue somewhere but its off to work.

I could imagine. You can't just copy a whole item over from Don't Starve. Luckily this one should be sort of easy.

Fixed it.




Edited by Ultroman
Link to comment
Share on other sites


- Added the networking stuff.
- Changed the foleysound path, because the path you had was for sounds in DS, and they've changed it for DST. I also changed the foleysound to use the sound for the log armor, since the one your code was referring to does not exist in DST. You can change it to whatever sound you want. Perhaps the same one the grass armor uses?
- I also made it play a sound when you block something with the armor. Copied the one from the log armor. Again, you can look at the grass armor or any of the other armors, to see which sound they use, and use one of them instead. Or you can go get the sounds used in the other mods, and add them to this mod.
- I added the missing TUNING variables, with the values they had in Shipwrecked. (0.8 or 80% absorption, 450 "health" and 17 damage).
- Removed unneeded lines in modmain, but added some other ones.

Be careful, though. Because your recipe requires a "needlespear" which is only available in your mods "Tropical Adventures" or "More items and whatever", your mod actually requires one of those mods. That is something you have to inform your users of, and you can actually add a dependency to your mod on Steam.

Tell your wife that you did it all. You deserve it :D

Link to comment
Share on other sites

i will change the recipe to use cactus flesh instead of spikes due to dependency. thank yuou so much. I learned alot from this little adventure lol 

ohh i will test and fix thanks though lol


doesnt work lol i will try again later

Link to comment
Share on other sites

That's good! :) It's always good to learn something new. Especially programming!!

I've been modding for quite a while, so I have some little cheats I use to make things go faster. I always keep a full copy of all the script folders from all the game versions (DS, RoG, SW, DST, HAMLET), from the last time I updated my mods. Then, whenever they update the game, I can cheat by using Beyond Compare to compare all the files and folders side by side, and see exactly which files were changed, and which lines were changed. This helps A LOT, because I know I've only changed stuff in very few files, so I mostly keep an eye on those. Also, getting familiar with Notepad++, especially taking advantage of its side by side functionality (e.g. right-click a tab and select "Move to other view") is just priceless, so you can have your code on one side, and look at the game code next to it.

Anyway, happy gaming!

There is no cactus flesh to be had in DST. There are only cactus, oasis_cactus and cactus_flower.

  • Like 1
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

  • Create New...