Jump to content

Limit custom set piece to 1 per world?


Recommended Posts

So I put together my first custom set piece this weekend, and thought I got everything working, so I released it. Then when testing other things, I realised it hadn't spawned just once on my map, but multiple times (9). I should have checked for something like this before releasing, but I was all took up with the excitement of getting the thing working.

 

I'm looking through other code right now, but I would be very grateful if anyone is able to point me in the right direction as to for limiting the spawn to 1 instance per world generated? I'm assuming this will be defined in modmain or modworldgenmain. (mod is here for those who want to look at the files)

 

I've essentially followed this tutorial (but can't post there because it's 30+ days old).

Link to comment
Share on other sites

Update:

 

So, on and off since I posted this I've tried to get it to work. Mainly I've been looking at other mods that spawn prefabs and set pieces to see if I can use the code, but I am an absolute novice to DS modding.

 

Now I'm focusing on this part of my code:

 

room.contents.countstaticlayouts["SETPIECENAME"] = 1

 

If the value is at anything less than 1, nothing shows up. But if it's at 1 or higher, 10+ instances of the set piece spawn in a world. They're spawning in the right biome, but too frequently. I'm at a loss for how to continue.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...