Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local me = peripheral.find('meBridge')
- local toCraft = {name="avaritia:ultimate_stew", count=1}
- local timeoutMinutes = 5
- local timeoutSeconds = 5 * 60
- local timeOfLastSchedule = os.clock()
- local longestCraftingCycle = 0
- redstone.setOutput("top", false)
- function clear( ... )
- term.clear()
- term.setCursorPos(1, 1)
- end
- function craftIfNotCrafting( ... )
- if not me.isItemCrafting(toCraft) then
- me.craftItem(toCraft)
- os.sleep(1)
- local elapsed = os.clock() - timeOfLastSchedule
- if me.isItemCrafting(toCraft) then
- if elapsed > longestCraftingCycle then
- longestCraftingCycle = elapsed
- end
- timeOfLastSchedule = os.clock()
- else
- alarm("Failed to start crafting recipie please check system.")
- end
- end
- if os.clock() - timeOfLastSchedule > timeoutSeconds then
- alarm("Crafting timed out please check system.")
- end
- end
- function alarm(err)
- redstone.setOutput("top", true)
- print("Error: " .. err)
- print("")
- print("Press enter to reboot.")
- read()
- os.reboot()
- end
- function status( ... )
- print("Current crafting cycle (seconds): " .. (os.clock() - timeOfLastSchedule))
- print("Longest crafting cycle (seconds): " .. tostring(longestCraftingCycle))
- end
- while true do
- status()
- craftIfNotCrafting()
- os.sleep(2)
- clear()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement