User Tools

Site Tools


guides:options_for_workplace

Options for Workplaces

Basics

This is an example of a simple workplace MY_BUILDING with a worker of job MY_BUILDING_JOB producing MY_BUILDING_OUTPUT_RESOURCE from MY_BUILDING_INPUT_RESOURCE:

    myMod:register({
        DataType = "BUILDING_PART",
        Id = "MY_BUILDING_PART",
        Mover = { DataType = "BUILDING_PART_MOVER_INSTANCE" },
        ConstructorData = {
            DataType = "BUILDING_CONSTRUCTOR_DEFAULT",
            CoreObjectPrefab = "MY_BUILDING_PREFAB"
        },
        AssetBuildingFunction = "MY_BUILDING_FUNCTION"
    })
 
    myMod:register({
        DataType = "BUILDING_FUNCTION_WORKPLACE",
        Id = "MY_BUILDING_FUNCTION",
        WorkerCapacity = 1,
        RelatedJob = { Job = "MY_BUILDING_JOB", Behavior = "WORK_BEHAVIOR" },
        InputInventoryCapacity = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE", Quantity = 10 }
        },
        ResourceListNeeded = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE", Quantity = 1 }
        },
        ResourceProduced = {
            { Resource = "MY_BUILDING_OUTPUT_RESOURCE", Quantity = 1 }
        }
    })

Same building for producing and selling

This is an example of a simple workplace MY_BUILDING with a worker of job MY_BUILDING_JOB producing and selling MY_BUILDING_OUTPUT_RESOURCE of type MY_RESOURCE_TYPE (see RESOURCE_TYPE) from MY_BUILDING_INPUT_RESOURCE:

    myMod:register({
        DataType = "BUILDING_PART",
        Id = "MY_BUILDING_PART",
        Mover = { DataType = "BUILDING_PART_MOVER_INSTANCE" },
        ConstructorData = {
            DataType = "BUILDING_CONSTRUCTOR_DEFAULT",
            CoreObjectPrefab = "MY_BUILDING_PREFAB"
        },
        AssetBuildingFunction = "MY_BUILDING_FUNCTION"
    })
 
    myMod:register({
        DataType = "BUILDING_FUNCTION_MARKET",
        Id = "MY_BUILDING_FUNCTION",
        TypeList = { "MY_RESOURCE_TYPE" },
        WorkerCapacity = 1,
        RelatedJob = { Job = "MY_BUILDING_JOB", Behavior = "WORK_BEHAVIOR" },
        InputInventoryCapacity = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE", Quantity = 10 }
        },
        ResourceListNeeded = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE", Quantity = 1 }
        },
        ResourceProduced = {
            { Resource = "MY_BUILDING_OUTPUT_RESOURCE", Quantity = 1 }
        }
    })

Workplace with several recipes

Workplace with 2 recipes:

1) produces MY_BUILDING_OUTPUT_RESOURCE_1 from MY_BUILDING_INPUT_RESOURCE_1,

2) produces MY_BUILDING_OUTPUT_RESOURCE_2 from MY_BUILDING_INPUT_RESOURCE_2:

    myMod:register({
        DataType = "BUILDING_PART",
        Id = "MY_BUILDING_PART",
        Mover = { DataType = "BUILDING_PART_MOVER_INSTANCE" },
        ConstructorData = {
            DataType = "BUILDING_CONSTRUCTOR_DEFAULT",
            CoreObjectPrefab = "MY_BUILDING_PREFAB"
        },
        AssetBuildingFunction = "MY_BUILDING_FUNCTION_ASSIGNABLE"
    })
 
    myMod:register({
        DataType = "BUILDING_FUNCTION_ASSIGNABLE",
        Id = "MY_BUILDING_FUNCTION_ASSIGNABLE",
        AuthorizedFunctionList = "MY_BUILDING_FUNCTION_LIST"
    })
 
    myMod:register({
        DataType = "BUILDING_FUNCTION_LIST",
        Id = "MY_BUILDING_FUNCTION_LIST",
        AssetFunctionList = {
            "MY_BUILDING_RECIPE_1_FUNCTION",
            "MY_BUILDING_RECIPE_2_FUNCTION"
        }
    })
 
    myMod:register({
        DataType = "BUILDING_FUNCTION_WORKPLACE",
        Id = "MY_BUILDING_RECIPE_1_FUNCTION",
        IsOverrideCapacity = true,
        CapacityPerSlot = 50,
        WorkerCapacity = 1,
        RelatedJob = { Job = "MY_BUILDING_JOB_1", Behavior = "WORK_BEHAVIOR" },
        InputInventoryCapacity = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE_1", Quantity = 50 }
        },
        ResourceListNeeded = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE_1", Quantity = 1 }
        },
        ResourceProduced = {
            { Resource = "MY_BUILDING_OUTPUT_RESOURCE_1", Quantity = 1 }
        }
    })
 
    myMod:register({
        DataType = "BUILDING_FUNCTION_WORKPLACE",
        Id = "MY_BUILDING_RECIPE_2_FUNCTION",
        IsOverrideCapacity = true,
        CapacityPerSlot = 20,
        WorkerCapacity = 1,
        RelatedJob = { Job = "MY_BUILDING_JOB_2", Behavior = "WORK_BEHAVIOR" },
        InputInventoryCapacity = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE_2", Quantity = 20 }
        },
        ResourceListNeeded = {
            { Resource = "MY_BUILDING_INPUT_RESOURCE_2", Quantity = 1 }
        },
        ResourceProduced = {
            { Resource = "MY_BUILDING_OUTPUT_RESOURCE_2", Quantity = 1 }
        }
    })

Note: The IsOverrideCapacity is mandatory to have different CapacityPerSlot per recipe.

Several workplaces per building

The only way I found is to have a monument with different buildingParts, each one having its own workplace.

Custom soldier's keep

Waiting for the next game upgrade.

guides/options_for_workplace.txt · Last modified: 2021/02/23 11:56 by minotorious