mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
(function() {
|
|
Script.include('utils.js');
|
|
|
|
Display = function() {
|
|
};
|
|
Display.prototype = {
|
|
preload: function(entityID) {
|
|
this.entityID = entityID;
|
|
|
|
this.entityIDsThatHaveCollidedWithMe = [];
|
|
|
|
var props = Entities.getEntityProperties(this.entityID, ['userData', 'parentID']);
|
|
var data = utils.parseJSON(props.userData);
|
|
if (data !== undefined && data.displayType !== undefined) {
|
|
this.gameChannel = data.displayType + "-" + props.parentID;
|
|
} else {
|
|
print("scoreboardEntity.js | ERROR: userData does not contain a game channel and/or team number");
|
|
}
|
|
|
|
Messages.subscribe(this.gameChannel);
|
|
Messages.messageReceived.connect(this, this.onReceivedMessage);
|
|
},
|
|
unload: function() {
|
|
Messages.unsubscribe(this.gameChannel);
|
|
Messages.messageReceived.disconnect(this, this.onReceivedMessage);
|
|
},
|
|
onReceivedMessage: function(channel, message, senderID) {
|
|
if (channel === this.gameChannel) {
|
|
Entities.editEntity(this.entityID, {
|
|
text: message
|
|
});
|
|
}
|
|
},
|
|
};
|
|
|
|
return new Display();
|
|
});
|