Fuffles Posted January 26, 2018 Share Posted January 26, 2018 Hello Buzzies, I had never touched worldgen in DST before nor in DS, and I wish to make a prefab gen randomly in a specific biome (as if I would be adding something like grass to a specific biome) but am unsure how to even beginn, so I hope to get some help here Link to comment https://forums.kleientertainment.com/forums/topic/86810-basic-worldgen/ Share on other sites More sharing options...
zyxerdima Posted January 26, 2018 Share Posted January 26, 2018 (edited) Hello FuffledBeeQueen, Don't be lazy - search for it at this forum before starting new theread theres a lot of them with usefull info, for example one, second, third Recently I've created my first mod using third link, specially this comment because my goal was to create Set Piece in certain Biome. In case of my mod I created Set Piece map (map is description for Set Piece - what it should contain, if you want to create one item you can still use map for only 1 prefab and define it in layout = {..}), it looked like this: \scripts\map\layouts\dyp_lucky_pond_set.lua Spoiler --this layout describes 'Lucky Pond' Set Piece require("constants") local StaticLayout = require("map/static_layout") return { type = LAYOUT.STATIC, args = nil, defs = {}, ground_types = {GROUND.GRASS}, ground = { {0, 1, 1, 1, 0}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {0, 1, 1, 1, 0}, }, --desctibe object which ones Set Piece should contain layout = { --pass Prefab name itself and coordinates where it sould be pigtorch = { {x=-3, y=-3}, {x=3, y=-3}, {x=-5, y=0}, {x=5, y=0}, {x=-3, y=3}, {x=3, y=3}, --{x=0,y=-5}, {x=0,y=5}, }, dyp_lucky_pond = { {x=0, y=0} }, }, scale = 0.4 } and you should create modworldgenmain.lua in root of your mod and use your map in it, in my case it looked like this: \modworldgenmain.lua Spoiler --this modwordgenmain create Set Piece 'Lucky Pond' local Layouts = GLOBAL.require("map/layouts").Layouts Layouts["dyp_lucky_pond_set"] = GLOBAL.require("map/layouts/dyp_lucky_pond_set") --announce rooms where pond can be spawned local rooms_for_pond = {"MagicalDeciduous", "DeepDeciduous"} local count = 0 --we want only one Lucky Pond to be spawned at whole world local function OrSpawn() if count == 0 then count = 1 --return spawn return 1 else --return not spawn return 0 end end for i, v in ipairs(rooms_for_pond) do AddRoomPreInit(v, function(room) if room.contents.countstaticlayouts == nil then room.contents.countstaticlayouts = {} end room.contents.countstaticlayouts["dyp_lucky_pond_set"] = function() return OrSpawn() end end) end Your modworldgenmain will be applied before your mod will set up while world is generating. I hope my code looks straight-forward, if not - ask any questions, and I'll try to help. Edited January 26, 2018 by zyxerdima spelling Link to comment https://forums.kleientertainment.com/forums/topic/86810-basic-worldgen/#findComment-996230 Share on other sites More sharing options...
Lumina Posted January 27, 2018 Share Posted January 27, 2018 If you want to add something to worldgen like grass, meaning something that will be in one entire biome, here and here, rather than a set piece (ensemble of things that will spawn in one place), i suggest you to use this code : This add, instead of "replacing" stuff to worldgen and ensure a good compatibility between mods. Hope it could help. Link to comment https://forums.kleientertainment.com/forums/topic/86810-basic-worldgen/#findComment-996400 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