AdslHouba

Agricraft culture 10/10/10 auto (1/2 ordi)

Dec 17th, 2015
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. -- Vidéo : https://youtu.be/bvMwtWKyIHg
  2.  
  3. local fermier1=101
  4. local fermier2=102
  5. local ordi=100
  6. local modem=peripheral.wrap("back")
  7.  
  8. function msgEtAttente(id,msg)
  9.     modem.transmit(id,ordi,msg)
  10.     pasok=true
  11.     while pasok do
  12.         local e, m, sc, rc, msg, sd = os.pullEvent("modem_message")
  13.         print(msg..' '..rc)
  14.         if msg=='ok' and rc == id then
  15.             pasok=false
  16.         end
  17.     end
  18. end
  19. modem.open(ordi)
  20.  
  21. local lecture=false
  22.  
  23. function boulot()
  24.     while true do
  25.         while lecture==false do
  26.             os.sleep(3)
  27.         end
  28.         msgEtAttente(fermier1,'premier')
  29.         while lecture do
  30.             msgEtAttente(fermier2,'recolte')
  31.             if lecture then msgEtAttente(fermier1,'recolte') end
  32.         end
  33.  
  34.         modem.transmit(fermier2,ordi,'fin')
  35.         modem.transmit(fermier1,ordi,'fin')
  36.     end
  37. end
  38. function ecoute()
  39.     while true do
  40.         local event = os.pullEvent("redstone")
  41.         print(rs.getInput("right"))
  42.         if rs.getInput("right") then
  43.             lecture=true
  44.         else
  45.             lecture=false
  46.         end
  47.     end
  48. end
  49. parallel.waitForAll(boulot,ecoute)
Add Comment
Please, Sign In to add comment