:33333 uwu

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

4
package-lock.json generated
View File

@ -8,6 +8,9 @@
"name": "keypados",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@typescript-to-lua/language-extensions": "^1.19.0"
},
"devDependencies": {
"typescript": "^5.5.2",
"typescript-to-lua": "^1.26.2"
@ -17,7 +20,6 @@
"version": "1.19.0",
"resolved": "https://registry.npmjs.org/@typescript-to-lua/language-extensions/-/language-extensions-1.19.0.tgz",
"integrity": "sha512-Os5wOKwviTD4LeqI29N0btYOjokSJ97iCf45EOjIABlb5IwNQy7AE/AqZJobRw3ywHH8+KzJUMkEirWPzh2tUA==",
"dev": true,
"license": "MIT"
},
"node_modules/enhanced-resolve": {

View File

@ -11,5 +11,7 @@
"devDependencies": {
"typescript": "^5.5.2",
"typescript-to-lua": "^1.26.2"
},
"dependencies": {
}
}

View File

@ -22,13 +22,45 @@ local function require(file, ...)
end
end
____modules = {
["lualib_bundle"] = function(...)
local function __TS__Class(self)
local c = {prototype = {}}
c.prototype.__index = c.prototype
c.prototype.constructor = c
return c
end
return {
__TS__Class = __TS__Class
}
end,
["src.computercraft"] = function(...)
local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local ____exports = {}
____exports.Peripheral = __TS__Class()
local Peripheral = ____exports.Peripheral
Peripheral.name = "Peripheral"
function Peripheral.prototype.____constructor(self)
end
function Peripheral.find(self, ty, filter)
return peripheral.find(ty, filter)
end
function Peripheral.findOne(self, ty, filter)
local p, _a, _b, _c = table.unpack(____exports.Peripheral:find(ty, filter))
return p
end
return ____exports
end,
["src.index"] = function(...)
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
local ____exports = {}
local ____basalt = require("src.basalt")
local basalt = ____basalt.default
local ____computercraft = require("src.computercraft")
local Peripheral = ____computercraft.Peripheral
local function main(self)
local d = peripheral.find("monitor")[1]
local d = table.unpack(Peripheral:findOne("monitor"))
local main = basalt.addMonitor()
main:setMonitor(d)
main:addLabel():setText("uwu")

15
src/computercraft.ts Normal file
View File

@ -0,0 +1,15 @@
export class Peripheral {
static find<T extends Peripheral>(ty: string,
filter?: (name: string, wrapped: Peripheral) => boolean
): [T, T|null, T|null, T|null] {
return peripheral.find(ty, filter);
}
static findOne<T extends Peripheral>(ty: string,
filter?: (name: string, wrapped: Peripheral) => boolean
): T {
const [p, _a, _b, _c] = Peripheral.find(ty, filter);
return p as T;
}
}

View File

@ -1,9 +1,10 @@
import basalt from "basalt";
import {Peripheral } from "./computercraft";
function main() {
const d: Monitor = peripheral.find("monitor")[0] as Monitor;
const [d]: [Monitor] = Peripheral.findOne("monitor");
const main = basalt.addMonitor();
main.setMonitor(d);

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

@ -125,7 +125,7 @@ declare namespace peripheral {
function call(name: string, method: string, ...arguments: unknown[]): unknown;
function wrap<T extends Peripheral>(name: string): T | null;
/** @tupleReturn */
function find<T extends Peripheral>(ty: string,
filter?: (name: string, wrapped: Peripheral) => boolean
): [T, T|null, T|null, T|null];

View File

@ -5,7 +5,6 @@
"lib": ["ESNext"],
"moduleResolution": "NodeNext",
"module": "NodeNext",
"types": [],
"typeRoots": [
"./src/types"
],