-
Notifications
You must be signed in to change notification settings - Fork 2
Material
The Crafting Framework's Material system is designed to maximise mod compatibility by allowing items added by different mods to count towards the same material requirement in a recipe. For example, if Mod A adds mod_a_metal_01
, and Mod B adds mod_b_steel
as a "Metal" material, and each mod requires "Metal" as a material requirement in their recipes, both items will be considered valid Metal materials to craft with.
If your recipes require specific, unique items to craft with, you can simply provide the object id in the material
field in the Material Requirements table when creating the recipe. This will register that object as its own Material automatically. However, if you want to use more generic materials for inter-mod compatibility, such as wood, fabric and metal, you can register them as a Material with the below API.
function | description |
---|---|
Material.getMaterial(id: string): Material | Returns a Material object from a material id. If the material of provided id hasn't been registered before, but id is a valid item id (e.g. defined in the Construction Set), a new material will be created. |
Material:new(materialData): Material | Creates a new Material object. |
Material:registerMaterials(materialData[]) | Registers a list of materials. |
Field | Type | Description |
---|---|---|
id |
string |
Required. This will be the unique identifier used internally by Crafting Framework to identify this material . By convention it should be all lowercase, with a simple name such as "wood" or "metal", to maximise the odds of different mods registering the same material type. |
name |
string | The name of the material. Used in various UIs. |
ids |
string[] | Required. This is the list of item ids that are considered as identical material. |
--Get the Crafting Framework API and check that it exists
local CraftingFramework = include("CraftingFramework")
if not CraftingFramework then return end
--Register your materials
local materials = {
{
id = "wood",
name = "Wood",
ids = {
"misc_firewood",
"misc_oak_wood_01"
}
},
{
id = "metal",
name = "Metal",
ids = {
"misc_iron_01",
"misc_steel_01",
"ingred_scrap_metal_01"
}
}
}
CraftingFramework.Material:registerMaterials(materials)