svdragster

Untitled

May 26th, 2013
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.07 KB | None | 0 0
  1. --SV Music Maker
  2.  
  3. debug = true
  4.  
  5. noten = {"fis", "g", "gis", "a", "ais", "h", "c1", "cis1", "d1", "dis1", "e1", "f1", "fis1", "g1", "gis1", "a1", "ais1", "h1", "c2", "cis2", "d2", "dis2", "e2", "f2", "fis2"}
  6. back = "c1"
  7. right = "d1"
  8. bottom = "e1"
  9. left = "f1"
  10.  
  11. function klicks(note)
  12.   for i=1, #noten do
  13.     if note == noten[i] then
  14.       anzahlKlicks = i-1
  15.       print("For "..note.." click "..anzahlKlicks.." times.")
  16.     end
  17.   end
  18. end
  19.  
  20. function play(note)
  21.   if debug then
  22.     print("function play")
  23.   end
  24.   if note == back then
  25.     redstone.setOutput("back", true)
  26.   elseif note == right then
  27.     redstone.setOutput("right", true)
  28.   elseif note == bottom then
  29.     redstone.setOutput("bottom", true)
  30.   elseif note == left then
  31.     redstone.setOutput("left", true)
  32.   end
  33.   sleep(0.01)
  34.   redstone.setOutput("back", false)
  35.   redstone.setOutput("right", false)
  36.   redstone.setOutput("bottom", false)
  37.   redstone.setOutput("left", false)
  38. end
  39.  
  40. function music()
  41.   rednet.open("top")
  42.   while true do
  43.     local id, toPlay = rednet.receive()
  44.     play(toPlay)
  45.   end
  46. end
  47.  
  48. function menu()
  49.     while true do
  50.         print("Type help for a list of commands.")
  51.         input = read()
  52.  
  53.         if input == "help" then
  54.           print("Type set to change notes,")
  55.           print("Type clicks to see the clicks.")
  56.         end
  57.        
  58.         if input == "set" then
  59.           print("Set notes: back, right, bottom, left")
  60.           write("back: ")
  61.           back = read()
  62.           write("right: ")
  63.           right = read()
  64.           write("bottom: ")
  65.           bottom = read()
  66.           write("left: ")
  67.           left = read()
  68.           if debug then
  69.             print("open /SVMM/bindings in mode w")
  70.           end
  71.           --[[file = fs.open("/SVMM/bindings", "w")
  72.           print("back")
  73.           file.writeLine("back")
  74.           print("right")
  75.           file.writeLine(right)
  76.           file.writeLine(bottom)
  77.           file.writeLine(left)
  78.           fs.close()]]--
  79.         end
  80.        
  81.         if input == "clicks" then
  82.           klicks(back)
  83.           klicks(right)
  84.           klicks(bottom)
  85.           klicks(left)
  86.         end
  87.     end
  88. end
  89.  
  90. print("Running Parallel.")
  91.  
  92. parallel.waitForAll(menu, music)
  93.  
  94.  
  95. klicks(back)
  96. klicks(right)
  97. klicks(bottom)
  98. klicks(left)
Advertisement
Add Comment
Please, Sign In to add comment