Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ClearPages()
- sleep(0.5)
- redstone.setBundledOutput("back",colors.combine(redstone.getBundledOutput("back"), colors.black))
- sleep(0.5)
- redstone.setBundledOutput("back",colors.subtract(redstone.getBundledOutput("back"), colors.black))
- sleep(2)
- end
- function ResetSignals()
- sleep(0.5)
- redstone.setBundledOutput("back",colors.subtract(redstone.getBundledOutput("back"), colors.orange))
- sleep(0.5)
- redstone.setBundledOutput("back",colors.combine(redstone.getBundledOutput("back"), colors.blue))
- end
- function RequestItems()
- -- CONSTANTS
- local PIPE_SIDE = "right"
- -- IMPLEMENTATION
- function convertNBT(nbt)
- local conv = {}
- if (nbt == nil) then
- return nil
- elseif (nbt["type"] == "NBTTagCompound") or (nbt["type"] == "NBTTagList") then
- for key, value in pairs(nbt["value"]) do
- conv[key] = convertNBT(value)
- end
- else
- conv = nbt["value"]
- end
- return conv
- end
- function getItems(pipe)
- pipe.getAvailableItems()
- local event, result = os.pullEvent("available_items_return")
- return result
- end
- function inList(item)
- local id = item.id
- local dmg = item.dmg
- local idKey = tostring(id)
- local exists, requestAmount = false, 0
- if REQUEST_IDS[id] then
- if type(REQUEST_IDS[id]) == "table" then
- local variantKey = idKey .. ":" .. tostring(dmg)
- if REQUEST_IDS[id][variantKey] then
- exists = true
- requestAmount = REQUEST_IDS[id][variantKey]
- end
- else
- exists = true
- requestAmount = REQUEST_IDS[id]
- end
- end
- return exists, requestAmount
- end
- -- MAIN
- local pipe = peripheral.wrap(PIPE_SIDE)
- for i, result in pairs(getItems(pipe)) do
- local iid, amount = unpack(result)
- local item = {
- id = pipe.getItemID(iid),
- dmg = pipe.getItemDamage(iid),
- nbt = convertNBT(pipe.getNBTTagCompound(iid))
- }
- local exists, requestAmount = inList(item)
- if exists then
- pipe.makeRequest(iid, requestAmount)
- sleep(sle)
- end
- end
- end
- ---------------------------------------------------------
- function RequestPage1()
- REQUEST_IDS = {
- [900] = {
- ["900:2"] = 16, --16x Controller
- ["900:6"] = 16, --16x Access Terminal
- ["900:5"] = 16, --16x Wireless Access Point
- ["900:7"] = 16, --16x ME Chest
- ["900:8"] = 16, --16x Interface
- ["900:1"] = 16, --16x Pattern Provider
- },
- }
- RequestItems()
- sleep(0.2)
- REQUEST_IDS = {
- [901] = {
- ["901:3"] = 16, --16x Crafting Terminal
- ["901:12"] = 16, --16x Storage Monitor
- ["901:11"] = 16, --16x Crafting Monitor
- ["901:10"] = 16, --16x IO Port
- ["901:6"] = 16, --16x Heat Vent
- ["901:7"] = 16, --16x Containment Wall
- ["901:5"] = 16, --16x Crafting CPU
- ["901:4"] = 16, --16x Level Emitter
- ["901:9"] = 16, --16x Storage Bus
- ["901:1"] = 16, --16x Import Bus
- ["901:0"] = 16, --16x Export Bus
- ["901:13"] = 16, --16x ME Cable
- },
- }
- RequestItems()
- sleep(0.2)
- REQUEST_IDS = {
- [900] = {
- ["900:0"] = 64, --64x ME Cable Blau
- ["900:10"] = 64, --64x ME Cable Schwarz
- ["900:11"] = 64, --64x ME Cable Weis
- ["900:12"] = 64, --64x ME Cable Braun
- ["900:13"] = 64, --64x ME Cable Rot
- ["900:14"] = 64, --64x ME Cable Gelb
- ["900:15"] = 64, --64x ME Cable GråBCn
- },
- }
- RequestItems()
- end
- ---------------------------------------------------------
- function RequestPage2()
- REQUEST_IDS = {
- [246] = {
- ["246:3"] = 60, --60x Solar Panel
- },
- }
- RequestItems()
- REQUEST_IDS = {
- [183] = {
- ["183:0"] = 60, --60x LV Solar Panel
- ["183:1"] = 60, --60x MV Solar Panel
- ["183:2"] = 60, --60x HV Solar Panel
- },
- }
- RequestItems()
- sleep(0.2)
- REQUEST_IDS = {
- [750] = {
- ["750:1280"] = 60, --60x Blue Alloy Wire
- ["750:1281"] = 60, --60x 10kV Wire
- ["750:16913"] = 60, --60x Jacketed Bluewire
- },
- }
- RequestItems()
- sleep(0.2)
- REQUEST_IDS = {
- [2050] = {
- ["2050:14"] = 32, --32x Lead Wire
- ["2050:15"] = 32, --32x Furnace Heater
- },
- }
- RequestItems()
- sleep(0.2)
- REQUEST_IDS = {
- [30184] = {
- ["30184:0"] = 60, --60x Copper Cable
- ["30184:4"] = 60, --60x 2x Ins. Gold Cable
- ["30184:9"] = 60, --60x Glass Fibre Cable
- },
- }
- RequestItems()
- REQUEST_IDS = {
- [227] = {
- ["227:0"] = 10, --10x Bat Box
- ["227:1"] = 10, --10x MFE
- ["227:2"] = 10, --10x MFSU
- ["227:3"] = 10, --10x LV Transformer
- ["227:4"] = 10, --10x MV Transformer
- ["227:5d"] = 10, --10x HV Transformer
- },
- }
- RequestItems()
- sleep(0.2)
- REQUEST_IDS = {
- [2006] = { ["2006:0"] = 32 }, --32x Redstone Energy Conduit
- [4320] = { ["4320:0"] = 32 }, --32x Wooden Conductice Pipe
- [4324] = { ["4324:0"] = 32 }, --32x Golden Conductice Pipe
- }
- RequestItems()
- end
- ---------------------------------------------------------
- function RequestPage3()
- REQUEST_IDS = {
- [207] = {
- ["207:0"] = 5, --5x Computer
- ["207:16384"] = 5, --5x Adv. Computer
- },
- }
- RequestItems()
- REQUEST_IDS = {
- [209] = { ["209:0"] = 5 }, --5x Turtle
- [900] = { ["900:5"] = 5 }, --5x Wireless Access Point
- [3893] = { ["3893:0"] = 5 }, --5x Sensor Peripheral
- [750] = { ["750:256"] = 5 }, --5x Red Alloy Wire
- }
- RequestItems()
- sleep(0.2)
- REQUEST_IDS = {
- [7742] = {
- ["7742:17"] = 2, --2x Proximity Sensor Card Mk1
- ["7742:33"] = 2, --2x Proximity Sensor Card Mk2
- ["7742:49"] = 2, --2x Proximity Sensor Card Mk3
- ["7742:65"] = 2, --2x Proximity Sensor Card Mk4
- ["7742:83"] = 2, --2x Applied Energystics Sensor Card Mk1
- ["7742:99"] = 2, --2x Applied Energystics Sensor Card Mk2
- ["7742:151"] = 2, --2x Applied Energystics Sensor Card Mk3
- ["7742:131"] = 2, --2x Applied Energystics Sensor Card Mk4
- },
- }
- RequestItems()
- end
- ---------------------------------------------------------
- function RequestPage4()
- sle = 0.2
- REQUEST_IDS = {
- [1] = { ["1:0"] = 192 }, --
- [2] = { ["2:0"] = 192 }, --
- [3] = { ["3:0"] = 192 }, --
- [13] = { ["13:0"] = 64 }, --
- [9] = { ["9:0"] = 64 }, --
- [11] = { ["11:0"] = 64 }, --
- [17] = { ["17:0"] = 64 }, --
- [24] = { ["24:0"] = 64 }, --
- [24] = { ["24:1"] = 64 }, --
- [128] = { ["128:0"] = 64 }, --
- [89] = { ["89:0"] = 64 }, --
- [85] = { ["85:0"] = 64 }, --
- [3133] = { ["3133:4"] = 192 }, --
- [45] = { ["45:0"] = 64 }, --
- [20] = { ["20:0"] = 64 }, --
- [80] = { ["80:0"] = 128 }, --
- [98] = { ["98:0"] = 128 }, --
- [98] = { ["98:3"] = 64 }, --
- [44] = { ["44:0"] = 64 }, --
- [44] = { ["44:1"] = 64 }, --
- [43] = { ["43:0"] = 64 }, --
- [43] = { ["43:7"] = 64 }, --
- }
- RequestItems()
- REQUEST_IDS = {
- [255] = { ["255:0"] = 64 }, --
- }
- RequestItems()
- REQUEST_IDS = {
- [255] = { ["255:1"] = 64 }, --
- }
- RequestItems()
- REQUEST_IDS = {
- [255] = { ["255:2"] = 64 }, --
- }
- RequestItems()
- REQUEST_IDS = {
- [255] = { ["255:6"] = 64 }, --
- }
- RequestItems()
- sleep(1)
- end
- ---------------------------------------------------------
- function RequestPage5()
- end
- function RequestPage6()
- end
- function RequestPage7()
- end
- function RequestPage8()
- end
- function RequestPage9()
- end
- ------------------------Program Start------------------------
- sle = 0.1 --Sleep zwischen jeder Request
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("bottom")
- redstone.setBundledOutput("back",colors.combine(redstone.getBundledOutput("back"), colors.orange)) --orange an
- sleep(0.5)
- redstone.setBundledOutput("back",colors.subtract(redstone.getBundledOutput("back"), colors.blue)) --blau aus
- while true do
- s = sen.getTargets()
- function getS()
- for v, k in pairs(s) do
- if k.Name == "ME Wireless Access Point" then
- target = v
- end
- end
- return target
- end
- f = getS()
- s1 = sen.getTargetDetails(target)
- local Page1 = 0
- local Page2 = 0
- local Page3 = 0
- local Page4 = 0
- local Page5 = 0
- local Page6 = 0
- local Page7 = 0
- local Page8 = 0
- local Page9 = 0
- for _, item in pairs(s1.Items) do
- --print(item.Name)
- --sleep(2)
- if item.Name == "ME Wireless Access Terminal" then
- Page1 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "Advanced Solar Panel" then
- Page2 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "Remote Orderer" then
- Page3 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "Cobblestone" then
- Page4 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "tile.machineBlock" then
- Page5 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "item.PipeItemsDiamond" then
- Page6 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "Electric Furnace" then
- Page7 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "Clay Dust" then
- Page8 = item.Size -- Werte ermittels und setzen
- end
- if item.Name == "Wooden Axe" then
- Page9 = item.Size -- Werte ermittels und setzen
- end
- if item.Size < 0 then
- os.reboot()
- end
- end
- term.setCursorPos(1,1)
- term.clear()
- print("1: "..Page1)
- print("2: "..Page2)
- print("3: "..Page3)
- print("4: "..Page4)
- print("5: "..Page5)
- print("6: "..Page6)
- print("7: "..Page7)
- print("8: "..Page8)
- print("9: "..Page9)
- reboot = 1
- if Page1 < 1 or Page2 < 1 or Page3 < 1 or Page4 < 1 then
- ResetSignals()
- ClearPages()
- reboot = 0
- end
- if Page1 < 1 then
- RequestPage1()
- elseif Page2 < 1 then
- RequestPage2()
- elseif Page3 < 1 then
- RequestPage3()
- elseif Page4 < 1 then
- RequestPage4()
- end
- if reboot == 0 then
- os.reboot()
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement