@siredvin/hopper-ts 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +120 -0
  2. package/index.lua +11 -0
  3. package/package.json +39 -0
package/index.d.ts ADDED
@@ -0,0 +1,120 @@
1
+ /** @noSelfInFile **/
2
+
3
+ declare class HopperTransferRecord {
4
+ commandName?: string;
5
+ transferred: number;
6
+ from: string;
7
+ to: string;
8
+ name: string;
9
+ displayName?: string;
10
+ nbt?: string;
11
+ type: "i" | "f" | "e";
12
+ }
13
+
14
+ declare interface HopperOptions {
15
+ name: string;
16
+ }
17
+
18
+ declare interface HopperCommand {
19
+ options: HopperOptions;
20
+ }
21
+
22
+ declare interface HopperCommandFinishedInfo {
23
+ command: HopperCommand;
24
+ execution_time: number;
25
+ }
26
+
27
+ declare interface HopperTimeInfo {
28
+ look: number;
29
+ reset_limits: number;
30
+ scan: number;
31
+ mark: number;
32
+ sort: number;
33
+ transfer: number;
34
+ }
35
+
36
+ /** @noSelf **/
37
+ declare class Callbacks {
38
+ transferred?: (record: HopperTransferRecord) => void;
39
+ command_finished?: (command: HopperCommandFinishedInfo) => void;
40
+ time_tracking?: (info: {
41
+ name: string;
42
+ times: LuaTable<string, number>;
43
+ }) => void;
44
+ }
45
+
46
+ declare interface HopperTagFilter {
47
+ tag: string;
48
+ }
49
+
50
+ declare interface HopperItemFilter {
51
+ name: string;
52
+ }
53
+
54
+ declare interface HopperFilterInformation {
55
+ chest_name: string;
56
+ chest_size: number | null; // output of .size() if such a method exists
57
+ slot_number: number; // 0 if there's none
58
+ name: string;
59
+ nbt: string; // "" if there's no nbt data or if the data is unknown and assumed to be none
60
+ count: number;
61
+ type: "i" | "f" | "e"; // item, fluid, energy
62
+ tags: { [tag: string]: true }; // result of getItemDetail(...).tags
63
+ }
64
+
65
+ declare type HopperFilterFunction = (info: HopperFilterInformation) => boolean;
66
+
67
+ export type HopperFilter =
68
+ | string
69
+ | HopperItemFilter
70
+ | HopperTagFilter
71
+ | HopperFilterFunction;
72
+
73
+ declare interface HopperLimit {
74
+ type: "from" | "to" | "transfer";
75
+ dir?: "max" | "min";
76
+ limit: number;
77
+ per_chest?: boolean;
78
+ per_item?: boolean;
79
+ per_nbt?: boolean;
80
+ per_slot?: boolean;
81
+ count_all?: boolean;
82
+ }
83
+
84
+ declare interface HopperSlotInfo {
85
+ from_priority: number;
86
+ count: number;
87
+ voided?: number;
88
+ chest_name: string;
89
+ slot_number: number;
90
+ name: string;
91
+ }
92
+
93
+ declare interface HopperTableInstruction {
94
+ name?: string;
95
+ from: string;
96
+ to: string;
97
+ filters?: HopperFilter[];
98
+ limits?: HopperLimit[];
99
+ once?: boolean;
100
+ forever?: boolean;
101
+ from_slot?: number | number[] | number[][];
102
+ to_slot?: number | number[] | number[][];
103
+ min_batch?: number;
104
+ batch_multiple?: number;
105
+ sleep?: number;
106
+ scan_threads?: number;
107
+ negate?: boolean;
108
+ energy?: boolean;
109
+ condition?: () => boolean;
110
+ from_sorting?: (a: HopperSlotInfo, b: HopperSlotInfo) => boolean;
111
+ }
112
+
113
+ export type HopperInstruction = string | HopperTableInstruction;
114
+
115
+ export function hopper(
116
+ instruction: HopperInstruction | HopperInstruction[],
117
+ callbacks?: Callbacks
118
+ ): number;
119
+ export function alias(alias: string, name: string);
120
+ export function list(filter: string): LuaTable<string, number>;
package/index.lua ADDED
@@ -0,0 +1,11 @@
1
+ package.path = package.path .. ";/?.lua;/?/init.lua"
2
+
3
+ local tweaked_require = require
4
+
5
+ local hopper = tweaked_require("hopper")
6
+
7
+ return {
8
+ hopper = hopper,
9
+ list = hopper.list,
10
+ alias = function(a, b) hopper("-alias " .. a .. " " .. b) end
11
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@siredvin/hopper-ts",
3
+ "version": "0.1.0",
4
+ "description": "Redistribution of Hopper.lua by umnikos",
5
+ "types": "./index.d.ts",
6
+ "files": [
7
+ "./index.d.ts",
8
+ "./index.lua"
9
+ ],
10
+ "main": "index",
11
+ "author": "umnikos",
12
+ "license": "MIT",
13
+ "scripts": {
14
+ "lint": "eslint . --ext .ts,.js",
15
+ "depcheck": "depcheck"
16
+ },
17
+ "nx": {
18
+ "targets": {
19
+ "lint": {
20
+ "executor": "@nx/linter:eslint",
21
+ "outputs": [
22
+ "{options.outputFile}"
23
+ ],
24
+ "options": {
25
+ "lintFilePatterns": [
26
+ "packages/api-types/**/*.{ts,tsx,js,jsx}"
27
+ ]
28
+ }
29
+ },
30
+ "depcheck": {
31
+ "executor": "nx:run-commands",
32
+ "options": {
33
+ "command": "depcheck",
34
+ "cwd": "packages/api-types"
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }