Advertisement
AssortedBrunoz

yragrahgargh

Sep 21st, 2024 (edited)
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. local vault = peripheral.wrap("left")
  2. local depot = peripheral.wrap("right")
  3. local debounce = 1.5
  4. depot = peripheral.getName(depot)
  5.  
  6. local last_heat = os.time(os.date("!*t"))
  7. local cooldown = 0
  8. local last_press = os.time(os.date("!*t"))
  9. local state = 0
  10.  
  11. local function find_item(str)
  12.     for index, pack in pairs(vault.list()) do
  13.         if string.find(pack.name, str) then
  14.             return index
  15.         end
  16.     end
  17. end
  18.  
  19. local function feed_coal()
  20.     vault.pushItems(depot, find_item("coal"),1)
  21. end
  22.  
  23. local function feed_blaze()
  24.     vault.pushItems(depot, find_item("blaze_cake"),1)
  25. end
  26.  
  27. local function check()
  28.     if os.time(os.date("!*t")) < last_press + debounce then
  29.         return
  30.     end
  31.    
  32.     last_press = os.time(os.date("!*t"))
  33.  
  34.     if state == 0 then
  35.         feed_coal()
  36.         last_heat = os.time(os.date("!*t"))
  37.         cooldown = 80
  38.         state = 1
  39.     elseif state == 1 then
  40.         if os.time(os.date("!*t")) >= last_heat + cooldown then
  41.             state = 0
  42.             check()
  43.         else
  44.             feed_blaze()
  45.             state = 2
  46.             cooldown = 160
  47.             last_heat = os.time(os.date("!*t"))
  48.         end
  49.     elseif state == 2 then
  50.         if os.time(os.date("!*t")) >= last_heat + cooldown then
  51.             state = 1
  52.             last_heat = os.time(os.date("!*t"))
  53.         end
  54.     end
  55. end
  56.  
  57. while true do
  58.  
  59.     os.pullEvent("redstone")
  60.    
  61.     check()
  62.    
  63. end
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement