Skip to content

SoundType

Merlord edited this page Apr 7, 2023 · 2 revisions

Crafting Framework comes with a variety of default crafting sounds to choose from, however you can also register your own. A "SoundType" is essentially a list of sounds registered to an id. When a recipe is registered with a given SoundType, a random sound will be picked from the SoundType and played when the recipe is crafted.

SoundType

SoundType.register(params: SoundTypeData)

Registers a new SoundType. If the SoundType is already registered, the sound paths will be merged into the existing list.

Example

-- Register a metal sound type
CraftingFramework.SoundType.register{
  id = "metal",
  soundPaths = {
    "mymod\\metal_01.wav",
    "mymod\\metal_02.wav",
  }
}

-- Use in a recipe
CraftingFramework.Recipe:new{
    id = "recipe_toy_car_01",
    craftableId = "metal_toy",
    description = "A toy car made of a metal,
    materials = {
        { material = "metal", count = 1 },
        { material = "misc_wheel_01", count = 4 },
    },
    category = "Toys",
    soundType = "metal"
},

SoundType.play(id)

Play a random sound of the given sound type.

Example

SoundType.play("metal")
Clone this wiki locally