content/hifi-content/wadewatts/scoreboard1.js
2022-02-14 02:04:11 +01:00

42 lines
1.1 KiB
JavaScript

(function() {
var messageChannel = 'MESSAGE_CHANNEL_GATE_GAME';
var entityID;
function sendMessage(message) {
message.entityID = entityID;
Messages.sendMessage(
messageChannel,
JSON.stringify(message)
);
}
function onReceivedMessage(channel, message, senderID) {
try {
var data = JSON.parse(message);
} catch (e) {
print('Error parsing message: ' + message);
return;
}
print('data: ' + JSON.stringify(data));
switch (data.type) {
case 'PASS':
print(data.payload);
break;
}
}
return {
preload: function(id) {
entityID = id;
Messages.subscribe(messageChannel);
Messages.messageReceived.connect(null, onReceivedMessage);
print('Hello Scoreboard');
},
unload: function(id) {
Messages.unsubscribe(messageChannel);
Messages.messageReceived.disconnect(null, onReceivedMessage);
},
};
})