Advertisement
Darking560

Postier

Oct 12th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. local modem = peripheral.wrap("right")
  2. local S1 = 1
  3. local S5 = 2
  4. local Slettre = 3
  5. local Sdrop = 16
  6. local rs = "left"
  7.  
  8. function drop(slot, nb)
  9.     turtle.select(slot)
  10.     turtle.transferTo(Sdrop,nb)
  11.     turtle.select(Sdrop)
  12.     turtle.drop()
  13. end
  14.  
  15. modem.open(512)
  16.  
  17. while true do
  18.  
  19. local event, modemSide, senderChannel, replyChannel, timbres, senderDistance = os.pullEvent("modem_message")
  20. --timbres = read()
  21. timbres = tonumber(timbres)
  22. if timbres <= 20 then
  23.     if timbres >= 5 then
  24.         tb5 = 0
  25.         while timbres >= 5 do
  26.             tb5 = tb5 +1
  27.             timbres = timbres - 5
  28.         end
  29.         print("timbres5: " .. tb5)
  30.         drop(S5, tb5)
  31.     end
  32.    
  33.     local rare = math.random(0, 10)
  34.     if rare == 10 then
  35.         print("Jackpot (ou pas)")
  36.         rs.setOutput(rs,true)
  37.         sleep(0.5)
  38.         rs.setOutput(rs,false)
  39.     end
  40.    
  41.     print("timbres1: " .. timbres)
  42.     print("-------")
  43.     drop(S1, timbres)
  44.     drop(Slettre, 1)
  45.    
  46. else
  47.     print("Erreur:timbres>20")
  48. end
  49. sleep(2)
  50.  
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement