This commit is contained in:
Gvidas Juknevičius 2024-08-23 03:20:09 +03:00
parent 9ef462c104
commit 53dd38aba9
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
5 changed files with 61 additions and 53 deletions

View File

@ -1 +0,0 @@

7
patch.sh Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/bash
function patch() {
sed -i $1 rOSs.lua
}
patch "s/peripheral:/peripheral\./g"

View File

@ -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")

102
src/types/cct.d.ts vendored
View File

@ -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<T extends Peripheral>(name: string): T | null;
static find(ty: string,
filter?: (name: string, wrapped: peripheral) => boolean
): [peripheral, peripheral|null, peripheral|null, peripheral|null];
function find<T extends Peripheral>(ty: string,
filter?: (name: string, wrapped: Peripheral) => boolean
): [T, T|null, T|null, T|null];
}
declare class inventory {
static size(): number;
static list(): Map<number, ItemInfo>;
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<number, ItemInfo>;
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<number, object>;
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<number, object>;
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<T extends Peripheral>(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;

View File

@ -16,6 +16,6 @@
"luaTarget": "universal",
"luaBundleEntry": "src/index.ts",
"luaBundle": "rOSs.lua",
"luaLibImport": "inline",
"luaLibImport": "require",
}
}