only send startNearTrigger once

This commit is contained in:
Seth Alves 2017-09-26 15:17:23 -07:00
parent ec80846281
commit 644532dd59

View file

@ -26,6 +26,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
this.previousParentID = {};
this.previousParentJointIndex = {};
this.previouslyUnhooked = {};
this.startSent = false;
this.parameters = makeDispatcherModuleParameters(
520,
@ -76,7 +77,6 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
var targetProps = this.getTargetProps(controllerData);
if (targetProps) {
this.targetEntityID = targetProps.id;
this.startNearTrigger(controllerData);
return makeRunningValues(true, [this.targetEntityID], []);
} else {
return makeRunningValues(false, [], []);
@ -84,12 +84,16 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
};
this.run = function (controllerData) {
if (controllerData.triggerClicks[this.hand] === 0) {
if (!this.startSent) {
this.startNearTrigger(controllerData);
this.startSent = true;
} else if (controllerData.triggerClicks[this.hand] === 0) {
this.endNearTrigger(controllerData);
this.startSent = false;
return makeRunningValues(false, [], []);
} else {
this.continueNearTrigger(controllerData);
}
this.continueNearTrigger(controllerData);
return makeRunningValues(true, [this.targetEntityID], []);
};