Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- local function split(str, delimeter)
- local parts = {}
- local current = ""
- if str ~= nil then
- for i=1, #str do
- local c = string.sub(str, i, i)
- if c == delimeter and #current ~= 0 then
- table.insert(parts, current)
- current = ""
- else
- current = current .. c
- end
- end
- end
- if #current ~= 0 then
- table.insert(parts, current)
- end
- return parts
- end
- local function contains(list, value)
- for k,v in ipairs(list) do
- if v == value then
- return true
- end
- end
- return false
- end
- local function shouldSmelt(list, ignoreList)
- local output = false
- for k1, name in ipairs(list) do
- if name == "raw" or name == "ore" then
- output = true
- end
- if contains(ignoreList, name) then
- return false
- end
- end
- return output
- end
- local function getSide(splitName, sideA, sideB)
- if contains(splitName, "block") then
- return sideA
- else
- return sideB
- end
- end
- if #args < 3 then
- term.setTextColor(colors.red)
- term.write("Usage: rsOreDepositor <rs bridge side> <single raw item output side> <raw block output side>")
- term.setTextColor(colors.white)
- else
- local ignoreList = {}
- if fs.exists("ignoreList.txt") then
- local file = fs.open("ignoreList.txt", "r")
- while true do
- local line = file.readLine()
- if line == nil then
- break
- else
- table.insert(ignoreList, line)
- end
- end
- file.close()
- end
- local rsBridge = peripheral.wrap(args[1])
- while true do
- local items = rsBridge.listItems()
- for k,v in ipairs(items) do
- local split1 = split(v.name, ':')
- local split2 = split(split1[2], "_")
- local shouldSmelt = shouldSmelt(split2, ignoreList)
- if shouldSmelt then
- local side = getSide(split2, args[3], args[2])
- local amount = v.amount
- while amount > 0 do
- local nextAmount = math.min(64, amount)
- rsBridge.exportItem({name=v.name,amount=nextAmount}, side)
- amount = amount - nextAmount
- end
- end
- end
- sleep(10)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement