Compare commits
10
Commits
master
..
49833b2270
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49833b2270 | ||
|
|
0f4fe2bb81 | ||
|
|
14bd08b16c | ||
|
|
90f537d6bf | ||
|
|
642135ca15 | ||
|
|
d2957509a9 | ||
|
|
2ff57086e2 | ||
|
|
9ac9294484 | ||
|
|
63c6e61489 | ||
|
|
5ba3e310d0 |
+1
-1
@@ -6,6 +6,6 @@
|
|||||||
name = "Logistics Pipes Test",
|
name = "Logistics Pipes Test",
|
||||||
description = "A program to test requesting items from a Logistics Pipes system",
|
description = "A program to test requesting items from a Logistics Pipes system",
|
||||||
authors = "cody_code",
|
authors = "cody_code",
|
||||||
repo = "tree/logistics-pipe-driver/test-programs/logistics-pipes"
|
repo = "tree/master/test-programs/logistics-pipes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
local component = require("component")
|
||||||
|
|
||||||
|
local driver = {}
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
---------------------------------- Item Class ----------------------------------
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local ItemStack = {}
|
||||||
|
ItemStack.__index = ItemStack
|
||||||
|
|
||||||
|
local function ItemStack_new(item)
|
||||||
|
checkArg(1, item, "table");
|
||||||
|
local out = {
|
||||||
|
data = item.getValue1(),
|
||||||
|
quantity = item.getValue2()
|
||||||
|
}
|
||||||
|
setmetatable(out, ItemStack)
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
function ItemStack:getName()
|
||||||
|
--- check for custom name
|
||||||
|
if self.data.hasTagCompount() then
|
||||||
|
local nbt = self.data.getTagCompount()
|
||||||
|
if nbt.value.display and nbt.value.display.value.Name then
|
||||||
|
return nbt.value.display.value.Name.value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self.data.getName()
|
||||||
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-------------------------------- Private Driver --------------------------------
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
driver.internal = {}
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
-------------------------------- Public Driver --------------------------------
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function driver.getItems()
|
||||||
|
if not component.isAvailable("logisticspipe") then
|
||||||
|
error("no logistics pipe available", 2)
|
||||||
|
end
|
||||||
|
local pipe = component.logisticspipe.getPipe()
|
||||||
|
if not pipe.getAvailableItems and not pipe.makeRequest then
|
||||||
|
error("Logistics pipe is not a a requesting pipe")
|
||||||
|
end
|
||||||
|
local output = {}
|
||||||
|
for _,item in pairs(pipe.getAvailableItems()) do
|
||||||
|
table.insert(output, ItemStack_new(item))
|
||||||
|
end
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
return driver
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
local component = require("component")
|
||||||
|
local pipe = component.logisticspipe.getPipe()
|
||||||
|
local items = pipe.getAvailableItems()
|
||||||
|
print("Requesting all items I can find... this might take up a lot of storage space!")
|
||||||
|
for _,item in pairs(items) do
|
||||||
|
local itemStack = item.getValue1()
|
||||||
|
print("Requesting :" .. item.getValue2() .. " of " .. itemStack.getName() .. " from mod " .. itemStack.getModName())
|
||||||
|
pipe.makeRequest(itemStack, item.getValue2() + .0)
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user