Jump to content

Recommended Posts

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

There's this mess of rag-tag code I extracted from Industrial Resolution:

 

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

local tasklist = GLOBAL.tasks.sampletasks

local task_names = {}

for _, task in pairs(tasklist) do
   table.insert(task_names, task.id) --NOTICE that this means the setpiece can spawn ANYWHERE
end --you could probably limit it to a certain few tasks, if you know how they're called

Layouts["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
    end
end)

 

It adds two setpieces, one with a chance.

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
×
  • Create New...