Advertisement
9551

Untitled

Jun 27th, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.96 KB | None | 0 0
  1. local wait = sleep
  2. local bingNum = 1
  3. local bingPlayed = 1
  4. local bingTotal = 0
  5. local time = 0.5
  6. local t = os.date("!*t")
  7. local f = fs.open("User/Cloud/bing/Log/log", "a")
  8. local speaker = peripheral.find("speaker")
  9. local gla = peripheral.find("arController")
  10. local m = peripheral.wrap("monitor_0")
  11. local posX = 5
  12. local posY = 60
  13. local mposX = 1
  14. local mposY = 1
  15. local size = m.getSize()
  16.  
  17. m.clear()
  18. m.setCursorPos(1, 1)
  19. m.setPaletteColour(colours.orange, 0x33dd33)
  20. m.setTextColour(colours.orange)
  21. m.setTextScale(0.8)
  22.  
  23. print("instrument to use")
  24. local instr = read()
  25. print("volume(range of the audio)")
  26. local vol = tonumber(read())
  27.  
  28. while true do
  29. if bingNum > 400 then
  30. time = 0.05
  31. elseif bingNum > 250 then
  32. time = 0.1
  33. elseif bingNum > 150 then
  34. time = 0.2
  35. elseif bingNum > 100 then
  36. time = 0.3
  37. elseif bingNum > 50 then
  38. time = 0.4
  39. else
  40. time = 0.5
  41. end
  42.  
  43. for i = 1, bingNum do
  44. local pitch = math.random(0, 24)
  45. end
  46.  
  47. speaker.playNote(instr, vol, pitch)
  48. bingTotal = bingTotal + 1
  49. print("That was bing number", bingPlayed)
  50.  
  51. gla.clear() -- clears glasses ready for next writes
  52. m.clear() -- Clears monitor ready for next writes
  53. if bingNum < 10 then -- writes the instrument to the Glasses for the first 10 steps
  54. gla.drawString("The current instruement is: " .. instr, posX, posY, 0x59de92) -- Writes the instrument to Glasses
  55. gla.drawString("The current bing is: " .. bingPlayed, posX, posY + 10, 0x59de92) -- Writes bingPlayed to Glasses
  56. gla.drawString("That bings pitch is: " .. pitch, posX, posY + 20, 0x59de92) -- Writes the notes pitch
  57. gla.drawString("The number of bings in queue is: " .. bingNum, posX, posY + 30, 0x59de92) -- Writes bingNum to Glasses
  58. gla.drawString("The total number of bings played is : " .. bingTotal, posX, posY + 40, 0x59de92) -- Writes bingTotal to Glasses
  59. else
  60. gla.drawString("The current bing is: " .. bingPlayed, posX, posY, 0x59de92) -- Writes bingPlayed to Glasses
  61. gla.drawString("That bings pitch is: " .. pitch, posX, posY + 10, 0x59de92) -- Writes the notes pitch
  62. gla.drawString("The number of bings in queue is: " .. bingNum, posX, posY + 20, 0x59de92) -- Writes bingNum to Glasses
  63. gla.drawString("The total number of bings played is : " .. bingTotal, posX, posY + 30, 0x59de92) -- Writes bingTotal to Glasses
  64. end
  65.  
  66. m.clear()
  67. m.write("The instrument is")
  68. m.setCursorPos(mposX, mposY + 1)
  69. m.write(instr)
  70. m.setCursorPos(mposX, mposY + 2)
  71. m.write("The current bing is")
  72. m.setCursorPos(mposX, mposY + 3)
  73. m.write(bingPlayed)
  74. m.setCursorPos(mposX, mposY + 4)
  75. m.write("That bings pitch is")
  76. m.setCursorPos(mposX, mposY + 5)
  77. m.write(pitch)
  78. m.setCursorPos(mposX, mposY + 6)
  79. m.write("The number of bings in queue is")
  80. m.setCursorPos(mposX, mposY + 7)
  81. m.write(bingNum)
  82. m.setCursorPos(mposX, mposY + 8)
  83. m.write("The total number of bings played is")
  84. m.setCursorPos(mposX, mposY + 9)
  85. m.write(bingTotal)
  86. m.setCursorPos(mposX, mposY) -- sets monitor cursor back to default position
  87.  
  88. if bingPlayed % 15 == 0 then -- Every 15 bings it will print the current bingNum
  89. print("The current amount of bings you are hearing is", bingNum)
  90. end
  91.  
  92. bingPlayed = bingPlayed + 1
  93. wait(time)
  94. end
  95. bingPlayed = 1
  96.  
  97. print("The number of bings you just heard is:", bingNum)
  98. print("The total number of bings played is:", bingTotal)
  99.  
  100. if bingNum % 10 == 0 then -- writes log file every 10 steps
  101. t = os.date("!*t")
  102. local f, err = fs.open("User/Cloud/bing/Log/log", "a")
  103. if err then
  104. error(err, 0)
  105. end
  106. f.write(t.hour .. ":" .. t.min .. ":" .. t.sec .. " " .. bingNum .. " reached \n")
  107. f.write("The total number of bings so far is " .. bingTotal .. " \n")
  108. f.close()
  109. print("log updated")
  110. end
  111. wait(6)
  112.  
  113. bingNum = bingNum + 1
  114.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement