Jump to content

Recommended Posts

What would be the best option for the following.

I am making 20 shrines that spawn on the map. Namely 10 on Overworld and 10 in Caves. All of which use the same prefab, however a data.value is set in Tiled.

There is nothing special about what is around them, and they just need to spawn on the map.

 

Do I make 20 setpieces  and use level.required_setpieces = {}

or

Do I make 20 different prefabs (numbered 1 - 20: example: shrine_1, shrine_2) and use level.required_prefabs = {}

 

Does using setpieces take away from natural spawning setpieces or just add more in?

Edited by JadeKnightblazer

Thinking its best with option 2, however having issues with modworldgenmain to load required prefabs with...

 

            if level.location == "forest" then -- only in overworld
            
            if level.required_prefabs == nil then
            level.required_prefabs = {}
            end

            table.insert(level.required_prefabs, "custom_altar_1")
        end

 

Just gets into a stuck world creation screen.  I have theses at the top of my lua


local Layouts = GLOBAL.require("map/layouts").Layouts --this is where we add the setpiece
local StaticLayout = GLOBAL.require("map/static_layout") --this helps us load the setpiece

 

is there a missing prefab one I need? or something like this for prefabs below?

Layouts["custom set piece"] = StaticLayout.Get("map/static_layouts/custom_setpiece") --index your setpiece
 

required_prefab does not add soemthing. I just makes the worldgeneration stop and try again, until some other code finally was able to place that prefab.

If you just want to place a single prefab, with no special stuff around it, it is best to simply spawn it in within modmain (eg.in  AddPrefabPostInit("world",...) (eg. count how many prefabs exist in Ents and if it is less then 10, spawn some. Or save and load somewhere if the prefabs were spawned already or not (so it is not spawned again on every game start).

You can take a look at my teleportato mod for this. Normally the teleportato parts are generated by setpieces. But setpiece placement from DST is very bad, especially for big setpieces it fails very often. Therefore I have code in modmain.lua to manually spawn the parts that are missing.

https://steamcommunity.com/sharedfiles/filedetails/?id=756229217

  • Like 1

Honestly I have looked into your teleportato even before I posted XD.

 

I can get every thing to spawn that I want, however..... If I say spawn 13 setpieces, do my 13 setpieces remove 13 other default setpieces?

I would hate for my req setpieces remove from the world than add to it!! :)

 

Thank you about the required_prefab part.  I thought it would work like the eyebone. Where I could just tell the worldgen to spawn the 10 prefabs and I have and not care where they would spawn.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...