Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("top")
- term.setCursorPos(1,1)
- term.clear()
- print("Neustart: System - Einrichtung")
- print(" ")
- print("Welche Seite wird erstellt: ")
- print("1-9 sind möglich")
- term.setTextColor(colors.red)
- Page = tonumber(read())
- term.setTextColor(colors.lightBlue)
- --------------------------------------------------
- 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(0.5)
- end
- end
- end
- --------------------------------------------------
- function gespeichert()
- term.setTextColor(colors.lime)
- print("gespeichert")
- term.setTextColor(colors.lightBlue)
- end
- if fs.exists("ItemsInPage1") == false then
- local file = fs.open("ItemsInPage1", "w")
- file.close()
- gespeichert()
- else
- print("Es wurden bereits Items für Seite 1 festgelegt!")
- print("Bestätige mit 'ja' um fortzufahren")
- Eingabe = io.read()
- if Eingabe == "Ja" or Eingabe == "ja" then
- local file = fs.open("ItemsInPage1", "w")
- file.close()
- gespeichert()
- else
- shell.run("1")
- end
- end
- 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)
- MaxItems = 0
- REQUEST_IDS = {
- [20] = { ["20:0"] = 32 },
- }
- RequestItems()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement