Ultroman 717 Report post Posted March 9, 2020 (edited) Here's my collection of good threads/posts with great content, either explanations or code snippets. You will also find many other tutorials by following the links in the Newcomer Intro Post to the other tutorial collections on the forum. I keep adding to this list in a text file on my computer anyway, so I might as well keep the list here for everyone to peruse. Klei ppl: It would be awesome if this could be put in a state where it did not get archived, so I can keep updating it. UPDATE: Thanks for the pin, @JoeW! >> Link to the Newcomer Intro Post <<The Newcomer Intro Post has a lot of basic information you need to start modding, plus a bunch of great tips, for example about how to debug your mods and how to search the forum effectively. Also contains links to various other resources, some similar to this thread, where you can find even more great information, albeit most of it is older than most of the things in this post, but there is still a lot of great information to find. If you're making your first player character, start by looking at the first 3-5 in the "Player Character Stuff" section below AFTER you've been through the newcomer post. 2021 update: It has come to my attention, that the tutorials are slowly being lost to automatic archiving on the forums. Since only pinned posts and those in the "Tutorials and Guides" section seem to stay alive, I'll start converting the scattered posts into actual tutorial threads, starting with the oldest ones. Many of them need a dusting, anyway. General StuffModinfo GuideModiconsExplanation of events and event parameters (by Serpens)Custom eventsExporting musicOriginal Music Mod tutorial (Here's a post where some person helps another person who is having trouble with this tutorial)Check if world has cavesSaving and loading data for a prefabMake prefab a light sourceAoE Damage / ExplosionGuide to differences between DS and DST modding and converting mods between the games Player Character StuffExtended Character TemplateExtended Character Template FixesGuide for character modding on MacMaking Custom Skins for Modded CharactersReskinning and Animation Guide (full guide to making a mod that reskins a monster; great source for anything with textures; redirects to a Steam Community post)Custom Character SoundsPlayer starting itemsMaking basic perks (most of them are for DS only; 40+ different ones; haven't tested them, personally, but they seem legit)Making buffs (simple buff framework with examples incl. movement speed, max-health increase and damage modifier)Using the sanityaura componentAffecting sanity in a dynamic way, using a custom sanity rate function and e.g. listenersAuras (can actually be applied to any entity in the world, not just the player. Even a rock)Sanity gain or drain when around another character or certain entities (the example is a character prefab, but it can be changed to any prefab / tags you want)Custom Sleeping Stats For A CharacterCharacter transformation / beast-formLevelling system Crafting and Food StuffMaking a recipe character-specific. Also duplicating crafting recipes, plus other stuffHow Cookpot Recipes WorkFun With Food (shows several different ways of changing the way food works, also character-specific changes) Item StuffMake it so no one else can pick up a custom item (like Thor's hammer)Make an armor have 100% damage absorption against certain mobsLife-stealCreating HANDS item from scratch[Template/Tutorial] Custom crafting tab and itemsHow to make Drying Racks Edited March 1 by Ultroman moved newcomer post in here and changed the link to it 15 12 1 Share this post Link to post Share on other sites
Yakuzashi 144 Report post Posted March 9, 2020 'You are a good man. Thank you.' 1 Share this post Link to post Share on other sites
Ultroman 717 Report post Posted March 10, 2020 (edited) >> The Newcomer Intro Post << Welcome to the world of Don't Starve modding! There are a bunch of things you should do, in order to make your life easier going into this. Get yourself a nice text editor. I use Notepad++ and can highly recommend it. Make sure to set the "Language" to "Lua" while you're coding in Lua (the language we use for modding). That'll help you greatly in many ways. The "Find in files" function is also useful, for finding examples of code usage in the game files (CTRL-SHIFT-F in Notepad++, and make sure the filter is either *.* or the extension of the files you want to search in, e.g. *.lua, and also make sure to set Match Case etc. to what you want). Sublime is another great text editor. There are many! Take a Lua crash course. Here's a quick text-based crash course for already experienced coders and here are two crash courses in video-form, the first (12 min) basically goes through the Lua Manual while the second (15 min) does its own thing. It WILL save you LOADS of time and frustration to learn Lua first. I'm not kidding. Do this for yourself. You need to know how the syntax and the peculiar table/object model work to form everything from a light, to a list of strings, to a full player object. There is very little help from the language itself, so things like searching through a list is something you have to make yourself or find from a code resource. You might be asking how to do tutorials in Lua when you haven't even set up a mod yet. You can use this Online Lua Interpreter to play around. Look in the FAQ for general information. You'll find the game code scripts in: DS: steamapps\common\dont_starve\data\scripts You'll find the new/changed data files for each DLC in: steamapps\common\dont_starve\data\DLC000# DST: steamapps\common\Don't Starve Together\data\databundles\scripts.zip Unpack that somewhere far away from your game folder. In the "prefabs" folder you'll find all the entities in the game (players, items, creatures, bosses etc.). Some prefabs files hold more than one prefab, like spider.lua and cavespiders.lua which have several creature prefabs in them, and e.g. the amulet.lua and hats.lua which have several item prefabs in them. Everything in the game is made up of components, which are in a separate folder. Living creatures have brains (AI) and stategraphs (a collection of states they can be in and actions they can perform, which together determine how they operate. It also handles a lot of the waiting for and switching of animations etc. based on the actions performed) and these are in separate folders, as well. The UI-stuff is mostly found in the widgets folder. Look at the amazing collection of modding tips and tutorials you can find in this forum section (DS) and this "getting started with modding guide" thread (DST). Both have some overlap between DS and DST. There are some for working with items, images and animations. Of course, there is also the list I've compiled in the first post in this thread. Learn the basics of the files involved in mods. I have a post here explaining the contents of modinfo.lua. Some information about mod icons. To see how working mods are made, download a few mods, and look at their code. I can recommend this one for a simple TUNING-variable tweak, and CactusArmor.zip for a simple armor (although it is a DST mod, I think the code should work for both DS and DST, except the api_version in modinfo.lua). Look at the tutorials I've listed in the first post of this thread. Even if you don't understand everything that's going on, it should still help you understand bit by bit how things are done. There are many moving parts, so don't expect to just push out a mod on your first day...at least not a bug-free one When you're completely baffled by something, try to find an existing mod that does something very similar to what you're doing. You can usually figure out what they're doing or it'll give you some new insight to help you progress. Searching the forum "I know how to search a #%&€ forum!" Yeah, but this one is special. When using the search bar at the top, it defaults to searching all the forums, not just the modding forums, so you'll get search results for all Klei's games and all the forums they have, not just the modding forums. These are the two easiest ways I've found to search for modding threads. One (normal forum search) allows you to search exclusively for threads for one of the games, and is probably the most easily accessible, while the other method (advanced search) allows you to search for threads for both games (DS and DST) at the same time OR exclusively one of the games. Normal modding forum search, when searching exclusively for DS or DST, but NOT BOTH: Make sure you go to the right forum[Don't Starve Together] Mods and Tools or[Don't Starve] Mods and Tools Click the search-bar at the top of the page Click the button that appears to the left of it and choose "This forum" Then type in your search at the top, and press Enter or the magnifying glass Advanced modding forum search, when you don't care whether the thread is for DS or DST: Click the search-bar at the top of the page Type in any search term and press enter or click the spyglass. On the next page, click on "More search options" underneath the search term bar. Select "Topics" on the left In the "Forums" dropdown below, scroll downwards and select BOTH[Don't Starve Together] Mods and Tools and[Don't Starve] Mods and Tools from the list. The content is kind of muddled together between the games, despite the mods trying their best to keep them separate, but much of the code can be used for either game. Just be aware that there are differences between the two games, and that you might sometimes need to make slight changes or even take a completely different approach for certain functionality between the games. If you want to be at least almost sure not to have this problem, only select the forum for the game you are modding for. Then type in your search at the top, and press Enter or the magnifying glass Debugging In order to see the full error log, which has more information than the game has room on the screen to show you, and also shows what might have lead to the error, you need to look at the game logs. For DS there's only one log. It's called "log.txt" and it's right here: <SystemDriveLetter>:\Users\<UserName>\Documents\Klei\DoNotStarve For DST, there are two "types" of logs. If your game crashed while playing, the error is most likely found in your server_log.txt file(s). If your server has caves in it, there will be a server_log.txt for both the regular server "shard" and the caves server "shard". You can find those files here: <SystemDriveLetter>:\Users\<UserName>\Documents\Klei\DoNotStarveTogether\Cluster_# (# = 1-5; this is the placement of your server on the list of servers in-game) In that folder, you will find a "Master" folder and perhaps also a "Caves" folder. Both should have a server_log.txt in them. There is also a client_log.txt. If the game dies in the main menu or while loading the game or on the character select screen, in which case there might not be any server_log.txt files, you can still find the client_log.txt file here: <SystemDriveLetter>:\Users\<UserName>\Documents\Klei\DoNotStarveTogether These files are crucial for us to help you, when you're asking how to fix a crash. Attach those files to your crash post, by dragging and dropping them onto the reply you are about to submit, and if you suspect that it's your mod causing it, also post a zip of your mod. You can also use those files to your advantage when debugging your mod. If something in your mod is not working, or even if it is crashing during play, you can give yourself lots of hints and information about what code is actually being executed and which parts are not. You do this by using print-statements, like shown below. These print-statements show up in the client_log.txt, which you can even look at while the game is playing (Notepad++ should automatically ask you to reload the file if you come back to it after it has been changed, but not always!!). -- Simple print just to show if a function was called. print("MyFunction was called") -- Printing numbers print("Current sanity value: "..inst.components.sanity.current) -- Printing booleans. To print booleans (true/false) you MUST wrap the boolean in a tostring() call, -- to tell LUA to convert it to a string. -- Example 1: print("My value is higher than 100: "..tostring(myvalue > 100)) -- Example 2: local isMyFeatureOn = true print("Feature is on: "..tostring(isMyFeatureOn)) You can really use print-statements to great advantage. If you're unsure why your mod isn't working, just slap in print-statements in all the functions and have them print out "<function name> was called", and follow the trail in the log and your code side-by-side. Add in some extra print-statements to make sure your variables are set to what you expect, and I can almost guarantee you, that you will find out what is going wrong. Posting A Topic If you need help, post a topic in the appropriate modding section of the forum. Note that there is one for DS and one for DST. Please include the relevant code (Lua file) and an error log if you have an error (see above how to find the logs). Try to keep your post on topic and don't ask too many things at once. It's better to start two, three or four topics, if you want help with two, three or four different things, but you should generally try to focus on fixing only a few things at a time. Also, keep in mind that the people reading your post have zero knowledge of what you're doing, what you have working, what the context of the problem is, your file structure, how much you actually know what you're doing or anything at all, unless you inform them of it. Remember that when you're new, the problem is often not what you think it is, but probably something "next to" what you think is the problem, so making sure that people know exactly what you're trying to achieve (the functionality you want to have in the end) and the context in which you're trying to achieve it (is the code for DS or DST? Is it in a bee or in the player?). And be specific. Ex: if you want a healing aura, what do you mean by that? Should the player be healed by being around some things or should things around the player be healed? Which things? What have you tried already? And remember, stay positive Edited Tuesday at 01:29 AM by Ultroman had this erroneous post, so thought I'd move the newcomer post in here 2 1 Share this post Link to post Share on other sites
Hornete 7052 Report post Posted March 10, 2020 Wooo, Congrats on the pin! @Ultroman I think you should add this to the post, 1 Share this post Link to post Share on other sites
Ultroman 717 Report post Posted March 10, 2020 10 minutes ago, Hornete said: I think you should add this to the post, Ooh, good one! And new 1 Share this post Link to post Share on other sites
ry3bread 4 Report post Posted March 11, 2020 Thanks again! This fella’s a hero. 3 Share this post Link to post Share on other sites
Mick Satana 0 Report post Posted July 14, 2020 Thanks for listing these topics. It's really easy to follow. ps, this link is broken. On 3/10/2020 at 4:56 AM, Ultroman said: Character item modding, special objects or features. Share this post Link to post Share on other sites
Ultroman 717 Report post Posted July 15, 2020 18 hours ago, Mick Satana said: Thanks for listing these topics. It's really easy to follow. ps, this link is broken. Thank you for the heads-up. Sadly, that post seems to have been deleted. I'm happy this list helped you Share this post Link to post Share on other sites
Merio. 2 Report post Posted August 5, 2020 Thank you for this. 1 Share this post Link to post Share on other sites
SinancoTheBest 2894 Report post Posted September 10, 2020 Are there any specific tutorials for music mods? Share this post Link to post Share on other sites
Ultroman 717 Report post Posted January 4 On 9/10/2020 at 3:00 PM, SinancoTheBest said: Are there any specific tutorials for music mods? There is an official one, but it's quite old now. Here's a relevant search. Here's the original Music Mod tutorial. Here's a post where some person helps another person who is having trouble with that tutorial. 1 Share this post Link to post Share on other sites
Ultroman 717 Report post Posted January 28 (edited) ignore this Edited January 28 by Ultroman Share this post Link to post Share on other sites
Ultroman 717 Report post Posted January 28 On 7/14/2020 at 4:05 PM, Mick Satana said: Thanks for listing these topics. It's really easy to follow. ps, this link is broken. That post has been replaced by this much more complete tutorial which includes exporting files to edit, converting them into separate images to edit using KTools and Spriter (I recommend that method, unless you really only need to do minor reskinning, as the author also says, but you'll probably want to get to know Spriter and KTools, anyway. Share this post Link to post Share on other sites
Muskar 8 Report post Posted March 1 On 3/10/2020 at 1:42 AM, Ultroman said: Normal modding forum search, when searching exclusively for DS or DST, but NOT BOTH: Make sure you go to the right forum[Don't Starve Together] Mods and Tools or[Don't Starve] Mods and Tools Click the search-bar at the top of the page Click the button that appears to the left of it and choose "This forum" Then type in your search at the top, and press Enter or the magnifying glass Doesn't seem to work for me. I get the following result in both Chrome and Firefox - no button appears: What am I doing wrong? Also, perhaps in the Debugging section you could add a small section about writing out tables in runtime via a table serializer like serpent or others - noting licenses are worth keeping an eye on etc. I've only tried serpent but it helps greatly with the followings options: local serpent = require "util/serpent" --put serpent.lua and license in "util" folder in the mod --... print(serpent.block(table, {metatostring=false, maxlevel=3, maxnum=50, nocode=true})) -- don't set maxlevel very high when metatostring is off, otherwise you'll likely run out of memory Share this post Link to post Share on other sites
Ultroman 717 Report post Posted Tuesday at 01:26 AM (edited) 4 hours ago, Muskar said: Doesn't seem to work for me. I get the following result in both Chrome and Firefox - no button appears: What am I doing wrong? It appears they've changed the script since I wrote that. Now you have to perform a search and press "More search options" to get to the list of forum sections. Fixed! Thanks for letting me know. 4 hours ago, Muskar said: Also, perhaps in the Debugging section you could add a small section about writing out tables in runtime via a table serializer like serpent or others - noting licenses are worth keeping an eye on etc. I've only tried serpent but it helps greatly with the followings options: local serpent = require "util/serpent" --put serpent.lua and license in "util" folder in the mod --... print(serpent.block(table, {metatostring=false, maxlevel=3, maxnum=50, nocode=true})) -- don't set maxlevel very high when metatostring is off, otherwise you'll likely run out of memory I would love to, but I simply do not have the time right now. Also, I have never used any of those libraries. Never had the need. You seem like a bright fellow. I would urge you to write up a small tutorial / guide thread about using these, to help others and perhaps serve as a log of understandings for yourself in the future. Edited Tuesday at 01:29 AM by Ultroman 1 Share this post Link to post Share on other sites