Advertisement
meuced

Affich7digit_digit

Mar 16th, 2014
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.03 KB | None | 0 0
  1. local idChannel = 126
  2. local numdigit = 0
  3. local correspondance = {}
  4. correspondance[0] = { 1,1,1,0,1,1,1 }
  5. correspondance[1] = { 0,0,1,0,0,1,0 }
  6. correspondance[2] = { 1,1,0,1,0,1,1 }
  7. correspondance[3] = { 1,0,1,1,0,1,1 }
  8. correspondance[4] = { 0,0,1,1,1,1,0 }
  9. correspondance[5] = { 1,0,1,1,1,0,1 }
  10. correspondance[6] = { 1,1,1,1,1,0,1 }
  11. correspondance[7] = { 0,0,1,0,0,1,1 }
  12. correspondance[8] = { 1,1,1,1,1,1,1 }
  13. correspondance[9] = { 1,0,1,1,1,1,1 }
  14.  
  15. if fs.exists("digit.ini") then
  16.     h = fs.open("digit.ini", "r")
  17.     numdigit = h.readAll()
  18.     h.close()
  19. else
  20.     h = fs.open("digit.ini", "w")
  21.     print("1er demarrage, indiquer num digit :")
  22.     numdigit = read()
  23.     h.write(numdigit)
  24.     h.close()
  25. end
  26.  
  27. modem = peripheral.wrap("bottom")
  28.  
  29. while true do
  30.     modem.open(idChannel)
  31.     event, modemSide, senderChannel, replyChannel, text, senderDistance = os.pullEvent("modem_message")
  32.  
  33.     if correspondance[text][tonumber(numdigit)] == 1 then
  34.         redstone.setOutput("back", true)
  35.     else
  36.         redstone.setOutput("back", false)
  37.     end
  38.  
  39.     modem.close(idChannel)
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement