Advertisement
Roar337

keepstewcrafting

Mar 22nd, 2025 (edited)
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. local me = peripheral.find('meBridge')
  2. local toCraft = {name="avaritia:ultimate_stew", count=1}
  3.  
  4. local timeoutMinutes = 5
  5. local timeoutSeconds = 5 * 60
  6.  
  7. local timeOfLastSchedule = os.clock()
  8.  
  9. local longestCraftingCycle = 0
  10.  
  11. redstone.setOutput("top", false)
  12.  
  13. function clear( ... )
  14.     term.clear()
  15.     term.setCursorPos(1, 1)
  16. end
  17.  
  18. function craftIfNotCrafting( ... )
  19.     if not me.isItemCrafting(toCraft) then
  20.         me.craftItem(toCraft)
  21.         os.sleep(1)
  22.        
  23.         local elapsed = os.clock() - timeOfLastSchedule
  24.    
  25.         if me.isItemCrafting(toCraft) then
  26.             if elapsed > longestCraftingCycle then
  27.                 longestCraftingCycle = elapsed
  28.             end
  29.             timeOfLastSchedule = os.clock()
  30.         else
  31.             alarm("Failed to start crafting recipie please check system.")
  32.         end
  33.     end
  34.  
  35.     if os.clock() - timeOfLastSchedule > timeoutSeconds then
  36.         alarm("Crafting timed out please check system.")
  37.     end
  38. end
  39.  
  40. function alarm(err)
  41.     redstone.setOutput("top", true)
  42.     print("Error: " .. err)
  43.     print("")
  44.     print("Press enter to reboot.")
  45.     read()
  46.     os.reboot()
  47. end
  48.  
  49. function status( ... )
  50.     print("Current crafting cycle (seconds): " .. (os.clock() - timeOfLastSchedule))
  51.     print("Longest crafting cycle (seconds): " .. tostring(longestCraftingCycle))
  52. end
  53.  
  54. while true do
  55.     status()
  56.     craftIfNotCrafting()
  57.     os.sleep(2)
  58.     clear()
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement