SiliconGhetto Engine API
    Preparing search index...

    Function createInventoryAPI

    • Returns {
          give(blockType: number, count?: number): boolean;
          take(blockType: number, count?: number): boolean;
          has(blockType: number, count?: number): boolean;
          get selected(): number;
          set selected(s: number): void;
          swap(a: number, b: number): void;
          drop(slot: number): void;
          get(slot: number): InventorySlot;
          set(slot: number, type: number, count: number): void;
      }

      • give: function
        • Add items to the player's inventory (first available slot).

          Parameters

          • blockType: number

            Block or item type ID to give

          • count: number = 1

            Number of items to add (default 1)

          Returns boolean

          True if items were added, false if inventory is full

          game.inventory.give(game.blocks.DIAMOND_ORE, 10);
          
      • take: function
        • Remove items from the player's inventory.

          Parameters

          • blockType: number

            Block or item type ID to remove

          • count: number = 1

            Number of items to remove (default 1)

          Returns boolean

          True if items were removed, false if not enough in inventory

      • has: function
        • Check whether the player has at least the specified count of an item.

          Parameters

          • blockType: number

            Block or item type ID

          • count: number = 1

            Minimum count required (default 1)

          Returns boolean

          True if the player has enough

      • get selected(): number

        Get the currently selected hotbar slot index.

      • set selected(s: number): void

        Set the active hotbar slot.

      • swap: function
        • Swap the contents of two inventory slots.

          Parameters

          • a: number

            First slot index

          • b: number

            Second slot index

          Returns void

      • drop: function
        • Drop all items from a slot onto the ground.

          Parameters

          • slot: number

            Slot index to drop

          Returns void

      • get: function
      • set: function
        • Directly set the contents of an inventory slot.

          Parameters

          • slot: number

            Slot index

          • type: number

            Block or item type ID

          • count: number

            Number of items

          Returns void