Terry_Rosario Posted March 15, 2024 Share Posted March 15, 2024 I've been creating a mod that adds several entities. My plan was for it to be used for decorations and server administrators, but I think it would be nice if everyone could have them without having to use a command to spawn them because they are completely functional But I don't know how to make them generate naturally in the world. Link to comment https://forums.kleientertainment.com/forums/topic/154958-how-to-make-my-creature-spawn-naturally/ Share on other sites More sharing options...
ant7735 Posted March 18, 2024 Share Posted March 18, 2024 You could make a setpiece with an invisible prefab, that spawns a few creatuers; But other than that, I'm not sure 1 Link to comment https://forums.kleientertainment.com/forums/topic/154958-how-to-make-my-creature-spawn-naturally/#findComment-1705760 Share on other sites More sharing options...
Feything Posted March 19, 2024 Share Posted March 19, 2024 You make a modworldgenmain.lua file, and within that file you put something along the lines of this local require = GLOBAL.require local AddRoomPreInit = AddRoomPreInit local GetModConfigData = GetModConfigData local function GenerateMobForRoom(room, factor) AddRoomPreInit(room, function(room) if room.contents.distributeprefabs then room.contents.distributeprefabs.yourmobprefabname = factor end end) end if GetModConfigData("Your Mob something something") == 1 then if GLOBAL.KnownModIndex:IsModEnabled("workshop-1467214795") or GLOBAL.KnownModIndex:IsModForceEnabled("workshop-1467214795") then GenerateMobForRoom("MeadowRocky", 0.035) GenerateMobForRoom("VolcanoRock", 0.035) GenerateMobForRoom("Rocky", 0.035) else GenerateMobForRoom("Rocky", 0.035) end end In this snippet, there's a random workshop ID. That's for Island Adventures. Just in case someone has that mod enabled since it's popular enough to be considered every time you make world gen based mods. The prefab names list are the biomes you want it to generate in. You can list more than one. The numbers next to them is straightforward as to how many you want to spawn in the biome.You can replace the ones here with your own rooms instead of using the ones here. Which can be found in C:\Steam\steamapps\common\Don't Starve Together\data\databundles\scripts.zip\scripts\map\rooms\forest usually. The GetModconfigData is just the option to turn it on and off just in case people don't want your mob spawning everywhere. You put the toggles and config stuff in your modinfo.lua 1 Link to comment https://forums.kleientertainment.com/forums/topic/154958-how-to-make-my-creature-spawn-naturally/#findComment-1705813 Share on other sites More sharing options...
Terry_Rosario Posted April 11, 2024 Author Share Posted April 11, 2024 On 3/19/2024 at 12:42 AM, Feything said: You make a modworldgenmain.lua file, and within that file you put something along the lines of this local require = GLOBAL.require local AddRoomPreInit = AddRoomPreInit local GetModConfigData = GetModConfigData local function GenerateMobForRoom(room, factor) AddRoomPreInit(room, function(room) if room.contents.distributeprefabs then room.contents.distributeprefabs.yourmobprefabname = factor end end) end if GetModConfigData("Your Mob something something") == 1 then if GLOBAL.KnownModIndex:IsModEnabled("workshop-1467214795") or GLOBAL.KnownModIndex:IsModForceEnabled("workshop-1467214795") then GenerateMobForRoom("MeadowRocky", 0.035) GenerateMobForRoom("VolcanoRock", 0.035) GenerateMobForRoom("Rocky", 0.035) else GenerateMobForRoom("Rocky", 0.035) end end In this snippet, there's a random workshop ID. That's for Island Adventures. Just in case someone has that mod enabled since it's popular enough to be considered every time you make world gen based mods. The prefab names list are the biomes you want it to generate in. You can list more than one. The numbers next to them is straightforward as to how many you want to spawn in the biome.You can replace the ones here with your own rooms instead of using the ones here. Which can be found in C:\Steam\steamapps\common\Don't Starve Together\data\databundles\scripts.zip\scripts\map\rooms\forest usually. The GetModconfigData is just the option to turn it on and off just in case people don't want your mob spawning everywhere. You put the toggles and config stuff in your modinfo.lua Thank you very much, the help was very valuable I really appreciate it Now I can continue with that work. Link to comment https://forums.kleientertainment.com/forums/topic/154958-how-to-make-my-creature-spawn-naturally/#findComment-1709924 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