Compare commits

8 Commits
Author SHA1 Message Date
cody 14bd08b16c Add missing __index 2023-03-21 00:38:25 -05:00
cody 90f537d6bf Stop using metatable it doesn't work 2023-03-21 00:22:47 -05:00
cody 642135ca15 Correct error 2023-03-21 00:06:01 -05:00
cody d2957509a9 Add debug methods 2023-03-21 00:03:57 -05:00
cody 2ff57086e2 Add pipe_driver 2023-03-21 00:01:59 -05:00
cody 9ac9294484 Add debug statement 2023-03-20 23:03:30 -05:00
cody 63c6e61489 Add programs.cfg 2023-03-20 21:24:27 -05:00
cody 5ba3e310d0 Add logistics pipes test 2023-03-20 20:42:52 -05:00
3 changed files with 61 additions and 1 deletions
+1 -1
View File
@@ -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,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