JadeKnightblazer Posted February 28, 2015 Share Posted February 28, 2015 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"] = 1Only 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 More sharing options...
Kzisor Posted February 28, 2015 Share Posted February 28, 2015 @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 More sharing options...
JadeKnightblazer Posted February 28, 2015 Author Share Posted February 28, 2015 So from my code above, it would belocal 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 More sharing options...
Kzisor Posted February 28, 2015 Share Posted February 28, 2015 @JadeKnightblazer, do not change the function I provided. You simply call the function I provided to with the name of your layout, the amount, and the tasks in which you want it to be spawned with. Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 28, 2015 Author Share Posted February 28, 2015 (edited) T_T its the calling part that confusses me @_@. I understand what the functions are doing, just not how give those functions my layout *calling* Something like this? AddSetPiecePreInitAny("ResearchLab",1,nil), Edited February 28, 2015 by JadeKnightblazer Link to comment Share on other sites More sharing options...
Kzisor Posted February 28, 2015 Share Posted February 28, 2015 @JadeKnightblazer, that is exactly how you do it. Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 28, 2015 Author Share Posted February 28, 2015 Giving it a test, thank you!!!!! Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 28, 2015 Author Share Posted February 28, 2015 Hmm... sadly it must have a Task linked to it? I get the following error: Trying to add set piece 'ResearchLab' but no choices given. scripts/map/level.lua (133,1) in function 'GetTasksForLevel' Link to comment Share on other sites More sharing options...
Kzisor Posted February 28, 2015 Share Posted February 28, 2015 (edited) @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 February 28, 2015 by Kzisor Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 28, 2015 Author Share Posted February 28, 2015 Hmm... no more errors, but still nothing spawning. I have the count at 40 atm I used the following Tut, which works with the rooms. T_T [TUTORIAL] Making a Custom SetPiece: http://forums.kleientertainment.com/topic/32602-tutorial-making-a-custom-setpiece/Started By JackSlender Link to comment Share on other sites More sharing options...
Kzisor Posted February 28, 2015 Share Posted February 28, 2015 @JadeKnightblazer, the size of your set piece can affect if it will spawn or not. What is the dimensions of your set piece? Anything above 1024x1024 will either not spawn or have difficulties spawning, based on my tests. Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted February 28, 2015 Author Share Posted February 28, 2015 have it at 5x5 like the Tut I linked had. Trying a 50x50 now to see if I can atleast see it on the map (With the no map fog mod). Does your functions work with Layouts? or do I have to create a room? Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted March 1, 2015 Author Share Posted March 1, 2015 (edited) 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 March 1, 2015 by JadeKnightblazer Link to comment Share on other sites More sharing options...
Kzisor Posted March 1, 2015 Share Posted March 1, 2015 @JadeKnightblazer, are you calling the function? 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 thenlevel.set_pieces = {}endlevel.set_pieces[name] = { count = count, tasks = tasks }end)endlocal 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 More sharing options...
JadeKnightblazer Posted March 1, 2015 Author Share Posted March 1, 2015 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 More sharing options...
JadeKnightblazer Posted March 1, 2015 Author Share Posted March 1, 2015 hmm... looking at ours, seems I been to narrow on my task. So using that local tasks will give it more of a chance to spawn. Link to comment Share on other sites More sharing options...
JadeKnightblazer Posted March 1, 2015 Author Share Posted March 1, 2015 Yep that did the trick! -_- Thank you for taking your time and helping me. Link to comment Share on other sites More sharing options...
Kzisor Posted March 1, 2015 Share Posted March 1, 2015 @JadeKnightblazer, you were too narrow on your tasks, you were sending it as a table. That is probably why it wasn't working correctly. Link to comment 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