diff --git a/build.sh b/build.sh deleted file mode 100644 index 8b13789..0000000 --- a/build.sh +++ /dev/null @@ -1 +0,0 @@ - diff --git a/patch.sh b/patch.sh new file mode 100755 index 0000000..f10b424 --- /dev/null +++ b/patch.sh @@ -0,0 +1,7 @@ +#!/usr/bin/bash + +function patch() { + sed -i $1 rOSs.lua +} + +patch "s/peripheral:/peripheral\./g" diff --git a/rOSs.lua b/rOSs.lua index 648a3be..8202ff7 100644 --- a/rOSs.lua +++ b/rOSs.lua @@ -27,7 +27,7 @@ ____modules = { local ____exports = {} local basalt = require("src.libs.basalt.basalt") local function main(self) - local d = peripheral:find("monitor")[1] + local d = peripheral.find("monitor")[1] local main = basalt:addMonitor() main:setMonitor(d) main:addLabel():setText("uwu") diff --git a/src/types/cct.d.ts b/src/types/cct.d.ts index 317d588..ee990e1 100644 --- a/src/types/cct.d.ts +++ b/src/types/cct.d.ts @@ -97,7 +97,9 @@ declare class commands { type AnyPeripheral = command | computer | drive | modem | Monitor | printer | speaker | BigReactors; -declare class peripheral { +declare class Peripheral {} + +declare namespace peripheral { /** * Provides a list of all peripherals available. * If a device is located directly next to the system, @@ -105,45 +107,45 @@ declare class peripheral { * If a device is attached via a Wired Modem, * then it'll be reported according to its name on the wired network. */ - static getNames(): string[]; + function getNames(): string[]; /** * Determines if a peripheral is present with the given name. */ - static isPresent(name: string): boolean; + function isPresent(name: string): boolean; - static getType(peripheral: string|peripheral): string|null; + function getType(peripheral: string|Peripheral): string|null; - static hasType(peripheral: string|peripheral, peripheral_type: string): boolean|null; + function hasType(peripheral: string|Peripheral, peripheral_type: string): boolean|null; - static getMethods(name: string): string[]|null; + function getMethods(name: string): string[]|null; - static getName(peripheral: peripheral): string; + function getName(peripheral: Peripheral): string; - static call(name: string, method: string, ...arguments: unknown[]): unknown; + function call(name: string, method: string, ...arguments: unknown[]): unknown; - static wrap(name: string): peripheral| null; + function wrap(name: string): T | null; - static find(ty: string, - filter?: (name: string, wrapped: peripheral) => boolean - ): [peripheral, peripheral|null, peripheral|null, peripheral|null]; + function find(ty: string, + filter?: (name: string, wrapped: Peripheral) => boolean + ): [T, T|null, T|null, T|null]; } -declare class inventory { - static size(): number; - static list(): Map; - static getItemDetail(slot: number): ItemInfo|null; - static getItemLimit(slot: number): number; - static pushItems(toName: string, fromSlot: number, limit: number, toSlot: number): number; - static pullItems(fromName: string, fromSlot: number, limit: number, toSlot: number): number; +declare class inventory extends Peripheral { + size(): number; + list(): Map; + getItemDetail(slot: number): ItemInfo|null; + getItemLimit(slot: number): number; + pushItems(toName: string, fromSlot: number, limit: number, toSlot: number): number; + pullItems(fromName: string, fromSlot: number, limit: number, toSlot: number): number; } -declare class fluid_storage { - static tanks(): Map; - static pushFluid(toName: string, limit?: number, fluidName?: string): number; - static pullFluid(fromName: string, limit?: number, fluidName?: string): number; +declare class fluid_storage extends Peripheral{ + tanks(): Map; + pushFluid(toName: string, limit?: number, fluidName?: string): number; + pullFluid(fromName: string, limit?: number, fluidName?: string): number; } -declare class energy_storage { +declare class energy_storage extends Peripheral { static getEnergy(): number; static getEnergyCapacity(): number; } @@ -151,42 +153,42 @@ declare class energy_storage { type Instrument = "harp" | "basedrum" | "snare" | "hat" | "bass" | "flute" | "bell" | "guitar" | "chime" | "xylophone" | "iron_xylophone" | "cow_bell" | "didgeridoo" | "bit" | "banjo" | "pling"; -declare class speaker { - static playNote(instrument: Instrument, volume?: number, pitch?: number): boolean; - static playSound(name: string, volume?: number, pitch?: number): boolean; - static playAudio(audio: number[], volume?: number): boolean; - static stop(): void; +declare class speaker extends Peripheral { + playNote(instrument: Instrument, volume?: number, pitch?: number): boolean; + playSound(name: string, volume?: number, pitch?: number): boolean; + playAudio(audio: number[], volume?: number): boolean; + stop(): void; } -declare class printer { - static write(...args: (string|number)[]): void; - static getCursorPos(): [number, number]; - static setCursorPos(x: number, y: number): void; - static getPageSize(): number; - static newPaget(): void; - static endPage(): boolean; - static setPageTitle(s: string): void; - static getInkLevel(): number; - static getPaperLevel(): number; +declare class printer extends Peripheral { + write(...args: (string|number)[]): void; + getCursorPos(): [number, number]; + setCursorPos(x: number, y: number): void; + getPageSize(): number; + newPaget(): void; + endPage(): boolean; + setPageTitle(s: string): void; + getInkLevel(): number; + getPaperLevel(): number; } declare class Monitor extends Redirect { static getNames(): string[]; static isPresent(name: string): boolean; - static getType(peripheral: string|peripheral): string|null; - static hasType(peripheral: string|peripheral, peripheral_type: string): boolean|null; + static getType(peripheral: string|Peripheral): string|null; + static hasType(peripheral: string|Peripheral, peripheral_type: string): boolean|null; static getMethods(name: string): string[]|null; - static getName(peripheral: peripheral): string; + static getName(Peripheral: Peripheral): string; static call(name: string, method: string, ...arguments: unknown[]): unknown; - static wrap(name: string): peripheral| null; - static find(ty: string, - filter: (name: string, wrapped: peripheral) => boolean - ): [peripheral, peripheral|null, peripheral|null, peripheral|null]; + static wrap(name: string): Peripheral| null; + static find(ty: string, + filter: (name: string, wrapped: Peripheral) => boolean + ): [T, T|null, T|null, T|null]; setTextScale(scale: number): void; getTextScale(): number; } -declare class modem { +declare class modem extends Peripheral { static open(channel: number): void; static isOpen(channel: number): boolean; static close(channel: number): void; @@ -202,7 +204,7 @@ declare class modem { static getNameLocal(): string|null; } -declare class drive { +declare class drive extends Peripheral { static isDiskPresent(): boolean; static getDiskLabel(): string|null; static setDiskLabel(l?: string): null; @@ -216,7 +218,7 @@ declare class drive { static getDiskID(name: string): string|null; } -declare class disk { +declare class disk extends Peripheral { static getLabel(name: string): string|null; static setLabel(name: string, label?: string): void; static hasData(name: string): boolean; @@ -231,7 +233,7 @@ declare class disk { -declare class computer { +declare class computer extends Peripheral { static turnOn(): void; static shutdown(): void; static reboot(): void; diff --git a/tsconfig.json b/tsconfig.json index bc09b69..e170dab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,6 @@ "luaTarget": "universal", "luaBundleEntry": "src/index.ts", "luaBundle": "rOSs.lua", - "luaLibImport": "inline", + "luaLibImport": "require", } }