Skip to content

Commit 5783379

Browse files
author
Exeteres
committed
Merge branch 'master' of https://github.com/Exeteres/opc-types
2 parents bac6de9 + 62ef937 commit 5783379

File tree

6 files changed

+231
-26
lines changed

6 files changed

+231
-26
lines changed

README.ru.md

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,19 @@ yarn add typescript-to-lua
4242
```json
4343
// tsconfig.json
4444
{
45-
"compilerOptions": {
46-
"target": "esnext",
47-
"outDir": "dist",
48-
"module": "commonjs",
49-
"lib": ["esnext"],
50-
"strict": true,
51-
"moduleResolution": "node",
52-
"rootDir": "src",
53-
"types": [
54-
"lua-types/jit",
55-
"@opct/openos",
56-
"@opct/gui",
57-
"@opct/mineos"
58-
]
59-
},
60-
"tstl": {
61-
"luaTarget": "JIT"
62-
}
45+
"compilerOptions": {
46+
"target": "esnext",
47+
"outDir": "dist",
48+
"module": "commonjs",
49+
"lib": ["esnext"],
50+
"strict": true,
51+
"moduleResolution": "node",
52+
"rootDir": "src",
53+
"types": ["lua-types/jit", "@opct/openos", "@opct/gui", "@opct/mineos"]
54+
},
55+
"tstl": {
56+
"luaTarget": "JIT"
57+
}
6358
}
6459
```
6560

@@ -69,14 +64,14 @@ yarn add typescript-to-lua
6964
- Вместо реального мода можно использовать эмулятор. Иначе необходимо установить `filesystem.bufferChanges` на `false`, чтобы иметь внешний доступ к диску.
7065
- Создайте ссылку на диск, чтобы хранить исходный код отдельно от него:
7166

72-
```shell
73-
# linux / macos
74-
ln -s /path/to/disk/home/app dist
75-
```
67+
```shell
68+
# linux / macos
69+
ln -s /path/to/disk/home/app dist
70+
```
7671

77-
```cmd
78-
# windows (cmd)
79-
mklink /j dist C:\path\to\disk\home
80-
```
72+
```cmd
73+
# windows (cmd)
74+
mklink /j dist C:\path\to\disk\home
75+
```
8176

8277
- Используйте `tstl --watch`

examples/ae2.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import * as component from "component";
2+
3+
const { me_controller } = component;
4+
me_controller.store();

