Finerlobster Posted August 14, 2015 Share Posted August 14, 2015 Hello everyone.How can I make the worldgen have 100% chance of creating my custom Set Piece but only creating it a single time?Just like the teleportato's things, it have 100% chance of spawning but there is only one in the world.Any help would be much appreciated. Thanks in advance. Link to comment https://forums.kleientertainment.com/forums/topic/57073-help-set-pieces/ Share on other sites More sharing options...
Mobbstar Posted August 15, 2015 Share Posted August 15, 2015 There's this mess of rag-tag code I extracted from Industrial Resolution: local require = GLOBAL.requirelocal Layouts = require("map/layouts").Layoutslocal StaticLayout = require("map/static_layout")require("map/level")require("map/tasks")local tasklist = GLOBAL.tasks.sampletaskslocal task_names = {}for _, task in pairs(tasklist) do table.insert(task_names, task.id) --NOTICE that this means the setpiece can spawn ANYWHEREend --you could probably limit it to a certain few tasks, if you know how they're calledLayouts["irpreset1"] = StaticLayout.Get("map/static_layouts/irpreset1")Layouts["irpreset2"] = StaticLayout.Get("map/static_layouts/irpreset2")AddLevelPreInitAny(function(level) local chosen = {} chosen["irpreset1"] = { count = 1, tasks = task_names } if math.random() < .3 then --TUNE chosen["irpreset2"] = { count = 1, tasks = task_names } end if #chosen > 0 and not level.set_pieces then level.set_pieces = {} end for k,v in pairs(chosen) do level.set_pieces[k] = v endend) It adds two setpieces, one with a chance. Link to comment https://forums.kleientertainment.com/forums/topic/57073-help-set-pieces/#findComment-663510 Share on other sites More sharing options...
Finerlobster Posted August 15, 2015 Author Share Posted August 15, 2015 Thank you so much, Mobbstar. Link to comment https://forums.kleientertainment.com/forums/topic/57073-help-set-pieces/#findComment-663569 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