mpfb_set_asset_material
Swap the material on an equipped MHCLO asset for an alternative shipped beside it, or restore the asset's own default material by asset object name.
Instructions
Replace the material on an equipped MHCLO asset with one of the alternatives that ship beside it - a hat in another colour - or put the asset's own material back.
name is required and is the asset's own Blender object name,
as mpfb_list_objects reports it or as mpfb_add_asset returned it in
asset_object_name - not the character's. There is no active-object
fallback: this destroys that object's current material.
Name the material with either path or fragment, never both.
Both come from mpfb_list_asset_materials, the only catalogue for
them: alternative materials sit in the asset's own directory rather
than in an asset library section, so mpfb_list_assets does not know
about them.
restore_default (default false) instead puts back the material named
by the asset's own MHCLO and clears the recorded
alternative_material. It cannot be combined with path or
fragment.
MPFB has no service-level "set an alternative material" - the logic
exists only in its asset library panel - and two of that panel's quirks
are reproduced here rather than tidied up, because tidying them would
make the result differ from what a user gets from the panel: the new
material is always a MakeSkin material named makeskinmaterial,
whatever the asset had before, and the slots are popped rather than
deleted, so node groups from the previous material survive. The
viewport display colour comes from MPFB's per-type table keyed on the
asset's object_type, so an asset mislabelled when it was equipped
gets the wrong colour here too; diffuse_color_from reports which type
was used and is null when the neutral grey fallback applied.
On applied: true, result carries asset_object_name,
object_type, asset_subdir, path_resolved_by/resolved_path,
alternative_material (the fragment now recorded on the object, empty
when the default was restored) beside alternative_material_before,
materials_destroyed, material_name and diffuse_color_from.
Refusals come back as applied: false (and so performed: false) with
a blocked_by and a sentence: subject_not_found, not_an_mpfb_object,
material_not_found, not_object_mode, asset_source_missing and
default_material_not_found (both for restore_default on an asset
whose own MHCLO cannot be found or names no material on disk), and
type_not_supported for a Basemesh, Proxymeshes or Skeleton -
MPFB's own panel refuses all three, and the first two have a skin
rather than an asset material, which is mpfb_set_skin's job.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| path | No | ||
| fragment | No | ||
| restore_default | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||