packages/ae2/ME.d.ts

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
/**
2+
* This library wraps functionality of Applied Energistics 2.
3+
* @see https://ocdoc.cil.li/component:applied_energistics
4+
* @noSelfInFile
5+
*/
6+
declare namespace ME {
7+
/**
8+
* Common is the base network API functionality for all AE2 interfaces.
9+
* @noSelf
10+
*/
11+
interface Common {
12+
/**
13+
* Get a list of tables representing the available CPUs in the network.
14+
*/
15+
getCpus(): Cpu[];
16+
17+
/**
18+
* Get a list of known item recipes. These can be used to issue crafting requests..
19+
*/
20+
getCraftables(filter?: any): Craftable[];
21+
22+
/**
23+
* Get a list of the stored items in the network.
24+
*/
25+
getItemsInNetwork(filter?: ItemStack): ItemStack[];
26+
27+
/**
28+
* Store items in the network matching the specified filter in the database with the specified address.
29+
*/
30+
store(filter?: any, dbAddress?: string, startSlot?: number, count?: number): boolean;
31+
32+
/**
33+
* Get a list of the stored fluids in the network.
34+
*/
35+
getFluidsInNetwork(): Fluid[];
36+
37+
/**
38+
* Get the average power injection into the network.
39+
*/
40+
getAvgPowerInjection(): number;
41+
42+
/**
43+
* Get the average power usage of the network.
44+
*/
45+
getAvgPowerUsage(): number;
46+
47+
/**
48+
* Get the idle power usage of the network.
49+
*/
50+
getIdlePowerUsage(): number;
51+
52+
/**
53+
* Get the maximum stored power in the network.
54+
*/
55+
getMaxStoredPower(): number;
56+
57+
/**
58+
* Get the stored power in the network.
59+
*/
60+
getStoredPower(): number;
61+
}
62+
63+
/**
64+
* Controller interface for the AE2 controller. Referred as "me_controller" in ocdocs
65+
* @noSelf
66+
*/
67+
interface Controller extends Common {
68+
/**
69+
* Returns the amount of stored energy on the connected side.
70+
*/
71+
getEnergyStored(): number;
72+
73+
/**
74+
* Returns the maximum amount of stored energy on the connected side.
75+
*/
76+
getMaxEnergyStored(): number;
77+
78+
/**
79+
* Returns whether this component can have energy extracted from the connected side.
80+
*/
81+
canExtract(): number;
82+
83+
/**
84+
* Returns whether this component can receive energy on the connected side.
85+
*/
86+
canReceive(): number;
87+
}
88+
89+
/**
90+
* Interface interface for the AE2 interface blocks. Referred as "me_interface" in ocdocs
91+
* @noSelf
92+
*/
93+
interface Interface extends Common {
94+
/**
95+
* Get the configuration of the interface.
96+
*/
97+
getInterfaceConfiguration(slot?: number): ItemStack[];
98+
99+
/**
100+
* Configure the interface.
101+
*/
102+
setInterfaceConfiguration(slot?: number, database?: string, entry?: number, size?: number): boolean;
103+
}
104+
105+
/**
106+
* ImportBus interface for the AE2 Importbus blocks. Referred as "me_importbus" in ocdocs
107+
* @noSelf
108+
*/
109+
interface ImportBus extends Common {
110+
/**
111+
* Get the configuration of the import bus pointing in the specified direction.
112+
*/
113+
getImportConfiguration(side: number, slot?: number): boolean;
114+
115+
/**
116+
* Configure the import bus pointing in the specified direction to import item stacks matching the specified descriptor.
117+
*/
118+
setImportConfiguration(side: number, slot?: number, database?: string, entry?: number): boolean;
119+
}
120+
121+
/**
122+
* ExportBus interface for the AE2 Exportbus blocks. Referred as "me_exportbus" in ocdocs
123+
* @noSelf
124+
*/
125+
interface ExportBus extends Common {
126+
/**
127+
* Get the configuration of the export bus pointing in the specified direction.
128+
*/
129+
getExportConfiguration(side: number, slot?: number): boolean;
130+
131+
/**
132+
* Configure the export bus pointing in the specified direction to export item stacks matching the specified descriptor.
133+
*/
134+
setExportConfiguration(side: number, slot?: number, database?: string, entry?: number): boolean;
135+
136+
/**
137+
* Make the export bus facing the specified direction perform a single export operation into the specified slot.
138+
*/
139+
exportIntoSlot(side: number, slot: number): boolean;
140+
}
141+
142+
/**
143+
* @noSelf
144+
*/
145+
interface Craftable {
146+
/**
147+
* Returns the item stack representation of the crafting result.
148+
*/
149+
getItemStack(): ItemStack;
150+
151+
/**
152+
* Requests the item to be crafted, returning an object that allows tracking the crafting status.
153+
*/
154+
request(amount: number, prioritizePower?: boolean, cpuName?: string): CraftingStatus;
155+
}
156+
157+
/**
158+
* @noSelf
159+
*/
160+
interface CraftingStatus {
161+
/**
162+
* Get whether the crafting request has been canceled.
163+
*/
164+
isCanceled(): boolean;
165+
166+
/**
167+
* Get whether the crafting request is done.
168+
*/
169+
isDone(): boolean;
170+
}
171+
172+
interface ItemStack {
173+
damage?: number;
174+
hasTag?: boolean;
175+
isCraftable?: boolean;
176+
label?: string;
177+
maxDamage?: number;
178+
maxSize?: number;
179+
name?: string;
180+
size?: number;
181+
}
182+
183+
interface Fluid {
184+
amount?: number;
185+
hasTag?: boolean;
186+
label?: string;
187+
name?: string;
188+
}
189+
190+
interface Cpu {
191+
busy?: boolean;
192+
coprocessors?: number;
193+
name?: string;
194+
storage?: number;
195+
}
196+
}

packages/ae2/component_map.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare namespace OC {
2+
interface ComponentMap {
3+
me_controller: ME.Controller;
4+
me_interface: ME.Interface;
5+
me_importbus: ME.ImportBus;
6+
me_exportbus: ME.ExportBus;
7+
}
8+
}

packages/ae2/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import "./ME";
2+
import "./component_map";

0 commit comments

Comments
 (0)