Advertisement
hohserg

button_crafter.lua

Dec 27th, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. local sides = {
  2.   forward = 3
  3. }
  4.  
  5. local function primary(name)
  6.     return component.proxy(component.list(name)())
  7. end
  8.  
  9. local crafting=primary("crafting")
  10. local eeprom=primary("eeprom")
  11. local robot=primary("robot")
  12. local inv=primary("inventory_controller")
  13. local modem=primary("modem")
  14.  
  15. modem.open(111)
  16.  
  17. local crafting_time=0.05
  18. local offset=0.25
  19.  
  20. local slot=tonumber(eeprom.getLabel())
  21. local side=sides.forward
  22.  
  23. do
  24.     local start=false
  25.     while not start do
  26.         local eventName = computer.pullSignal()
  27.         start = eventName=="modem_message"
  28.     end
  29. end
  30.  
  31. function sleep(timeout)
  32.   local deadline = computer.uptime() + (timeout or 0)
  33.   repeat
  34.     computer.pullSignal(deadline - computer.uptime())
  35.   until computer.uptime() >= deadline
  36. end
  37.  
  38. sleep(1+offset)
  39.  
  40. robot.select(4)
  41. while true do
  42.     crafting.craft(64)
  43.     inv.dropIntoSlot(sides.forward, slot, 64)
  44.     sleep(0.5-crafting_time)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement