forked from Niels1006/Level-Maintainer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAE2.lua
More file actions
59 lines (51 loc) · 1.5 KB
/
Copy pathAE2.lua
File metadata and controls
59 lines (51 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
local component = require("component")
local ME = component.me_interface
local AE2 = {}
local inCraft = {}
function AE2.requestItem(name, threshold, count)
craftables = ME.getCraftables({
["label"] = name
})
if #craftables >= 1 then
item = craftables[1].getItemStack()
if threshold ~= nil then
itemInSystem = ME.getItemsInNetwork({
["label"] = name
})
if (#itemInSystem > 0 and itemInSystem[1]["size"] > threshold) then
return
end
end
if item.label == name then
if item.size > count then
count = item.size
end
local craft = craftables[1].request(count)
while craft.isComputing() == true do
os.sleep(1)
end
if craft.hasFailed() then
print("Failed to request " .. name .. " x " .. count)
return
else
inCraft[name] = craft
print("Requested " .. name .. " x " .. count)
return
end
end
end
return table.unpack({false, name .. " is not craftable!"})
end
function AE2.checkIfCrafting()
for name, craft in pairs(inCraft) do
if craft.isDone() then
print(name, "is Done!")
inCraft[name] = nil
elseif craft.isCanceled() then
print(name, "is Canceled!")
inCraft[name] = nil
end
end
return inCraft
end
return AE2