Compare commits
8
Commits
master
..
14bd08b16c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14bd08b16c | ||
|
|
90f537d6bf | ||
|
|
642135ca15 | ||
|
|
d2957509a9 | ||
|
|
2ff57086e2 | ||
|
|
9ac9294484 | ||
|
|
63c6e61489 | ||
|
|
5ba3e310d0 |
+1
-1
@@ -6,6 +6,6 @@
|
||||
name = "Logistics Pipes Test",
|
||||
description = "A program to test requesting items from a Logistics Pipes system",
|
||||
authors = "cody_code",
|
||||
repo = "tree/logistics-pipe-driver/test-programs/logistics-pipes"
|
||||
repo = "tree/master/test-programs/logistics-pipes"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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()
|
||||
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,8 @@
|
||||
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