I may not have much to say (and this question may be broad-ish), but can you accurately calculate BPM in RBX.lua? Doing some "deep" web search was not helpful as there were not many tutorials on calculating BPM. Whilst one site may have a tutorial, tempotap.com seems to have on what I was looking for. It works, but it is not very accurate on Lua
001 | --Javascript code taken from tempotap.com |
002 | --[[ |
003 | var startTime = null; |
004 | var currentBeats = 0; |
005 |
006 |
007 |
008 | /* |
009 | $(window).keypress(function(event) { |
010 | var spaceBarKey = 32; |
011 | var lowerXKey = 120; |
012 | var upperXKey = 88; |
013 |
014 | var result = true; |
015 |
(It's milliseconds
, by the way)
Change line 87 to use tick
instead of time
-- these are two different types of time and should not be combined (tick is real time seconds, time is game seconds; game seconds can go slower than real seconds in some circumstances)
Then change line 96-99 to be:
1 | minutes = (now - starttime) / 60 --tick() is measured in seconds, divide by 60 seconds in a minute |
2 | bpm = currentBeat / minutes --# beats / minutes == "beats per minute" |
Notably, you were using "%" when I think you needed to use "/".