Skip to content

Commit

Permalink
feat(craftos): add SlotDetail typings
Browse files Browse the repository at this point in the history
This commit adds an explicitly named type for the return of the `list()` function on an inventory peripheral.
This allows for people to create their own typings based off of the slot detail or reference the type as part of their own code.

This also contains one type fix, changing the `count` field on `ItemDetail` to a number.
  • Loading branch information
justinbrick committed Feb 23, 2025
1 parent ea088d7 commit 28f49b1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions types/craftos/craftos.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,13 @@ declare class FluidStoragePeripheral implements IPeripheral {
pullFluid(from: string, limit?: number, name?: string): number;
}

declare type ItemDetail = {
declare type SlotDetail = {
name: string;
count: string;
count: number;
nbt?: string;
}

declare type ItemDetail = SlotDetail & {
displayName: string;
maxCount: number;
damage?: number;
Expand All @@ -527,7 +530,7 @@ declare type ItemDetail = {
/** @noSelf */
declare class InventoryPeripheral implements IPeripheral {
size(): number;
list(): {[index: number]: {name: string, count: number, nbt?: string}};
list(): {[index: number]: SlotDetail};
getItemDetail(slot: number): ItemDetail|undefined;
getItemLimit(slot: number): number;
pushItems(to: string, slot: number, limit?: number, toSlot?: number): number;
Expand Down

0 comments on commit 28f49b1

Please sign in to comment.