Fixing loop when setting variables

Setting a variable would makes the application enter in an infinite loop of events (between all the scripts and the back)
This fix makes sure a variable does not emit any event if it is changed to a value it already has.
This commit is contained in:
David Négrier 2021-07-23 11:50:03 +02:00
parent 84df25f863
commit 2aba6b1c27
6 changed files with 61 additions and 23 deletions

View file

@ -327,6 +327,11 @@ export class GameRoom {
const readableBy = variableManager.setVariable(name, value, user);
// If the variable was not changed, let's not dispatch anything.
if (readableBy === false) {
return;
}
// TODO: should we batch those every 100ms?
const variableMessage = new VariableWithTagMessage();
variableMessage.setName(name);