Lumina Posted April 18, 2017 Share Posted April 18, 2017 (edited) Most of the informations about how to create a custom set piece can be found here : Even if this tutorial is for DS, the major part still work for DST. You need don't starve mod tools, if you don't have it already. Run Tiled. The don't starve tileset should be included and more or less up to date (meaning that ground for cave should be included, but as far as i know, not the ground for RoG). Let me know if they aren't, i'll add a .zip with them. I will not repeat step that already are in the tutorial, but if you need informations about one of them, i'll try to explain. You have two ways to add a prefab in a setpiece. Writing the name or selecting a prefab in the list. Even if a prefab isn't in the list, you could still add it, allowing the creation of set piece with custom prefab. You can also use existing set piece as a template for new set piece. They could provide good example for starting. Scenarios. You could add scenario to a setpiece. Scenario could do various things, like adding random items to a chest, triggering an even when doing a certain action... For example, you have a trap named "trap_sleepingspider.lua" (you could find it in Don't Starve Together\data\scripts\map\static_layouts) https://vignette1.wikia.nocookie.net/dont-starve-game/images/9/93/Spider_Trap_1.png/revision/latest?cb=20130403030203 Here is the wiki image of the trap. When the sleeping spider is attacked, othes spider warrior will spawn around. It's the scenario that make the spider asleep and spawn others spider when the event is triggered. The code of the setpiece look like this Spoiler return { version = "1.1", luaversion = "5.1", orientation = "orthogonal", width = 32, height = 32, tilewidth = 16, tileheight = 16, properties = {}, tilesets = { { name = "tiles", firstgid = 1, tilewidth = 64, tileheight = 64, spacing = 0, margin = 0, image = "../../../../tools/tiled/dont_starve/tiles.png", imagewidth = 512, imageheight = 384, properties = {}, tiles = {} } }, layers = { { type = "tilelayer", name = "BG_TILES", x = 0, y = 0, width = 32, height = 32, visible = true, opacity = 1, properties = {}, encoding = "lua", data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }, { type = "objectgroup", name = "FG_OBJECTS", visible = true, opacity = 1, properties = {}, objects = { { name = "spider", type = "spider_warrior", shape = "rectangle", x = 344, y = 225, width = 0, height = 0, visible = true, properties = { ["scenario"] = "sleepingspider_spiderambush" } }, { name = "", type = "houndbone", shape = "rectangle", x = 306, y = 162, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "houndbone", shape = "rectangle", x = 328, y = 138, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "houndbone", shape = "rectangle", x = 386, y = 289, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "houndbone", shape = "rectangle", x = 396, y = 160, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "sapling", shape = "rectangle", x = 186, y = 146, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "sapling", shape = "rectangle", x = 222, y = 150, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "sapling", shape = "rectangle", x = 232, y = 177, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "sapling", shape = "rectangle", x = 218, y = 203, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "sapling", shape = "rectangle", x = 204, y = 174, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "sapling", shape = "rectangle", x = 182, y = 196, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "perma_grass", shape = "rectangle", x = 226, y = 259, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "perma_grass", shape = "rectangle", x = 194, y = 260, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "perma_grass", shape = "rectangle", x = 198, y = 290, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "perma_grass", shape = "rectangle", x = 189, y = 312, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "perma_grass", shape = "rectangle", x = 227, y = 314, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "perma_grass", shape = "rectangle", x = 232, y = 288, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 128, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 144, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 176, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 192, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 160, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 240, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 208, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 272, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 288, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 256, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 320, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 144, y = 304, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 160, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 192, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 176, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 224, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 208, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 240, y = 112, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 160, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 176, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 224, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 208, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 240, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 192, y = 336, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 288, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 128, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 320, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 144, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 272, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 176, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 160, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 304, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 256, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 160, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 176, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 224, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 208, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 240, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "wall_hay", shape = "rectangle", x = 192, y = 224, width = 16, height = 16, visible = true, properties = {} }, { name = "", type = "houndbone", shape = "rectangle", x = 291, y = 264, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "houndbone", shape = "rectangle", x = 366, y = 129, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "pighead", shape = "rectangle", x = 304, y = 304, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "twiggy_tall", shape = "rectangle", x = 197, y = 159, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "twiggy_tall", shape = "rectangle", x = 232, y = 178, width = 0, height = 0, visible = true, properties = {} }, { name = "", type = "twiggy_tall", shape = "rectangle", x = 197, y = 200, width = 0, height = 0, visible = true, properties = {} } } } } } Specifically, the object "spider_warrior" have a custom propertie : { name = "spider", type = "spider_warrior", shape = "rectangle", x = 344, y = 225, width = 0, height = 0, visible = true, properties = { ["scenario"] = "sleepingspider_spiderambush" } } This is "sleepingspider_spiderambush.lua" in Don't Starve Together\data\scripts\scenarios Spoiler local function OnWakeUp(inst, scenariorunner, data) -- Spawn spider queen here, disable scenario. inst.components.sleeper.hibernate = false local pt = Vector3(inst.Transform:GetWorldPosition()) local theta = math.random() * 2 * PI local radius = 15 local steps = 3 local ground = TheWorld local player = data.attacker local settarget = function(inst, player) if inst and inst.brain then inst.brain.followtarget = player end end -- Walk the circle trying to find a valid spawn point for i = 1, steps do local offset = Vector3(radius * math.cos( theta ), 0, -radius * math.sin( theta )) local wander_point = pt + offset if ground.Map and ground.Map:GetTileAtPoint(wander_point.x, wander_point.y, wander_point.z) ~= GROUND.IMPASSABLE then local particle = SpawnPrefab("poopcloud") particle.Transform:SetPosition( wander_point.x, wander_point.y, wander_point.z ) local spider = SpawnPrefab("spider_warrior") spider.Transform:SetPosition( wander_point.x, wander_point.y, wander_point.z ) spider:DoTaskInTime(1, settarget, player) end theta = theta - (2 * PI / steps) end scenariorunner:ClearScenario() end local function OnCreate(inst, scenariorunner) --Anything that needs to happen only once. IE: Putting loot in a chest. --"I'm different." end local function OnLoad(inst, scenariorunner) --Anything that needs to happen every time the game loads. if inst.sg then inst.sg:GoToState("sleep") inst.components.sleeper.hibernate = true end inst.scene_attackedfn = function(oninst, data) OnWakeUp(inst, scenariorunner, data) end inst:ListenForEvent("attacked", inst.scene_attackedfn) end local function OnDestroy(inst) --Stop any event listeners here. if inst.scene_attackedfn then inst:RemoveEventCallback("attacked", inst.scene_attackedfn) inst.scene_attackedfn = nil end end return { OnCreate = OnCreate, OnLoad = OnLoad, OnDestroy = OnDestroy } Another example is the trap_firestaff.lua/trap_icestaff.lua. Both will call the same scenario, staff_hounds.lua, one scenario that put hound in forcesleep and wake them all if someone take the staff. You could add scenario to a chest that will define the content of the chest. Here is one example : chest_cavesupplies.lua Spoiler chestfunctions = require("scenarios/chestfunctions") local function OnCreate(inst, scenariorunner) local items = { { item = "slurtleslime", count = math.random(5, 12), }, { item = "slurtle_shellpieces", count = math.random(3, 8), }, { item = "lightbulb", count = math.random(4, 9) }, { item = "armorsnurtleshell", chance = 0.05, initfn = function(item) item.components.armor:SetCondition(math.random(item.components.armor.maxcondition * 0.33, item.components.armor.maxcondition * 0.8))end }, { item = "slurtlehat", chance = 0.05, initfn = function(item) item.components.armor:SetCondition(math.random(item.components.armor.maxcondition * 0.33, item.components.armor.maxcondition * 0.8))end }, { item = "batbat", chance = 0.05, initfn = function(item) item.components.finiteuses:SetUses(math.random(item.components.finiteuses.total * 0.33, item.components.finiteuses.total * 0.8)) end }, { item = "log", count = math.random(3, 10) }, { item = "twigs", count = math.random(3, 10) }, { item = "flint", count = math.random(3, 10) }, { item = "healingsalve", count = math.random(2, 6) }, { item = "guano", count = math.random(3, 10) }, { item = "rocks", count = math.random(3, 10) }, { item = "goldnugget", count = math.random(2,6) }, { item = "silk", count = math.random(3, 10) }, { item = "bluegem", chance = 0.25, }, { item = "redgem", chance = 0.25, }, { item = "bedroll_furry", }, } chestfunctions.AddChestItems(inst, items) end return { OnCreate = OnCreate } This scenario will add various items in a chest, you could choose items, number of theses items, chance that they spawn, and for item with durability/use, define the remaining durability/use. This chest is only beneficial, but you could do trap chest (like the one spoiling the food you have on you, the explosive chest, or the season change chest and ixebox) Others properties : Some examples of custom properties other than scenario Custom name on gravestone : Spoiler { name = "Matt", type = "gravestone", shape = "rectangle", x = 96, y = 288, width = 0, height = 0, visible = true, properties = { ["data.setepitaph"] = "Matt" } } Burnt prefab (for tree mostly) Spoiler { name = "", type = "marsh_tree", shape = "rectangle", x = 365, y = 361, width = 0, height = 0, visible = true, properties = { ["data.burnt"] = "true" } } Data health percent (for wall mostly) Spoiler { name = "", type = "wall_stone", shape = "rectangle", x = 2155, y = 5915, width = 0, height = 0, visible = true, properties = { ["data.health.percent"] = "0.75" } } Make always barren, for plant Spoiler { name = "", type = "berrybush_juicy", shape = "rectangle", x = 4690, y = 6315, width = 0, height = 0, visible = true, properties = { ["data.pickable.makealwaysbarren"] = "1" } } Set amount of work left : Spoiler { name = "", type = "gargoyle_houndatk", shape = "rectangle", x = 219, y = 165, width = 0, height = 0, visible = true, properties = { ["data.workable.workleft"] = "1" } } Saved rotation Spoiler { name = "", type = "atrium_statue_facing", shape = "rectangle", x = 192, y = 496, width = 0, height = 0, visible = true, properties = { ["data.savedrotation.rotation"] = "45" } } Recipe to use for blueprint : Spoiler { name = "", type = "blueprint", shape = "rectangle", x = 64, y = 64, width = 0, height = 0, visible = true, properties = { ["data.recipetouse"] = "earmuffshat" } } Spider den at stage 3 Spoiler { name = "", type = "spiderden", shape = "rectangle", x = 272, y = 288, width = 0, height = 0, visible = true, properties = { ["data.growable.stage"] = "3" } } Tree stump : Spoiler { name = "stump", type = "marsh_tree", shape = "rectangle", x = 96, y = 256, width = 0, height = 0, visible = true, properties = { ["data.stump"] = "true" } } Note : i didn't tried all the properties, some could have restriction i'm not aware of. How to add a set piece. See Serpens code below for a way to add Set piece Edited April 19, 2017 by Lumina 8 Link to comment Share on other sites More sharing options...
Serpens Posted April 19, 2017 Share Posted April 19, 2017 (edited) The knowledge I have about setpieces I got partly from DarkXero and partly teached myself (try and error) from game code. So no gurantee that it is the most efficient/best way Here I learned the most (you should read posts from DarkXero!):http://forums.kleientertainment.com/topic/69888-solved-add-own-set-pieces-to-worldgeneration/ Content of this post: - make variable setpieces - add fixed amount of setpiece to a specific task - make sure setpiece is successfully spawned The setpieces described in the tutorial link above are so called "static layouts". You can find more examples in scripts/map/static_layouts. But you can also make some easier setpieces without needing those modding tools. You can find examples for this in scripts/map/layouts.lua For example a simple ring of mushrooms: ["MushroomRingLarge"] = { type = LAYOUT.CIRCLE_EDGE, defs = { unknown_plant = { "red_mushroom", "green_mushroom", "blue_mushroom"}, }, count = { unknown_plant = 15, }, scale = 1.5 } "unknown_plant" is just a name you choose, but must be the same for "defs" and for "count" of course. When you make your own layout like this, simply put the code in a new file in your mods scripts/layouts folder. Eg. for a juicyberryfarm with 4 bushes: return { type = LAYOUT.STATIC, -- Choose layout type args = nil, -- Add any arguments for the layout function defs = -- Define a choice list for substitution below { unknown_plant = { "berrybush_juicy" }, }, layout = -- Lay the objects in whatever pattern { unknown_plant = { {x=-1,y=-1}, {x=1,y=-1}, -- coordinates with 0,0 in the middle {x=-1, y=1}, {x=1, y=1} }, }, count = nil, -- Either choose to specify the objects positions or a number of objects scale = 0.3 -- Choose a scale on which to place everything. -- scale must be 1 if we set grount tiles } At best make one file for every setpiece, like the code above (with return {...}) and name it for example "juicyberryfarm.lua". As you can see in the layouts.lua, you can also edit static layouts to make them a bit more random. Eg. the "simple base" setpiece, defined in scripts/map/static_layouts/simple_base.lua. One entry in this static layout is called "construction_area", which we make random here: require("constants") local StaticLayout = require("map/static_layout") ["SimpleBase"] = StaticLayout.Get("map/static_layouts/simple_base", { -- load the static layout areas = { construction_area = function() return PickSome(2, { "birdcage", "cookpot", "firepit", "homesign", "beebox", "meatrack", "icebox", "tent" }) end, -- picksome is a function defined in util.lua, it will pick 2 random things from the list }, }) Other important values for a setpiece are "start_mask" and "fill_mask". They define how/where the setpiece is placed. When both are not defined, they will get the default values, which is PLACE_MASK.NORMAL I think. When you ever took a look at a logfile, you maybe saw entries like this:"Warning! Could not find a spot for Maxwell1 in node ..." This means according to the masks, it was not possible to place this setpiece, cause the generation found no empty spot. When the mask is normal and the setpiece is quite big, it is very likely that you get this message and your setpiece is not placed. I think start_mask is only one point, where to start to place the setpiece. And fill_mask is the whole space the setpiece needs. You can set the masks to (found in constants.lua): Spoiler PLACE_MASK.NORMAL PLACE_MASK.IGNORE_IMPASSABLE, PLACE_MASK.IGNORE_BARREN, PLACE_MASK.IGNORE_IMPASSABLE_BARREN, PLACE_MASK.IGNORE_RESERVED, PLACE_MASK.IGNORE_IMPASSABLE_RESERVED, PLACE_MASK.IGNORE_BARREN_RESERVED, PLACE_MASK.IGNORE_IMPASSABLE_BARREN_RESERVED, "PLACE_MASK.IGNORE_IMPASSABLE_BARREN": is recommend if you want a high chance of it to spawn and/or it is a big setpiece, since it is much more likely that the setpiece is successfully placed. "_RESERVED": This also ignores other setpieces. This can also mean that two or more setpieces are created at the same place! So be careful with it. Set fill_mask to one of this values is more important, than the start_mask, since fill_mask is a bigger area. Instead of setting those values directly in the layout, you can also set them for any existing layout in modworldgenmain, see below. How to add a set piece to worldgeneration: There are several possible ways. Eg if you want a fixed amount of it to spawn? Or do you want it several times in a specific biome by defining a chance? Fixed Amount: First we load the layouts.lua and add our new layouts to that list (so the rest is done automatically from the game, which adds those layouts to database) local Layouts = GLOBAL.require("map/layouts").Layouts -- load the table of existing layouts. we want to add our layouts Layouts["My Juicyberry Farm"] = GLOBAL.require("map/layouts/juicyberryfarm") -- load our juicyberryfarm and put it into Layouts with name "My Juicyberry Farm" Now you can add the layout for example to a specific "task". You can find all existing tasks in scripts/map/tasks folder: AddTaskSetPreInitAny(function(tasksetdata) if tasksetdata.location ~= "forest" then -- this stuff is only for overworld (of course you can also make it for caves or both) return end tasksetdata.set_pieces["My Juicyberry Farm"] = { count = 2, tasks={"Befriend the pigs","Forest hunters", "For a nice walk", "Magic meadow",}} -- random task from this list is chosen for every count. So if there is no placing problem (masks) you will have it 2 times in the world end) If you want to edit the fill_mask for a layout here instead of in the layout file itself, do this (not 100% sure if addlevelpreinit is necessary): AddLevelPreInitAny(function(level) Layouts["My Juicyberry Farm"].fill_mask = GLOBAL.PLACE_MASK.IGNORE_IMPASSABLE_BARREN end) In case you want something 100% be spawned in the world, like eg. pigking, you can add it to "ordered_story_setpieces" (edit: better use required_setpieces) (for prefab you can also use "required_prefabs"). This will cause the world to reload until the set_piece was successfully placed. Make sure you set good fill_mask value, cause if it is normal and it is a big setpiece, you could end up with endless generating of world, cause the set_piece is never placed successfully. AddLevelPreInitAny(function(level) if level.location ~= "forest" then -- only in overworld return end if level.ordered_story_setpieces == nil then -- if ordered_story_setpieces does not exist already, create it level.ordered_story_setpieces = {} end table.insert(level.ordered_story_setpieces, "My Juicyberry Farm") end) You can also set setpieces per room: local rooms_for_pigs = {"BGCrappyForest", "BGForest"} local pick = math.random(#rooms_for_pigs) AddRoomPreInit(rooms_for_pigs[pick], function(room) if room.contents.countstaticlayouts == nil then room.contents.countstaticlayouts = {} end room.contents.countstaticlayouts["PigGuardsB"] = function() return 1 end end) see this and following posts:http://forums.kleientertainment.com/topic/69888-solved-add-own-set-pieces-to-worldgeneration/?do=findComment&comment=811143Example Mods: Increase animals+more game setpieces: http://steamcommunity.com/sharedfiles/filedetails/?id=758921911 Teleportato: http://steamcommunity.com/sharedfiles/filedetails/?id=756229217 Multi Worlds: http://steamcommunity.com/sharedfiles/filedetails/?id=726432903 Map Preset : http://steamcommunity.com/sharedfiles/filedetails/?id=608722692 Edited September 4, 2019 by Serpens 6 Link to comment Share on other sites More sharing options...
Bunions Posted April 30, 2017 Share Posted April 30, 2017 (edited) Wow awesome I have been asking around and trying to learn more about this behind the scenes. Timely and appreciated! By the way do you 2 gents use the DST Modders Discord? Your brains would be welcome there too! Edited April 30, 2017 by Bunions Link to comment Share on other sites More sharing options...
Kronas Posted January 6, 2018 Share Posted January 6, 2018 i read this but what's a "setpiece" pardon my stupid question if i missed something Link to comment Share on other sites More sharing options...
Lumina Posted January 6, 2018 Author Share Posted January 6, 2018 (edited) 2 hours ago, Kronas said: i read this but what's a "setpiece" A set piece is an ensemble of objets that you can find in the world of don't starve. For example, this is a set piece : It's a killer bee set piece, when 3 wasphive are surrounded by grass. Some are garanteed to spawn in a world (bee queen, toadstool in cave, pig kind...), most of them are random. A set piece could be beneficial to the player (pig king), detrimental, both, neutral... Pretty much everything you want. For example, the killer bee set piece is both detrimental (killer bee are dangerous, and the wasphive are close together), and beneficial (if you can destroy the nest you have honeycomb and a nice spot of grass to harvest). Edited January 6, 2018 by Lumina Link to comment Share on other sites More sharing options...
DST_LSJ Posted September 29, 2019 Share Posted September 29, 2019 EXM? I need some help with Tiled. I put all tiles I could found and only get several tiles. Spoiler I changed mud 's pic, never mind. So here is the constants of tiles in game date. And which I put in the pic. Spoiler As you see, some tile sets were failed in game. I want to find the desert tile. Could you pls help me? 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