Tidy 5e Sheets API
    Preparing search index...

    Class ActorItemApi

    API functionality related to Actor-owned items.

    Index

    Constructors

    Methods

    • Registers actor item section commands which Tidy 5e can render at select locations on the sheet.

      Parameters

      Returns void

      Hooks.once('tidy5e-sheet.ready', (api) => {
      api.config.actorItem.registerSectionFooterCommands([
      {
      enabled: (params) =>
      params.section.items?.length > 1 || params.section.spells?.length > 1,
      iconClass: 'fa-solid fa-arrow-up-a-z',
      tooltip: 'Sort by Name Ascending',
      execute: async (params) => {
      const actor = params.actor;
      const itemsToSort = params.section.items ?? params.section.spells;
      await actor.updateEmbeddedDocuments(
      'Item',
      [...itemsToSort]
      .sort((a, b) => {
      return a.name.localeCompare(b.name, game.i18n.lang);
      })
      .map((item, idx) => {
      return { _id: item.id, sort: idx };
      })
      );
      },
      },
      ]);
      });