tetrified Posted December 31, 2014 Share Posted December 31, 2014 (edited) I've noticed that hardly anyone knows how to make worldgen mods, so I thought I'd share my knowledge on the subject. Feel free to correct me on anything I got wrong or give me information I might not have EDIT: Yay! My post got the "popular" thing! ---->Thanks Guys! Section 1: What are the parts of World Geneation? Part 1: Prefabs and Static Layouts Prefabs are, as far as this guide is concerned, the smallest units in the don’t starve worldgen. Everything you see in the world is made of a combination of prefabs. I’m not going to be going over how to create prefabs in this guide, only how to implement already made prefabs and place them in the world.Static layouts are a series of prefabs that are placed in a specific order, when a static layout is placed, it will be exactly the same every single time. If you remember the pig king, or the teleportato pieces, these are good examples of static layouts (mostly just because they’re easy to remember as the same every time).I include these two in the same part because they’re both used when you make...Part 2: Rooms, and SetpiecesRooms are the first randomly generated part of don’t starve, they have contents (prefabs and static layouts), tags, and values.The tags determine special characteristics of a room, and the value determines the floor, what you’ll find yourself standing on.Contents are defined in a table, under several categories which are:countstaticlayouts, a table that holds the static layouts that you want in your roomcountprefabs, a table which holds prefabs that you want in your roomdistributepercent, a floating point value that determines the distribution of the prefabs in your roomdistributeprefabs, a table of prefabs to be distributed and how distributed they areprefabdata, to determine how to modify the prefabs in the roomAt first glance, distributeprefabs and countprefabs seem to be similar, but they’re actually used for very different purposes. The table, distributeprefabs is used for prefabs that you don’t necessarily want a specific amount of, but you want them evenly distributed across the room, things like trees, and flint. Whereas countprefabs is used for prefabs that you want a specific amount of. The countstaticlayouts table is used in an identical fashion to countprefabs, but obviously for static layouts.The table, prefabdata is used to determine the starting conditions of prefabs like trees (which can be burnt) and spider dens (which can be teir1,2,or 3) You don’t need to use prefabdata to determine the starting conditions for tree growth, as that is randomly selected by the trees. The reason for this is that people are unlikely to want a tree forest with trees the same height, but spider dens are frequently all tier1, or all tier3, or a random selection, so naturally you would want to determine this on a room-by-room basis.Setpieces are the middleground between a room and a static layout, generally incorporated into the world after it has been generated, and around the same size as a static layout, but (somewhat) randomly generated like a room. Part 3: Tasks, locks and keysA task has five important parts:Locks, which determine how the task can be “attached” to other tasksKeys, are the other half of the equation that determines if two tasks can be attached to eachother.Rooms, which are in essence what the task is made up of.room_bg and background_room, which determines the type of room used to flesh out the area.When the world is being generated, it goes through each task, checks the locks, and keys, and attaches the tasks together so that each lock is unlocked by any of the keys that can unlock it. A list of locks and keys can be found in the locksandkeys.lua in the maps folder. Locks and keys can be used to shape mildly. Rooms are the main rooms of the world, you define a specific amount of these. As opposed to room_bg and background_room, which are used to flesh out the area and an amount of them is chosen at random.. Part 4: LevelsThis is the part where you pick what you want in the world. The level is made of several portions, In this guide I’ll discuss the important parts for a survival mode worldleveltype, there are a few options for this, we’ll be using survivalid, the level id, this is how the game recognized the levelname, the name of your world, which will be viewable by the playersdesc, the description of the world, which will be viewable by the playersoverrides override specific settings in the worldtasks, these are guaranteed to be in the world which is what the world is made ofoptional tasks, which are what the world could be made of, if they’re pickedsetpieces, guaranteed to be in the world, covered in part 2random setpieces, that could be in the world if they’re pickedLeveltype is the type of level that this level is going to be, survival, adventure, etc. survival maps can be picked from the world generation menu. Overrides are used to override specific settings in the world, meaning you could make the start season winter, or have only islands, start on a specific setpiece, or a number of other things.Tasks are where you put the tasks that you made in part 3, setpieces are where you put the setpieces that we learned about in part 2. Random setpieces and optional tasks are setpieces and tasks that shouldn’t necessarily be in every world, but belong in some worlds. Section 2: Making your worldgen mod; A tutorial. This is going to be the most basic world you could possibly make, but it uses all the basic concepts and makes for a fairly short tutorial that someone could easily make a much better world based off of. So here we go Part 1: Making mod folder.Name it whatever you want, and make the following directory structureTop level foldermodinfo.lua (empty)modworldgenman.lua (empty)scriptsmaplevelsroomstasksPart 2: Making your first room Create a new empty lua file in scripts/map/rooms and open it in your favorite text editor Start with the function addroom(“name of your room”{}) Add in colour and value, color is (as far as I’m aware) purely for debugging purposes which we aren’t going over in this guide. Add the contents, I chose to add only grass Add a background room, it’s going to be pretty much the same as your normal room, but in this specific case, it doesn’t really matter, as it’s probably going to get overwritten by the start node(although you can choose to not include a start node) Part 3: Make yourself a task Since we only have one task this is pretty simple, I’m only planning on putting in one task for this demo.If you want more, you’re going to have to go through the locks and keys lua file in maps, but since we only have one right now, I’m just going to leave locks and keys as none. For future reference, you must choose locks.none if you want a specific area to be your starting area.Then we need to make our room_choices table, for mine I put in one of the plains room we made. If you want to see your background room, you should put in more than one, you’ll see why when we actually make the world. Lastly, add in your room_bg (it should match the room you’re making), your background_room, and the colour, which once again, is only used for debug purposes, so you can make it any color you want.Part 4: Levels Add in your survival level, with an id, name, and description of your choosing. Next comes overrides, you can make your own starting setpiece if you want to, but I just used the default one provided with don’t starve.And finally tasks, we have no optional tasks because we only made one task. Part 5: Playing the mod Now comes the moment of truth, link all your files in modworldgenmain.lua, name the mod in modinfo, and install your mod!If everything worked out, you should have a new world preset, and when you select it…. I know it looks stupid, but that's because there's only one room.Note: the green comes from the start node, and you can't see any of my background room, but my plains room is clearly visible. Edited January 3, 2015 by tetrified 1 Link to comment Share on other sites More sharing options...
tetrified Posted December 31, 2014 Author Share Posted December 31, 2014 (edited) Section 3: Adventure Mode Part 0: Preamble The first thing I want to say about adventure mode is that it’s not all that different from normal world generation, the new additions to rooms are tags, the new additions to tasks are blocker rooms, and entrance rooms The new addition to levels are campaign legnth, leveltype, min and max playlist positions, substitutes, and override_triggers. You should really read and play around with the settings above before you start with this section. I’m also going to assume that you remember all the code that we used above, but I’ll write out what the functions and variables we didn’t use in section 2 were. Lastly, I’m going to use code I’ve already written, instead of writing out code specifically for this level. Part 1: New Rooms?Yes, a whole new kind of room, called a blocker. The main difference between a blocker room and a “normal” room is blockers are typically smaller, and tougher to get through, the really awesome part about it though is you can actually use a set piece as a blocker room, I’m sure there’s tons of untapped potential here, but on to the codeThese two tags are bordering on required for a blocker roomtags = {"ForceConnected", "RoadPoison"},Though if you’re not going to be using the blocker room as a blocker room, you can remove road poison.This is for turning a setpiece straight into a blocker room, it’ll automatically add the tags mentioned above, turn the default ground to impassable, and add your setpiece as the only static layout in the room.AddRoom("roomname", MakeSetpieceBlockerRoom("setpiecename"))Part 2: Adding these to your tasksYou can add a blocker room, or entrance room using the entrance_room field in the AddTask function, you can also have a chance for the entrance room using entrance_room_chance. You’re going to want to take special care with your locks and keys to ensure people can’t just walk around the blockers, you want to force them to walk straight through blocker rooms, that’s kinda the point. I find that easy locks/keys to use for this are the tier locks, and if you’re planning on adding and adventuremode world, you should think long and hard about what locks and keys you’re going to use to prevent the player from gaining easy access to everything. code:entrance_room=blockersets.blockerset,or entrance_room="roomname",are both ways to add a blocker room, blockersets are located in the blockersets.lua, blocker rooms are located in blockers.luaPictures to help visualization: Part 3: LevelsLevels don’t change much, and there are a few parts here that don’t work in DST, adding tasks to the levels is identical to normal, you just add the tasks in and let the locks/keys sort out the rest. If you’re planning on actually adding this level to adventure mode and not just adding it as a more challenging survival map, you need to make the leveltype adventure, add in min and max playlist positions, and add in the teleport action and teleportato pieces.substitutes will sub out items for other items, you can read more about substitutes in level.lua and the actual code to change out the items is in storygen.lua. code for this stuff: Creating an adventure leveltype:AddLevel(LEVELTYPE.ADVENTURE, {everything else that normally goes here}min and max playlist positions min_playlist_position=1, max_playlist_position=4, ordered story set pieces and required prefabs are really self explanatory if you see how they’re used ordered_story_setpieces = { "TeleportatoRingLayout", "TeleportatoBoxLayout", "TeleportatoCrankLayout", "TeleportatoPotatoLayout", "TeleportatoBaseAdventureLayout", }, required_prefabs = { "teleportato_ring", "teleportato_box", "teleportato_crank", "teleportato_potato", "teleportato_base", "chester_eyebone" }, What doesn’t work in DST: override_triggers these were really nifty in DS because they allowed you to change world settings like weather, time of day, and seasons on the fly. I’ve gotten them working in DST… sort of. If anyone can get them working all the way please let me know because I love these things. Override triggers are used like this: ["START"] = { -- Quick (localised) fix for area-aware bug #677 {"override1", "whatyouwantfirst"}, {"override2", "whatyouwantfirst"}, }, ["task1"] = { {"override1", "whatyouwantfirst"}, {"override2", "whatyouwantfirst"}, }, ["task2"] = { {"override1", "whatyouwantsecond"}, {"override2", "whatyouwantsecond"}, }, },campaign length is literally just how many maps long the campaign is, put at the top of the file, before you start adding levels, like this:CAMPAIGN_LENGTH = 5 Edited January 3, 2015 by tetrified Link to comment Share on other sites More sharing options...
tetrified Posted January 3, 2015 Author Share Posted January 3, 2015 (edited) APPENDIX: references Levels Tasks Rooms Making a Custom Setpiece Edited January 3, 2015 by tetrified Link to comment Share on other sites More sharing options...
tetrified Posted January 3, 2015 Author Share Posted January 3, 2015 (edited) There we go, that's probably as finished as it's going to get, unless people have suggestions for more things that I can write about here. Feel free to pm me/ post in this thread if you want more info on how to even into worldgen Edited January 3, 2015 by tetrified Link to comment Share on other sites More sharing options...
Kzisor Posted January 3, 2015 Share Posted January 3, 2015 @tetrified, great guide, however, I have a recommendation as a native English speaker. I'd recommend asking a mod or editing the title to [GUIDE] Modding World Generation as the current title does not fully indicate intent of the post. Link to comment Share on other sites More sharing options...
tetrified Posted January 3, 2015 Author Share Posted January 3, 2015 (edited) @tetrified, great guide, however, I have a recommendation as a native English speaker. I'd recommend asking a mod or editing the title to [GUIDE] Modding World Generation as the current title does not fully indicate intent of the post. Yeah...I realized this way too late, I would like [GUIDE] to be added to the title, but I can't do it myself. the title to be changed to "[GUIDE] Intro to worldgen" but I can't do it myself. Or were you saying that the title should be "[GUIDE] Modding World Generation" "[GUIDE] Intro to worldgen"? And on this topic, maybe I should have put it in the "don't starve mods and tools section", but it seems like it should be at least mentioned here somehow as well. Not sure who to mention here Edited January 3, 2015 by tetrified Link to comment Share on other sites More sharing options...
Kzisor Posted January 3, 2015 Share Posted January 3, 2015 Or were you saying that the title should be "[GUIDE] Modding World Generation"?Because I'd be fine with that too, but it does need a [GUIDE] at the beginning nomatter how it gets changed. I was specifically recommending the full title to be [GUIDE] Modding World Generation, native English speakers might not understand the humor in the title as it is currently. Either way, I completely agree as long as it has guide in the name it will get the point across. Link to comment Share on other sites More sharing options...
tetrified Posted January 3, 2015 Author Share Posted January 3, 2015 (edited) I was specifically recommending the full title to be [GUIDE] Modding World Generation, native English speakers might not understand the humor in the title as it is currently. Either way, I completely agree as long as it has guide in the name it will get the point across. Oh right, the reference is probably lost on this community, I was going for the "can you even into" meme found (mostly) on image boards. I suppose I should have considered my audience more when writing the title EDIT: If anyone who can change the title ever sees this, I'd like the title to be "[GUIDE] Intro to worldgen", to allow for an advanced worldgen guide later if I can ever figure everything out. Because this definitely isn't all there is to modding world generation. Edited January 3, 2015 by tetrified Link to comment Share on other sites More sharing options...
DarkXero Posted January 4, 2015 Share Posted January 4, 2015 Regardless of title, this should be a sticky. Very informative. Link to comment Share on other sites More sharing options...
Developer PeterA Posted January 5, 2015 Developer Share Posted January 5, 2015 Lots of useful information here. I edited title and pinned the topic. 2 Link to comment Share on other sites More sharing options...
tetrified Posted January 5, 2015 Author Share Posted January 5, 2015 @PeterA,Thank you! Link to comment Share on other sites More sharing options...
UnStarved Posted May 23, 2015 Share Posted May 23, 2015 Great guide but I still have a few questions: What is the difference between distributepercent and distributeprefabs? Is distriubutepercent the chance of that room being selected and distributeprefabs the chance of those pieces being put into the room? I am tring to edit the chess room to ensure spawning of clockwork monsters(last two worlds had no clockwork monsters in the rooms, only a skeleton/pickaxe or trees). I do realise now, I can just use countprefabs to ensure spawns. Side question, where is the world size varible located? I want to make a world with more land than "huge" and hopefully with more biomes but smaller. Link to comment Share on other sites More sharing options...
blahpers Posted May 26, 2015 Share Posted May 26, 2015 Great guide but I still have a few questions: What is the difference between distributepercent and distributeprefabs? Is distriubutepercent the chance of that room being selected and distributeprefabs the chance of those pieces being put into the room? I'd like to second that question (specifically, details on how distributepercent and distributeprefabs are used internally) and add a help request. When I tried this tutorial, I ended up with a normal-looking world instead of the expected two islands connected by bridge. Any idea what I might have done wrong? Link to comment Share on other sites More sharing options...
eldr1ch Posted June 11, 2015 Share Posted June 11, 2015 This seems to be broken by DST RoG update. I tried this tutorial yesterday, but it didn't change the default map. Then I downloaded author's mods but it also didn't work. Link to comment Share on other sites More sharing options...
Kzisor Posted June 11, 2015 Share Posted June 11, 2015 @eldr1ch, this particular guide was not broken when ROG was released. It still works, make sure you're putting the code in modworldgenmain.lua. The reason I know it still works is because World Generation code has not changed at all, however, I suspect that might change when caves are added. Link to comment Share on other sites More sharing options...
eldr1ch Posted June 11, 2015 Share Posted June 11, 2015 I see. That was just my suspicion after reading people's comments for these mods on Steam Workshop. I have no modding knowledge to even start modifying this and find out what's wrong, but I know for sure that the mod itself worked - it loaded properly, it changed my starting season and starting set piece. If anyone finds a solution - I'd be grateful. Link to comment Share on other sites More sharing options...
blahpers Posted June 12, 2015 Share Posted June 12, 2015 Same boat here. Code is definitely in modworldgenmain.lua. Haven't yet verified whether the new room itself is created, as I've been busy on other projects, but the rest of the world is still being generated. And I have only a tiny handle on that area of the API, so it'll be a challenge to track down the problem. Link to comment Share on other sites More sharing options...
Rokin Posted June 26, 2015 Share Posted June 26, 2015 Hi and thank for the guide I have the same problem that eldr1ch and blahpers, anyone have found the solution ? Link to comment Share on other sites More sharing options...
rilane Posted July 21, 2015 Share Posted July 21, 2015 Hello, sorry for bringing up an old thread.I've been looking through this forum to find how to use custom turfs in static layouts and found nothing. (you know, these ID's from Tiled, with hardcoded ground values in scripts\map\static_layout.lua)The only way I see now is to copy-paste it all with new values (but I'm not realy good at lua , so maybe there is another way to do this).Please send help Link to comment Share on other sites More sharing options...
Finerlobster Posted July 23, 2015 Share Posted July 23, 2015 Hello, I don't know why but it's not working for me, I tested the same code in DS and it worked, but in DST seems like nothing happens.Thanks in advance. Link to comment Share on other sites More sharing options...
DarkXero Posted July 23, 2015 Share Posted July 23, 2015 @Finerlobster, and everybody else here. There have been changes to how you customize world gen that will reach the game when the new UI comes out. Link to comment Share on other sites More sharing options...
Developer PeterA Posted June 21, 2016 Developer Share Posted June 21, 2016 @BUTTERSKY11 I'll unpin this thread for now as it's outdated, but you may want to take a look at http://steamcommunity.com/sharedfiles/filedetails/?id=503187227&searchtext= which I believe is up-to-date and working. You'll want to take a look at ipsquiggle's post, which I've pinned now. Good luck! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now