Compare commits
No commits in common. "logistics-pipe-driver" and "master" have entirely different histories.
logistics-
...
master
|
@ -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/master/test-programs/logistics-pipes"
|
repo = "tree/logistics-pipe-driver/test-programs/logistics-pipes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
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
|
|
|
@ -1,9 +0,0 @@
|
||||||
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
|
|
Loading…
Reference in New Issue