Jump to content

1 of a kind spawn custom setpiece


Recommended Posts

Looking for a way to add a 1 time spawn of a custom setpiece, much like the pig king.

 

Using the modworldgenmain...

local Layouts = GLOBAL.require("map/layouts").Layoutslocal StaticLayout = GLOBAL.require("map/static_layout") Layouts["ResearchLab"] = StaticLayout.Get("map/static_layouts/testerTiledmap") AddRoomPreInit("Forest", function(room)    if not room.contents.countstaticlayouts then        room.contents.countstaticlayouts = {}    end    room.contents.countstaticlayouts["ResearchLab"] = 1end)

Does in fact spawn the custom setpiece in, however the line...

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

Only controls the rarity of the spawn, not a limit. Even if it was set to .01, sure it would be very very rare... however there is a chance 1 or more can still spawn on a map or even none at all.

 

 

Really hoping to have a 1 time spawning of this custom setpiece, just don't know how T_T

Link to comment
Share on other sites

@JadeKnightblazer, the reason why you're spawning multiple times is because your adding it to a room and rooms spawn multiple times. You must add it to the level.

 

AddSetPiecePreInitAny = function(name, count, tasks)	AddLevelPreInitAny(function(level)		if not level.set_pieces then			level.set_pieces = {}		end		level.set_pieces[name] = { count = count, tasks = tasks }	end)end 

 
Link to comment
Share on other sites

So from my code above, it would be

local Layouts = GLOBAL.require("map/layouts").Layoutslocal StaticLayout = GLOBAL.require("map/static_layout") Layouts["ResearchLab"] = StaticLayout.Get("map/static_layouts/testerTiledmap")AddSetPiecePreInitAny = function(name, count, tasks)     AddLevelPreInitAny(function(level)        if not level.set_pieces then            level.set_pieces = {}        end         level.set_pieces["ResearchLab"] = { count = 1, tasks = tasks }    end)end 

Thanks for the functions, but not sure how to apply it.*Worldgen is new coding for me*

Link to comment
Share on other sites

@JadeKnightblazer, that error means that tasks cannot be nil, you must specify at least one task. You can see the task names in map/tasks.

 

Most commonly used:

local tasks={"Make a pick", "Dig that rock", "Great Plains", "Squeltch", "Beeeees!", "Speak to the king", "Forest hunters" }
Edited by Kzisor
Link to comment
Share on other sites

Would it be possible if you could share a known working custom setpiece with this type of worldgen? That way I can see if there are any mistakes I am making :-)

 

 

I mean it could be my Tiled saved data / export is messed up, or simply I am not calling the right task, ect.

 

 

All I know is that the AddRoomPreInit works with my Layouts["ResearchLab"], where as the AddSetPiecePreInitAny seems to ignore it...

Edited by JadeKnightblazer
Link to comment
Share on other sites

@JadeKnightblazer, are you calling the function?

 

local Layouts = GLOBAL.require("map/layouts").Layouts
local StaticLayout = GLOBAL.require("map/static_layout")

Layouts["ResearchLab"] = StaticLayout.Get("map/static_layouts/testerTiledmap")

AddSetPiecePreInitAny = function(name, count, tasks)

AddLevelPreInitAny(function(level)
if not level.set_pieces then
level.set_pieces = {}
end

level.set_pieces[name] = { count = count, tasks = tasks }
end)
end

local tasks={"Make a pick", "Dig that rock", "Great Plains", "Squeltch", "Beeeees!", "Speak to the king", "Forest hunters" }

AddSetPiecePreInitAny("ResearchLab",1,tasks)

 

If you want a known working set piece look at Additional Set Pieces for DST. The one in data/layouts/piece is a working set piece.

Link to comment
Share on other sites

This is what I am using...

local Layouts = GLOBAL.require("map/layouts").Layoutslocal StaticLayout = GLOBAL.require("map/static_layout") Layouts["ResearchLab"] = StaticLayout.Get("map/static_layouts/testerTiledmap")--AddRoomPreInit("Forest", function(room)    --if not room.contents.countstaticlayouts then        --room.contents.countstaticlayouts = {}    --end    --room.contents.countstaticlayouts["ResearchLab"] = 1--end)AddSetPiecePreInitAny = function(name, count, tasks)     AddLevelPreInitAny(function(level)        if not level.set_pieces then            level.set_pieces = {}        end         level.set_pieces[name] = { count = count, tasks = tasks }    end)end AddSetPiecePreInitAny("ResearchLab", 1, "Resource-Rich")
Link to comment
Share on other sites

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
 Share

×
  • Create New...