Compare commits
15
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73dab0efac | ||
|
|
c40bdb5a09 | ||
|
|
9606e545e4 | ||
|
|
523696db16 | ||
|
|
cb19161ddd | ||
|
|
49833b2270 | ||
|
|
0f4fe2bb81 | ||
|
|
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,88 @@
|
||||
local component = require("component")
|
||||
|
||||
local driver = {}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
------------------------------- ItemStack Class -------------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local ItemStack = {}
|
||||
ItemStack.__index = ItemStack
|
||||
|
||||
local function ItemStack_new(item)
|
||||
checkArg(1, item, "table");
|
||||
local output = {
|
||||
data = item.getValue1(),
|
||||
quantity = item.getValue2()
|
||||
}
|
||||
setmetatable(output, ItemStack)
|
||||
return output
|
||||
end
|
||||
|
||||
function ItemStack:getName()
|
||||
--- check for custom name
|
||||
if self.data.hasTagCompound() then
|
||||
local nbt = self.data.getTagCompound()
|
||||
-- if Long arry is in the NBT complex logistic pipes fails to
|
||||
-- serialize the NBT resulting in a empty nbt
|
||||
if not nbt then
|
||||
return self.data.getName() .. " <NBT ERROR>"
|
||||
elseif nbt.value.display and nbt.value.display.value.Name then
|
||||
return nbt.value.display.value.Name.value
|
||||
end
|
||||
end
|
||||
return self.data.getName()
|
||||
end
|
||||
|
||||
function ItemStack:getId()
|
||||
if not self.data.hasTagCompound() then
|
||||
return self.data.getIdName() .. "." .. self.data.getData()
|
||||
end
|
||||
return "complex"
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
----------------------------- ItemCollection Class -----------------------------
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local ItemCollection = {}
|
||||
ItemCollection.__index = ItemCollection
|
||||
|
||||
local function ItemCollection_new(items)
|
||||
checkArg(1, items, "table");
|
||||
local output = {}
|
||||
output.searchTable = {}
|
||||
for i,item in pairs(items) do
|
||||
local itemStack = ItemStack_new(item)
|
||||
output[i] = itemStack
|
||||
output.searchTable[itemStack:getName()] = i
|
||||
end
|
||||
setmetatable(output, ItemCollection);
|
||||
return output
|
||||
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
|
||||
return ItemCollection_new(pipe.getAvailableItems())
|
||||
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