zyxerdima Posted February 25, 2018 Share Posted February 25, 2018 (edited) Hello, I'm working on mod and all almost done, but I stuck with problem - how to spawn Set Piece with 100% chance anywhere in the world? (e.g. like Pig King, but without special room) My Set Piece "my_set_piece" static layout: Spoiler require("constants") local StaticLayout = require("map/static_layout") return { type = LAYOUT.STATIC, args = nil, defs = {}, ground_types = {GROUND.CARPET, GROUND.CHECKER}, ground = { {1, 1, 1, 1, 1}, {1, 2, 2, 2, 2}, {1, 2, 1, 1, 1}, {1, 2, 2, 2, 1}, {1, 1, 1, 1, 1}, }, --desctibe object which ones Set Piece should contain layout = { --pass Prefab name itself pigtorch = { {x=-3, y=-3}, {x=3, y=3}, }, mermhead = { {x=-3, y=3}, {x=3, y=-3} }, my_new_item = { {x=0, y=0} }, }, scale = 0.5 } As was mentioned at this comment it is possible to use ordered_story_setpieces at modworldgenmain.lua and it should do the job - generate Set Piece with 100% chance, so I've done local Layouts = GLOBAL.require("map/layouts").Layouts Layouts["my_set_piece"] = GLOBAL.require("map/layouts/my_set_piece") Layouts["my_set_piece"].start_mask = GLOBAL.PLACE_MASK.IGNORE_IMPASSABLE_BARREN Layouts["my_set_piece"].fill_mask = GLOBAL.PLACE_MASK.IGNORE_IMPASSABLE_BARREN Layouts["my_set_piece"].layout_position = GLOBAL.LAYOUT_POSITION.CENTER and added code with AddLevelPreInitAny ordered_story_setpieces AddLevelPreInitAny(function(level) if level.location ~= "forest" then -- only in overworld return end if level.ordered_story_setpieces == nil then -- if ordered_story_setpieces does not exist already, create it level.ordered_story_setpieces = {} end table.insert(level.ordered_story_setpieces, "my_set_piece") end) But this didn't working for my Set Piece. Chances are around 50%. At Teleportato mod source code I found usage of AddTaskSetPreInitAny so I've done AddTaskSetPreInitAny(function(tasksetdata) if tasksetdata.location ~= "forest" then return end tasksetdata.set_pieces["my_set_piece"] = { count = 1, tasks={"Make a pick", "Dig that rock", "Great Plains", "Beeeees!", "Speak to the king", "Forest hunters", "For a nice walk", "The hunters", "Magic meadow", "Frogs and bugs","Oasis","Badlands","Lightning Bluff"}} end) And looks like it's working for 100% chances, but I don't know if it is good solution or no - have no idea what 'Task' is. Looking forward to suggestions how it should be done. Edited February 25, 2018 by zyxerdima typo Link to comment Share on other sites More sharing options...
zyxerdima Posted February 28, 2018 Author Share Posted February 28, 2018 Someone? Anyone? Link to comment Share on other sites More sharing options...
justjasper Posted March 1, 2018 Share Posted March 1, 2018 (edited) A task basically means all the bits of worldgen (you can see it there in the examples like "speak to the king" is the pig king area), so attaching your set piece mod to a task is a legit way to do it. If you seem to have made it work 100% just give it some testing - regen a bunch of worlds, check your log files for errors etc. Edited March 1, 2018 by justjasper 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