sound seems to be working"

This commit is contained in:
ericrius1 2016-03-21 14:09:02 -07:00
parent 68dc5a8251
commit e5b2483604

View file

@ -4,7 +4,7 @@
var baton; var baton;
var iOwn = false; var iOwn = false;
var updateLoopConnected = false; var soundIntervalConnected = false;
var _this; var _this;
BatonSoundEntity = function() { BatonSoundEntity = function() {
@ -23,18 +23,21 @@
// We already have our injector so just restart it // We already have our injector so just restart it
_this.soundInjector.restart(); _this.soundInjector.restart();
} }
print("EBL SETTING TIMEOUT")
_this.playSoundInterval = Script.setInterval(function() {
print("EBL RESTART");
_this.soundInjector.restart();
}, _this.drumSound.duration * 1000); // Duration is in seconds so convert to ms
iOwn = true; iOwn = true;
updateLoopConnected = true; soundIntervalConnected = true;
print("START UPDATE");
Script.update.connect(_this.update);
} }
function stopUpdateAndReclaim() { function stopUpdateAndReclaim() {
// when the baton is release // when the baton is release
print("CLAIM BATON") print("CLAIM BATON")
if (updateLoopConnected === true) { if (soundIntervalConnected === true) {
updateLoopConnected = false; soundIntervalConnected = false;
Script.update.disconnect(_this.update); Script.clearInterval(_this.playSoundInterval);
} }
iOwn = false; iOwn = false;
@ -63,9 +66,9 @@
}, },
unload: function() { unload: function() {
if (updateLoopConnected === true) { if (soundIntervalConnected === true) {
updateLoopConnected = false; soundIntervalConnected = false;
Script.update.disconnect(_this.update); Script.clearInterval(_this.playSoundInterval);
} }
} }