Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get wngsBEP2 StorageManager
- TCE = require("TCE")
- SM = {}
- local function varInList(var, list)
- for _, v1 in ipairs(list) do
- if var == v1 then return true end
- end
- return false
- end
- local function existsOutgoingTask()
- local taskOut = SDM.getOutgoingTasks()
- if taskOut and #textutils.serialize(taskOut) > 2 then
- return true
- end
- return false
- end
- function SM.moveOutgoingToFinished()
- local taskList = SDM.getOutgoingTasks()
- local task = table.remove(taskList, 1)
- SDM.setOutgoingTasks(taskList)
- if task then
- SDM.setFinishedTask(task)
- end
- end
- function SM.main()
- local creatorLists = {TCE.createFromRequest, TCE.createFromIncoming, TCE.createChest, TCE.createChestCheck}
- local needChestsCreators = {TCE.createFromIncoming}
- local cnt = 1
- local cntSleep = 0
- while true do
- if FM.getEmptyDiskAmount() >= 2 and not existsOutgoingTask() then
- local taskCreator = creatorLists[cnt]
- if not SDM.chestAvailable() then
- while varInList(taskCreator, {needChestsCreators}) do
- cnt = cnt % #createFunctions + 1
- taskCreator = creatorLists[cnt]
- end
- end
- if not taskCreator() then
- cntSleep = cntSleep + 1
- end
- cnt = cnt % #creatorLists + 1
- end
- TCE.evaluateTasks()
- if cntSleep == #creatorLists then
- sleep(0.5)
- cntSleep = 0
- end
- sleep(0.3)
- end
- end
- return SM
Advertisement
Add Comment
Please, Sign In to add comment