This commit is contained in:
Gvidas Juknevičius 2024-08-23 13:09:03 +03:00
parent 9b89185c2a
commit 5fe85f414b
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
3 changed files with 8 additions and 6 deletions

View File

@ -38,16 +38,18 @@ return {
local ____lualib = require("lualib_bundle") local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class local __TS__Class = ____lualib.__TS__Class
local ____exports = {} local ____exports = {}
---
-- @noSelf *
____exports.Peripheral = __TS__Class() ____exports.Peripheral = __TS__Class()
local Peripheral = ____exports.Peripheral local Peripheral = ____exports.Peripheral
Peripheral.name = "Peripheral" Peripheral.name = "Peripheral"
function Peripheral.prototype.____constructor(self) function Peripheral.prototype.____constructor(self)
end end
function Peripheral.find(self, ty, filter) function Peripheral.find(ty, filter)
return peripheral.find(ty, filter) return peripheral.find(ty, filter)
end end
function Peripheral.findOne(self, ty, filter) function Peripheral.findOne(ty, filter)
local p, _a, _b, _c = table.unpack(____exports.Peripheral:find(ty, filter)) local p, _a, _b, _c = table.unpack(____exports.Peripheral.find(ty, filter))
return p return p
end end
return ____exports return ____exports
@ -60,7 +62,7 @@ local basalt = ____basalt.default
local ____computercraft = require("src.computercraft") local ____computercraft = require("src.computercraft")
local Peripheral = ____computercraft.Peripheral local Peripheral = ____computercraft.Peripheral
local function main(self) local function main(self)
local d = table.unpack(Peripheral:findOne("monitor")) local d = Peripheral.findOne("monitor")
local main = basalt.addMonitor() local main = basalt.addMonitor()
main:setMonitor(d) main:setMonitor(d)
main:addLabel():setText("uwu") main:addLabel():setText("uwu")

View File

@ -1,4 +1,5 @@
/** @noSelf **/
export class Peripheral { export class Peripheral {
static find<T extends Peripheral>(ty: string, static find<T extends Peripheral>(ty: string,
filter?: (name: string, wrapped: Peripheral) => boolean filter?: (name: string, wrapped: Peripheral) => boolean

View File

@ -3,8 +3,7 @@ import {Peripheral } from "./computercraft";
function main() { function main() {
const [d]: [Monitor] = Peripheral.findOne("monitor"); const d: Monitor = Peripheral.findOne("monitor");
const main = basalt.addMonitor(); const main = basalt.addMonitor();
main.setMonitor(d); main.setMonitor(d);